Constructing Fractals and Fractal measures

An iterated function system is a set of $M$ affine contraction maps, or similarities.

Similarities

Each similarity is of the form:

\[s_m(x)=r_mA_mx + \delta_m,\quad x\in\mathbb{R}^n,\]

where $r_m\in(0,1)$ is the contraction factor, $A_m\in\R^{n\times n}$ is a rotation matrix, and $\delta\in\R^{n}$ is a translation vector.

IFSintegrals.SimilarityType
struct Similarity{V<:Union{Real,AbstractVector}, M<:Union{Real,AbstractMatrix}}
    r::Float64 # contraction
    δ::V # translation
    A::M # rotation/reflection
    rA::M # contraction * rotation/reflection
end

Constructs a similarity map. The third input (rotation matrix) is optional, and the fourth is created automatically.

Can be treated as a function, for example

    julia> s = Similarity(1/2,0) # creates contraction s(x)=x/2+0
    julia> s(π)
    1.5707963267948966
source

InvariantMeasure

The iterated function system may be interpreted as a set of these maps, $\{s_m\}_{m=1}^M$. The attractor $\Gamma$ is the unique non-empty compact set which satisfies

\[\Gamma = S(\Gamma):=\bigcup_{m=1}^M s_m(\Gamma).\]

We can construct the map $S$ defined above as follows.

using IFSintegrals
s₁ = Similarity(1/3,2/3)
s₂ = Similarity(1/3,2/3)
S = [s₁,s₂]
x = rand()
S(x) # applies the map S to the point x
2-element Vector{Float64}:
 0.8218035731482836
 0.8218035731482836

This is the IFS for the Cantor Set, and this can be converted into an InvariantMeasure with the command

 Γ = InvariantMeasure(S)
InvariantMeasure{Float64, Float64}(Similarity{Float64, Float64}[Similarity{Float64, Float64}(0.3333333333333333, 0.6666666666666666, 1.0, 0.3333333333333333), Similarity{Float64, Float64}(0.3333333333333333, 0.6666666666666666, 1.0, 0.3333333333333333)], 1, 0.6309297535714574, true, true, 0.9999999999999999, 0.0, 1.0, [0.5, 0.5], true, Bool[1 0; 0 1], IFSintegrals.AutomorphicMap{Float64, Float64}[IFSintegrals.AutomorphicMap{Float64, Float64}(1.0, 0.0)])

The outer constructor for InvariantMeasure constructs other properties, such as diameter and Hausdorff dimension, which describe this fractal measure.

The full type is described below:

IFSintegrals.InvariantMeasureType
struct InvariantMeasure{V,M} <: SelfSimilarFractal{V,M}
    IFS::Vector{Similarity{V,M}}
    spatial_dimension::Int64
    Hausdorff_dimension::Float64
    homogeneous::Bool
    Hausdorff_weights::Bool
    barycentre::V
    diameter::Float64
    measure::Float64
    weights::Vector{Float64}
    disjoint::Bool
    connectedness::Matrix{Bool}
    symmetry_group::Vector{AutomorphicMap{V,M}}
end

Representation of a invariant measure, whose support is an iterated function system (IFS). Constructor requires only an IFS, which is of type Array{Similarity}. All other essential properties can be deduced from this, including barycentre, diameter and dimension, which are approximated numerically.

Has the outer constructor, which only requires IFS (a vector of Similarity) as an input.

InvariantMeasure(sims::Vector{Similarity}; measure::Real=1.0) = 
    InvariantMeasure(sims, get_diameter(sims); measure=measure)

Fields

  • IFS: The iterated function system, a vector of Similarity, describing the fractal
  • spatial_dimension: The integer dimension of the smallest open set containing the fractal
  • Hausdorff_dimension: The Hausdorff dimenson of the fractal
  • homogeneous: A flag, true if all the contractions are of the same size
  • Hausdorff_weights: A flag, true if this is a Hausdorff measure
  • barycentre: The barycentre of the measure
  • diameter: The diemater of the fractal support
  • measure: The measure of the whole fractal, usually set to one
  • weights: The probability weights describing the invariant measure
  • disjoint: Flag for if the fractal support is disjoint
  • connectedness: Matrix describing which subcomponents are connected
  • symmetry_group: Vector of AutomorphicMap, describing symmetries of the measure
source

Now let's try a more complicated example. The second (translation) argument of Similarity can also be a vector. For example:

ρ = 0.41
IFS = [
    Similarity(ρ,[0,0])
    Similarity(ρ,[1-ρ,0])
    Similarity(ρ,[(1-ρ)/2,sqrt(3)*(1-ρ)/2])
    Similarity(ρ,[(1-ρ)/2,(1-ρ)/(2*sqrt(3))])
    ]
 Γ = InvariantMeasure(IFS)

We can plot an approximation attractors in $\mathbb{R}$ or $\mathbb{R}^2$, as follows:

using Plots
plot(Γ,color = "black", markersize=0.75,label="My fractal")
Example block output

Preset fractals

Several preset fractals are available. These may be called with:

CantorSet()
CantorDust()
Sierpinski() # triangle/gasket
KochCurve() # Koch curve
KochFlake() # Koch snowflake
Vicsek() # Vicsek fractal
SquareFlake() # Minkowski snowflake
Carpet() # Sierpinski carpet
Dragon() # Heighway Dragon

Some of these presets have optional arguments, for example CantorSet and CantorDust have the default contraction=1/3, but this can be set to any value in $(0,1/2]$.

Manipulating fractals

Fractals can be translated, stretched and rotated very easily, using simple arithmetic syntax. For example,

Γ = Sierpinski()
plot(Γ, markersize=0.75,
    label="Sierpinski Triangle (default)")

Γ_shift = 1.5*Γ + [-2,0.5]
plot!(Γ_shift, markersize=0.75,
    label="Sierpinski Triangle (translated and stretched)",aspect_ratio=1.0)
Example block output

SubInvariantMeasure

Consider an IFS with $M\in\mathbb{N}$ components. For a vector

\[\mathbf{m}=[m_1,\ldots,m_N]\in\{1,\ldots,M\}^N,\]

it is standard to denote a sub-component of the fractal by

\[\Gamma_{\mathbf{m}} := s_{m_1}\circ\ldots \circ s_{m_N}(\Gamma)\]

The following type also describes a measure whose support is a sub-component, in the above sense.

IFSintegrals.SubInvariantMeasureType
struct SubInvariantMeasure{V,M} <: SelfSimilarFractal{V,M}
    parent_measure::InvariantMeasure
    IFS::Vector{Similarity{V,M}} # could be removed ?
    index::Vector{Int64}
    barycentre::V
    diameter::Float64
    measure::Float64
end

Represents a fractal measure which has been derived from an InvariantMeasure.

Fields

  • parentmeasure: This measure is supported on a subet of the support of parentmeasure
  • IFS: The vector of similarities describing the fractal support of this measure
  • index: The vector index corresponding to the contractions applied to parent_measure
  • barycentre: The barycentre of this measure
  • diameter: The diameter of the fractal support
  • measure: The measure of the support
source

Using standard vector index syntax, a SubInvariantMeasure can be easily constructed:

Γ = Sierpinski()
m = [1,3,2] # vector index
Γₘ = Γ[m] # construct SubInvariantMeasure

plot(Γ, markersize=0.75,
    label="Sierpinski Triangle (default)")
plot!(Γₘ, markersize=0.75,
    label="Subcomponent",aspect_ratio=1.0)
Example block output