This shows the generation of different shapes including fractals using Num2D, variables which can be in cartesian (x,y) or polar (size angle) form. They are like complex numbers.
Shapes are defined by Polar num2Ds which represent the end of each line relative to its start. The polar form is convenient for calculating shapes and for drawing them scaled or rotated. However, drawing is from the current position to that plus the line, so the Cartesian equivalent is easier.
The user can select one of three geometric shapes, and these are transformed before being drawn : size 0.8^n angle 30*n, where n is 'operations'.
The user can select fractals, which are defined by an Initiator (one or more lines) and a Generator (many lines). Each line in the Initiator is replaced by the lines in the Generator, which can then be replaced. This continues until the set maximum level is reached. Polar numbers are used, as a replaced line is the product of the original line and that from the generator.
The Basic, Koch, Snowflake and Forest fractals are generated in this way. The Dragon and Sierpinski triangles require the replacement angle to be negated alternately - the conjugate of the generator number being used. For the dragon, this starts with the second, whereas for the triangle, each level toggles whether the first or second line's angle is negated.
The Sierpinksi and Hilbert space filling curves can also be drawn : their lines are generated in polar form. Different levels can be selected.
The user use the More/Fewer operations to set the level of replacement before lines are drawn / scaling of shapes.
You can opt to view the first few num2D numbers of lines drawn (in polar form) or their end positions (in Cartesian form).
Shapes Triangle Square Pentagon Robot
Fractal Basic Koch SnowFlake Forest
Advanced Dragon Sierpinski Triangle
Space Filling Sierpinski Curve Hilbert Curve
Operations:
View:
List: None Lines Positions