Skip to main content

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.

Figure 4.5.1. A set in the plane

Subsubsection 4.5.1.1 Rotation

Rotation rotates a set about a point.

Figure 4.5.2. Rotation of a set in the plane

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.

Figure 4.5.3. Scaling of a set in the plane

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.

Figure 4.5.4. Translation of a set in the plane

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.

Figure 4.5.5. Reflection of a set in the plane

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.

Figure 4.5.6. A more complicated similarity

In order, the sequence of basic transformations that lead to the final final transformation is:

  1. The reflection \(F_{\langle 0,1 \rangle}(0,0)\) followed by

  2. the scaling \(S_{1/2}(0,0)\) followed by

  3. the rotation \(R_{-15^{\circ}}(0,0)\) followed by

  4. the translation \(T_{\langle -8,-3 \rangle}\text{.}\)

The final similarity transformation can therefore be expressed as the composition

\begin{equation*} T_{\langle -8,-3 \rangle} \circ R_{-15^{\circ}}(0,0) \circ S_{1/2}(0,0) \circ F_{\langle 0,1 \rangle}(0,0). \end{equation*}

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] pairs

  • compose: a function that accepts another AffineFunction and returns the composition.

That last item compose is of particular importance, if we want to represent arbitrary similarity transformations.