This is a Chaotic Fractal generator based upon the work done by Michael Barnsley et alia and is implemented in Numpy. A chaotic fractal is a fractal for which the points are generated by selecting from a collection of vector functions with weighted probabilities.
- matplotlib.pyplt, numpy, pylab, scipy.stats, tqdm, pprint, random, math, sys, time, pylab (optional)
bfern
: barnsley fern as researched by michael barnsleyrose
: a conch shell like spiraling rose - a neat constant set found...koch
: Koch curve (approximate)natgalaxy
: A galaxy like spiral ascendingtriangle
: A serinpenski trianglegoldenDragon
: the golden dragon spiral based off of the golden ratiobtree
: A Symetric Binary tree with no stems scale 0.7 rotation 9 degbranch
: golden dragon rotated by the angles of the triangle conecting the golden dragon's attractorspenta
: a slice of a branched pentagonal fractal which is a fractal itselfspentagon
:Serenpenski Pentagonscarpet
: Serenpenski Carpetpythagorean
: Pythagorean tree note a special d constant is associated with it in the constants.py filesfcurve
: A space filling curvedurer
: Durer pentagon ...antisnow
: Koch Anti-Snowflake
- Terminal Interface for configuring a Chaotic Iterated Function System:
python ChaoticIFSFractal2.0.py
- Predefined transformations as listed above that can be selected in the terminal interface
- Point Quantity customization
-
Note! Point Quantity based upon calculated point quantity and does not include additional points added withine a threshold of each point so that the data is more dense and displays better ...
-
Here is a screenshot of the Golden Dragon Fractal: (1Mil Points)
-
Here is a screenshot of the Barnsley Fern (bfern) Fractal: (1Mil Points)
-
Here is a screenshot of the Nat Galaxy Fractal: (3Mil Points)
- A lot of the code used here was based on the chaotic fractal code... this is more just an storage than anything else...
- more modular code for rapid testing was the key...
class IFS
: (essentially a static class: collection of functions useful for iterated function systems)
method (static)run(self,vector_func,max_points=50000,stop_func=lambda __,_: False,initial_point=np.array([1,1]),status=True)
- generates a sequence of points and returns the x and y values as a tuple containing np arrays for x and y respectivly ex. (np.array([1]),np.array([2]))
vector_func
: takes a np array of two nums and returns a new arraystop_func
: is passed number of points computed and the most recent point and should return true to stop or false to continemax_points
: is the maximum number of points to computeinitial_point
: is the starting poin defaults to value stated abovestatus
: logs a progress bar indicating how close it is to finishing...
- Preforms an affine transformation on a row vector name x_vect
x_vect
: the input vector as a numpy array ex. x_vect = np.array([0,42])theta
: the angle to rotate the input vector by... NOTE: the stretch array can influence rotation toostretch
: a matrix to stretch the x_vect byshift
: is added to the x_vect to shift it...
- function takes a set of constants as described below and builds a new probabilistic function that selects based on the groups of constants
- returns that new function so it can be used throught other programs (curried function...)
constants
: is essentially a list of functions in the form:
[
[
np.array([[a,b],[c,d]]), #stretch x and y using this matrix
np.array([h,k]), #add this to the vector (shift x and y)
t, #rotate the vector by this angle
p, #probability as a fraction that this function is selected
]
... etc ...
another set of constants
]
- takes input values and plots them as a scatter plot...
points_tuple
: where the first item is a np array corresponding to x values and the seccond item the y valuesx_name
: the name of the x axisy_name
: the name of the y axistitle
: the name title of the graph
- Preforms an affine transformation on a row vector name x_vect BUT does not explicitly calculate rotation... faster
x_vect
: the input vector as a numpy array ex. x_vect = np.array([0,42])stretch
: a matrix to stretch the x_vect byshift
: is added to the x_vect to shift it...
- function takes a set of constants as described below and builds a new probabilistic function that selects based on the groups of constants
- returns that new function so it can be used throught other programs (curried function...)...
- gains a speed boost by not calculating rotation by theta...
constants
: is essentially a list of functions .... seechaoticAffineGenerator
constants argument