Section 4.5 Similarity transformations
A solid understanding of similarity transformations is quite important, if you want to explore self-similar sets and generate your own examples. Thus, in this section, we're going to take a closer look at similarity transformations in both mathematical notation and code.
Subsection 4.5.1 The basic types of similarity transformations
There are four basic types of similarity transformations, namely:
-
Rotation through the angle \(\theta\) about the point \((x_0,y_0)\text{,}\) which can be represented
mathematically by \(R_{\theta}(x_0,y_0)\) and
in code by
rotate(t,[x0,y0])
.
-
Scaling by the factor \(r\) about the point \((x_0,y_0)\text{,}\) which can be represented
mathematically by \(S_{r}(x_0,y_0)\) and
in code by
scale(r,[x0,y0])
.
-
Translation by the vector \(\langle a,b \rangle\) which can be represented
mathematically by \(T_{\langle a,b \rangle}\) and
in code by
shift([a,b])
.
-
Reflection about a vector perpendicular to \(\langle a,b \rangle\) containing the point \((x_0,y_0)\text{,}\) which can be represented
mathematically by \(F_{\langle a,b \rangle}(x_0,y_0)\) and
in code by
reflect([a,b],[x0,y0])
.
These are “basic” in the sense that
It's easy to see that each type is a similarity,
Any similarity can be expressed as a composition of these types, and
In this subsection, we'll take a look at these four types of similarity transformations. In particular, we'll examine the effect of these transformations on the set show in Figure 4.5.1. For each of these, we'll also examine a Javascript code snippet that might represent the transformation.
Subsubsection 4.5.1.1 Rotation
Rotation rotates a set about a point.
Mathematically, the specific rotation above is \(R_{120^{\circ}}(0,0)\) and in code it's
rotate(120*degree,[0,0])
Note that the [0,0]
is optional, since the rotation will be about the origin by default.
Subsubsection 4.5.1.2 Scaling
Scaling scales a set about a point.
Mathematically, the specific scaling above is \(S_{1/2}(0,0)\) and in code it's
scale(0.5,[0,0])
Note that the [0,0]
is optional, since the scaling will be about the origin by default.
Subsubsection 4.5.1.3 Translation
Translation translates a set by a vector.
Mathematically, the specific translation above is \(T_{\langle -4,-3 \rangle}\) and in code it's
shift([-4,-3])
Subsubsection 4.5.1.4 Reflection
Reflection reflects a set across a line.
Mathematically, the specific reflection above is \(F_{\langle 0,1 \rangle}(0,0)\) and in code it's
reflect([0,1],[0,0])
Note that the [0,0] is optional, since the point is assumed to be the origin by default.
Subsection 4.5.2 Composition
Again, we can express any similarity as a composition of functions chosen from the four basic types of similarity transformations. Consider, as an example, Figure 4.5.6. The larger green set can be reflected, scaled, rotated, and shifted to land on the smaller red set. Hit the "Start" button to begin a step-by-step illustration of that process.
In order, the sequence of basic transformations that lead to the final final transformation is:
The reflection \(F_{\langle 0,1 \rangle}(0,0)\) followed by
the scaling \(S_{1/2}(0,0)\) followed by
the rotation \(R_{-15^{\circ}}(0,0)\) followed by
the translation \(T_{\langle -8,-3 \rangle}\text{.}\)
The final similarity transformation can therefore be expressed as the composition
Note that the application of the functions happens from the inside out, i.e. from left to right.
Subsection 4.5.3 AffineFunction
object
As already metioned, the four types of similarity transformations can be represented on a computer:
rotate(t,[x0,y0])
scale(r,[x0,y0])
shift([a,b])
reflect([a,b],[x0,y0])
These representations refer to concrete Javascript objects that instances of an AffineFunction
class. As objects, they know certain things about themselves. In computer parlance, we would say they have certain properties and methods, including:
is_similarity
: a Boolean indicating whether the function is a similarity or not. This should be true for all of these functions!is_contractive
: a Boolean indicating whether the function is a contraction or not.norm
: the scaling factor.f
: a function that maps[x,y]
pairs to other[x,y]
pairscompose
: a function that accepts anotherAffineFunction
and returns the composition.
That last item compose
is of particular importance, if we want to represent arbitrary similarity transformations.