Fractals/Computer graphic techniques/2D/plane
2D plane direct links:
Geometry
edit
Quality of image geometry:
- good ( not distorted)
- bad ( distorted)
visualisation
edit- grid
- level sets
- checker board ( chess board)
Viewport (visible part of the plane )
editA viewport is a polygon viewing region in computer graphics.[3]
Description
editRectangle 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
- radius
"People specify fractal coordinates in many ways. Some people use the coordinates of the upper-left and lower-right visible points, specifying the coordinates as four numbers x1, y1, x2, y2. To set the same viewpoint in XaoS, set the real portion of the center to (x1+x2)/2, the imaginary part of center to (y1+y2)/2, and the radius to the greater of x2-x1 and y2-y1." ( from Xaos doc[4] )
Corners
editStandard 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
See demo par file :
Mandel_Demo { ; PAR for initialization of Fractint demo reset=1900 type=mandel corners=-2.5/1.5/-1.5/1.5 params=0/0 inside=0 sound=no }
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.
int SetPlaneFromCorners(double CxMin , double CxMax, double CyMin , double CyMax){
Radius = fabs(CyMax-CyMin)/2.0;
Magnification = 1.0/Radius;
// http://www.purplemath.com/modules/midpoint.htm
Center = (CxMax+CxMin)/2.0 + I*(CyMax+CyMin)/2.0;
return 0;
}
Center and ...
edit"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).
magnification
editFractint uses Mag ( compare with Xmagfactor)
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
width
editWolf Jung uses center and width in Mandel:
/*
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
width and height
editto describe plane ( view ) Xaos uses:
- 4 numbers in scripts
- 3 numbers in menu
Xaos uses to call it "radius" but it is defind as : the greater of (x2-x1= width) and y2-y1=height."
radius
editIt is very usefull for zooming : fix center and only change radius.
Claude Heiland-Allen[5] use center and radius for parameter plane of complex quadratic polynomial:
Radius is defined as:
- the radius of a circle that fits within the actual frame of the image
- "the difference in imaginary coordinate between the center and the top of the axis-aligned view rectangle".
- "px_radius is half the width of the image (in real coordinates)" [6]
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;
complex double coordinate(int i, int j, int width, int height, complex double center, double radius) {
double x = (i - width /2.0) / (height/2.0);
double y = (j - height/2.0) / (height/2.0);
complex double 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
}
}
another version
int main()
{
int aa = 4;
int w = 800 * aa;
int h = 800 * aa;
#pragma omp parallel for schedule(static, 1)
for (int j = 0; j < h; ++j)
{
double y = (h/2 - (j + 0.5)) / (h/2) * r;
for (int i = 0; i < w; ++i)
{
double x = (i + 0.5 - w/2) / (h/2) * r;
double _Complex c = x + I * y;
// proceed
}
}
return 0;
}
The same in GLSL ( for Shadertoy) :
vec2 GiveCoordinate(vec2 center, float radius, vec2 fragCoord, vec3 iResolution)
{
// from pixel to world coordinate
// now point (0,0) is left bottom
// point (iResolution.x, iResolution.y) is right top
float x = (fragCoord.x - iResolution.x/2.0)/ (iResolution.y/2.0);
float y = (fragCoord.y - iResolution.y/2.0)/ (iResolution.y/2.0);
vec2 c = vec2(center.x + radius*x, center.y + radius*y) ;
return c ;
}
Set plane corners from radius, center and aspect ratio:
int SetPlane(complex double center, double radius, double a_ratio){
ZxMin = creal(center) - radius*a_ratio;
ZxMax = creal(center) + radius*a_ratio; //0.75;
ZyMin = cimag(center) - radius; // inv
ZyMax = cimag(center) + radius; //0.7;
double PixelWidth = (ZxMax-ZxMin)/iWidth;
double PixelHeight = (ZyMax-ZyMin)/iHeight; // pixel_size = PixelWidth = PixelHeight
return 0;
}
Orientation
editThere is a major incompatability between:
- the standard Math convention taught in Math class = standard coordinates (y-up)
- some CS graphics programming systems (but not all) = y-down
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.
OpenGL is right handed in object space and world space. But in window space (aka screen space) we are suddenly left handed.[7]
See also
Aspect ratio
edit- image
- display
image
editThe aspect ratio of an image is the ratio of its width to its height, and is expressed with two numbers separated by a colon, such as 16:9, sixteen-to-nine. For the x:y aspect ratio, the image is x units wide and y units high. Common aspect ratios are 1.85:1 and 2.39:1 in cinematography, 4:3 and 16:9 in television photography, and 3:2 in still photography.
Display Aspect ratio
editThe aspect ratio, or more precisely the Display Aspect Ratio (DAR)[8] – the aspect ratio of the image as displayed. For TV:
- for TV DAR as traditionally 4:3 (a.k.a. Fullscreen)
- now is 16:9 (a.k.a. Widescreen) now the standard for HDTV
Optimisation
edit- "recursive algorithm to split the image up into blocks, and tests each block to see whether it lies inside a “black area”." by Michael Hogg[9]
- Poincaré half-plane metric for zoom animation
- A Simple Optimization of Fractal Animation by Wei-Yin Chen, You-Sheng Yang and Kun-Mao Liang
- optimizing zoom animations by Claude Heiland-Allen [10]
- reenigne blog : recursive subdivision
- Xaos - algorithm description
- New fast method !!!!
- Zooming by Albert Lobo Cusidó
- Rendering the Mandelbrot Set — with an example implementation in javascript By Christian Stigen Larsen
- perturbation
Patterns
editReferences
edit- ↑ Euclidean space in wikipedia
- ↑ Non-Euclidean Geometry by Malin Christersson ( 2018)
- ↑ viewport in wikipedia
- ↑ Xaos - view
- ↑ Claude Heiland-Allen blog
- ↑ Exponential Map by Robert P. Munafo, 2010 Dec 5. From the Mandelbrot Set Glossary and Encyclopedia, by Robert Munafo, (c) 1987-2020.
- ↑ stackoverflow question: is-opengl-coordinate-system-left-handed-or-right-handed
- ↑ wikipedia : Aspect_ratio_(image)
- ↑ michael hogg : fractalnet
- ↑ optimizing zoom animations by Claude Heiland-Allen