MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
LevyCurve.cpp File Reference

Draws Levy Curve with the Chaos Game algorithm. More...

Go to the source code of this file.

Detailed Description

Draws Levy Curve with the Chaos Game algorithm.

Author
Mitch Richling http://www.mitchr.me/
Standards
C++23
See also
https://www.mitchr.me/SS/LevyCurveChaosGame/index.html
Details


A chaos game that generates a Levy Curve:

Start at a random point. Randomly select one of two transformations, and transform the point. Repeat this process with the new point. The two transformations are given by:

\[ \begin{array}{ll} T_1(\vec{x}) & = \left[ {\begin{array}{rr} \frac{1}{2} & \frac{1}{2} \\ -\frac{1}{2} & \frac{1}{2} \\ \end{array} } \right] \cdot\vec{x} \\ T_2(\vec{x}) & = \left[ {\begin{array}{rr} \frac{1}{2} & -\frac{1}{2} \\ \frac{1}{2} & \frac{1}{2} \\ \end{array} } \right] \cdot\vec{x}- \left[ {\begin{array}{rr} \frac{1}{2} \\ \frac{1}{2} \\ \end{array} } \right] \end{array} \]

We can easily expand these transforms into C code with maxima:

A : matrix([.5, .5], [-.5, .5]);
B : matrix([.5, -.5], [ .5, .5]);
C : matrix([-.5], [-.5]);
X : matrix([x], [y]);
display2d:false;
A.X;
matrix([0.5*y+0.5*x],[0.5*y-0.5*x])
B.X+C;
matrix([(-0.5*y)+0.5*x-0.5],[0.5*y+0.5*x-0.5])

Definition in file LevyCurve.cpp.