Last modified on 5 November 2014, at 18:34

Fractals/Computer graphic techniques/2D/plane

Viewport = part of the planeEdit

A viewport is a polygon viewing region in computer graphics.[1]

TypesEdit

  • world coordinates ( with floating point valuese )
  • screen coordinates ( with integer values ) used for pixels of the screen or bitmap or array

Relation between these 2 types creates new items :

  • pixel size ( pixel spacing ) related with zoom
  • mapping ( converting) between screen and integer coordinates[2][3]
  • clipping
  • rasterisation

DescriptionEdit

Rectangle part of 2D plane can be described by :

  • corners ( 4 real numbers or 2 complex numbers = 2D points)
  • center and :
    • width ( 3 real numbers )
    • magnification ("If you use the center, you can change the zoom level and the plot zooms in/out smoothly on the same center point. " Duncan C)
    • radius

CornersEdit

Standard description in Fractint, Ultra Fractal, ChaosPro and Fractal Explorer are corners. For example initial plane for Mandelbrot set is

 Corners:                X                     Y
 Top-l          -2.5000000000000000    1.5000000000000000
 Bot-r           1.5000000000000000   -1.5000000000000000
 Ctr -0.5000000000000000   0.0000000000000000  Mag 6.66666667e-01
 X-Mag-Factor     1.0000   Rotation    0.000   Skew    0.000

Display window of parameter plane has :

  • a horizontal width of 4 (real)
  • a vertical width (height) of 3 (imag)
  • an aspect ratio (proportion) 4/3 ( also in pixels 640/480 so ther is no distorsion)
  • center z=-0.5

For julia set/ dynamic plane has :

Corners:                X                     Y
Top-l          -2.0000000000000000    1.5000000000000000
Bot-r           2.0000000000000000   -1.5000000000000000
Ctr  0.0000000000000000   0.0000000000000000  Mag 6.66666667e-01
X-Mag-Factor     1.0000   Rotation    0.000   Skew    0.000


Description from documentation of Fractint :


CORNERS=[xmin/xmax/ymin/ymax[/x3rd/y3rd]]

Example: corners=-0.739/-0.736/0.288/0.291

Begin with these coordinates as the range of x and y coordinates, rather than the default values of (for type=mandel) -2.0/2.0/-1.5/1.5. When you specify four values (the usual case), this defines a rectangle: x- coordinates are mapped to the screen, left to right, from xmin to xmax, y-coordinates are mapped to the screen, bottom to top, from ymin to ymax. Six parameters can be used to describe any rotated or stretched parallelogram: (xmin,ymax) are the coordinates used for the top-left corner of the screen, (xmax,ymin) for the bottom-right corner, and (x3rd,y3rd) for the bottom-left. Entering just "CORNERS=" tells Fractint to use this form (the default mode) rather than CENTER-MAG (see below) when saving parameters with the [B] command.

Center and ...Edit

magnificationEdit

CENTER-MAG=[Xctr/Yctr/Mag[/Xmagfactor/Rotation/Skew]]

This is an alternative way to enter corners as a center point and a magnification that is popular with some fractal programs and publications. Entering just "CENTER-MAG=" tells Fractint to use this form rather than CORNERS (see above) when saving parameters with the [B] command. The [TAB] status display shows the "corners" in both forms. When you specify three values (the usual case), this defines a rectangle: (Xctr, Yctr) specifies the coordinates of the center of the image.

Mag indicates the amount of magnification to use. Initial value ( no zoom ) is 6.66666667e-01.

Six parameters can be used to describe any rotated or stretched parallelogram: Xmagfactor tells how many times bigger the x- magnification is than the y-magnification,

Rotation indicates how many degrees the image has been turned.

Skew tells how many degrees the image is leaning over. Positive angles will rotate and skew the image counter-clockwise.


Parameters can be saved to parmfile called fractint.par

widthEdit

Wolf Jung uses center and width:

/* 
   from mndlbrot.cpp  by Wolf Jung (C) 201
   These classes are part of Mandel 5.7, which is free software; you can
   redistribute and / or modify them under the terms of the GNU General
   Public License as published by the Free Software Foundation; either
   version 3, or (at your option) any later version. In short: there is
   no warranty of any kind; you must redistribute the source code as well
*/
void mndlbrot::startPlane(int sg, double &xmid, double &rewidth) const
{  if (sg > 0) 
     { xmid = -0.5; rewidth = 1.6; } // parameter plane
     else { xmid = 0; rewidth = 2.0; } // dynamic plane

radiusEdit

Claude Heiland-Allen[4] uses center and radius for parameter plane of complex quadratic polynomial:

view="-0.75 0 1.5" # standard view of parameter plane : center_re, center_im, radius


  // modified code using center and radius to scan the plane 
  int height = 720;
  int width = 1280;
  double dWidth;
  double dRadius = 1.5;
  double complex center= -0.75*I;
  double complex c;
  int i,j;
 
  double width2; // = width/2.0
  double height2; // = height/2.0
 
  width2 = width /2.0;
  height2 = height/2.0;
 
double complex coordinate(int i, int j, int width, int height, double complex center, double radius) 
{
  double x = (i - width2) / height2;
  double y = (j - height2) / height2;
  double complex c = center + radius * (x - I * y);
  return c;
}
 
for ( j = 0; j < height; ++j) {
    for ( i = 0; i < width; ++i) {
      c = coordinate(i, j, width, height, center, dRadius);
      // do smth 
       }
     }


or simply :


 
 double pixel_spacing = radius / (height / 2.0);
 complex double c = center + pixel_spacing * (x + I * y);

OrientationEdit

Check orientation of the plane by marking first quadrant of Cartesian plane :

if (x>0 && y>0) Color=MaxColor-Color; 

It should be in upper right position.



OptimisationEdit

PrecisionEdit

What precision do I need for zoom ?

ScanningEdit

See :

  • Fractint Drawing Methods[7]
  • Fratal Witchcraft drawing methods by Steven Stoft[8]
  • AlmondBread algorithms [9]

All the pixelsEdit

Scan the plane :

  • all pixels ( plane is scaned pixel by pixel )
  • the same pixel size


Here in Lisp

; common lisp. Here float values can be used,  there is no mapping
(loop for y from -1.5 to 1.5 by 0.1 do
      (loop for x from -2.5 to 0.5 by 0.05 do
            (princ (code-char 42))) ; print char
      (format t "~%")) ; new line

and in C

/* c */
/* screen coordinate = coordinate of pixels */      
int iX, iY, 
iXmin=0, iXmax=1000,
iYmin=0, iYmax=1000,
iWidth=iXmax-iXmin+1,
iHeight=iYmax-iYmin+1;
 
/* world ( double) coordinate = parameter plane*/
const double ZxMin=-5;
const double ZxMax=5;
const double ZyMin=-5;
const double ZyMax=5;
 
/* */
double PixelWidth=(ZxMax-ZxMin)/iWidth;
double PixelHeight=(ZyMax-ZyMin)/iHeight;
double Zx, Zy,    /* Z=Zx+Zy*i   */
       Z0x, Z0y,  /* Z0 = Z0x + Z0y*i */
 
 for(iY=0;iY<iYmax;++iY)
      { Z0y=ZyMin + iY*PixelHeight; /* mapping from screen to world; reverse Y  axis */
        if (fabs(Z0y)<PixelHeight/2) Z0y=0.0; /* Zy = 0 is a special value  */    
        for(iX=0;iX<iXmax;++iX)
         {    /* initial value of orbit Z0 */
           Z0x=ZxMin + iX*PixelWidth;
          }
      }

Plane transformationsEdit

ZoomEdit

Mandelbrot zoom created using Double-double precision


NotationEdit

If you want to zoom [10]

baseSize // constant value =  extend in real and imaginary axis when zoomLevel is zero.
zoomLevel // inital value = 0.0
zoomFactor = 2^(-zoomLevel) // initial value = 1.0 = no zoom
sizeX = zoomFactor * baseSize
sizeY = zoomFactor * baseSize   
minImaginary = centerY - sizeY/2
maxImaginary = centerY + sizeY/2

Note that base of zoom factor is important when one wants to optimize zooming by using previosly computed pixels.


Usually other notation is used :

baseSize // constant value =  extend in real and imaginary axis when zoomLevel is zero.
zoomLevel // inital value = 0.0
zoomFactor = 10^zoomLevel // initial value = 1.0 = no zoom
sizeX =  baseSize / zoomFactor
sizeY = baseSize / zoomFactor   
minImaginary = centerY - sizeY/2
maxImaginary = centerY + sizeY/2


Pixel sizeEdit

Pixel size is size of a pixel in a world coordinate. For linear scale and same resolution on both axes :

iSize = iXmax - iXmin ; // width of image in pixels ( integer or screen ) coordinate ; pixels are numbered from iXmin to iXmax; image is rectangular
fSize = CxMax-CxMin // width of image in world ( floating point ) coordinate
PixelWidth = fWidth / iWidth
PixelSize = PixelWidth // 
Zoom exponent Zoom level [11] iSize fSize PixelSize Decimal digits Binary digits ( precision)
0 1 = 10^0 = 1.0e0 1000 3.0 0.003
1 10 = 10^1 =1.0e1 1000 0.3 0.0003
2 100 = 10^2 = 1.0e2 1000 0.03 0.00003 6
3 1000 = 10^3 = 1.0e3 1000 0.003 0.0000003 7
275 2.1*10^{275} = 2.1E275[12] 1000 1.42857142857143*10^{−275} 1.42857142857143*10^{−278} 278 945
2167 1E2167 [13]
n 10^n 10^3 10^{-n} 10^{-n-3} n+3 3.4*(n+3)

See also pixel spacing

Maximal zoomEdit

Maximal zoom factor is :


Parameter file for FractInt ( extension PAR) :

top-mag1500      { ; a really really deep zoom        Wesley Loewer
                   ; highly self similar
                  ; took over 1200 hours at 320x240 on a 486sx/25
                  reset=1920 type=mandel passes=b center-mag=0.0/1.0/1e+1500
                  maxiter=15000  }

Maximal zoom is correlated with :

  • precision ( single , double, Quadruple precision, multiple-precision (MP) )[17][18]
  • algorithm

Examples :

  • zoom factor for video [19]
  • zoom factor [20]

OptimisationEdit

Möbius transformationEdit

Riemann sphere

A Möbius transformation of the extended complex plane ( the Riemann sphere ) :

f\colon \hat{\mathbf{C}} \rightarrow \hat{\mathbf{C}}


is a rational function with general for :

 f(z) =\frac{az+b}{cz+d}

It's inverse function in general form is :

f^{-1}(w) = \frac{dw-b}{-cw+a}

Specifying a transformation by three pointsEdit

Given a set of three distinct points z1, z2, z3 on the one Riemann sphere ( let's call it z-sphere) and a second set of distinct points w1, w2, w3 on the second sphere ( w-sphere) , there exists precisely one Möbius transformation f(z) with :

  •  f(z_i) = w_i
  • f^{-1}(w) = z_i

for i=1,2,3

Mapping to 0, 1, infinityEdit

The Möbius transformation with an explicit formula :[22]

f(z)= \frac {(z-z_1)(z_2-z_3)}{(z-z_3)(z_2-z_1)}

maps :

  • z1 to w1= 0
  • z2 to w2= 1
  • z3 to w3= ∞
the unit circle to the real axis - first methodEdit

Let's choose 3 z points on a circle :

  • z1= -1
  • z2= i
  • z3= 1

then the Möbius transformation will be :

f(z)= \frac {(z+1)(i-1)}{(z-1)(i+1)}

Knowing that : [23]

i+1 = -i (i -1 )

one can simplify this to :

f(z)= i \frac {z+1}{z-1}

In Maxima CAS one can do it :

(%i1) rectform((z+1)*(%i-1)/((z-1)*(%i+1)));
(%o1) (%i*(z+1))/(z−1)

where coefficients of the general form are :

a = i
b = i
c = 1
d = -1

so inverse function can be computed using general form :

f^{-1}(w) = \frac{dw-b}{-cw+a} = \frac{-i - w}{i-w}

Lets check it using Maxima CAS :

(%i3) fi(w):=(-%i-w)/(%i-w);
(%o3) fi(w):=−%i−w/%i−w
(%i4) fi(0);
(%o4) −1
(%i5) fi(1);
(%o5) −%i−1/%i−1
(%i6) rectform(%);
(%o6) %i

Find how to compute it without symbolic computation program (CAS)  :

(%i3) fi(w):=(-%i-w)/(%i-w);
(%o3) fi(w):=−%i−w/%i−w
(%i8) z:x+y*%i;
(%o8) %i*y+x
(%i9) z1:fi(w);
(%o9) (−%i*y−x−%i)/(−%i*y−x+%i)
(%i10) realpart(z1);
(%o10) ((−y−1)*(1−y))/((1−y)^2+x^2)+x^2/((1−y)^2+x^2)
(%i11) imagpart(z1);
(%o11) (x*(1−y))/((1−y)^2+x^2)−(x*(−y−1))/((1−y)^2+x^2)
(%i13) ratsimp(realpart(z1));
(%o13) (y^2+x^2−1)/(y^2−2*y+x^2+1)
(%i14) ratsimp(imagpart(z1));
(%o14) (2*x)/(y^2−2*y+x^2+1)
2 steps of unrolling the main cardioid of Mandelbrot set: Moebius map and conformal map
Unrolled main cardioid of Mandelbrot set for periods 7-13

So using notation :

 z = x + yi = f^{-1}(w)

one gets :

 x = \operatorname{Re}(z) = \operatorname{Re}(f^{-1}(w))   = \frac{y^2+x^2-1}{y^2-2y+x^2+1}

y = \operatorname{Im}(z) = \operatorname{Im}(f^{-1}(w))  = \frac{2x}{y^2-2y+x^2+1}


It can be used for unrolling the Mandelbrot set components [24]

the unit circle to the real axis - second methodEdit

Function :

f(z) = i\frac{z-1}{z+1}

sends the unit circle to the real axis :

  • z=1 to w=0
  • z=i to w=1
  • z=-1 to w=\infty

Mapping to the imaginary axisEdit

Function f(z) = \frac{z-1}{z+1} sends the unit circle to the imaginary axis.[25]

ReferencesEdit

  1. viewport in wikipedia
  2. How to convert world to screen coordinates and vice versa
  3. | How to transform 2D world to screen coordinates OpenGL
  4. Claude Heiland-Allen blog
  5. michael hogg : fractalnet
  6. optimizing zoom animations by Claude Heiland-Allen
  7. Fractint Drawing Methods
  8. Synchronous-Orbit Algorithm by R Munafo
  9. The Almond BreadHomepage by Michael R. Ganss
  10. stackoverflow : how-do-i-zoom-into-the-mandelbrot-set
  11. zoom level definition
  12. Fractal Journey by ORSON WANG
  13. Zoom level discussion - Maximum zoom level supported by Fractal eXtreme
  14. video Mandelbrot Zoom 999 on youtube by phaumann
  15. zooming with exteded precision in Delphi
  16. DeepZooming with FractInt
  17. [:w:wiki/Talk:Floating_point/Archive_4#No_mention_of_Double-double No_mention_of_Double-double - talk]
  18. stackoverflow : mandelbrot-set-reaches-to-its-limit-way-too-soon
  19. fractalforums : problem with zooming transform one view rect-to another
  20. fractalforums "basic-location-and-zoom-question
  21. optimizing_zoom_animations by Claude Heiland-Allen
  22. Triple transitivity by David J Wright 2004-12-04
  23. math.stackexchange questions : how-to-do-this-transformation-of-complex-rational-function
  24. Stretching cusps by Claude Heiland-Allen
  25. math.stackexchange questions: what-mobius-transformation-maps-the-unit-circle-z-z-1-to-the-real-axis/335061#335061