Linear Transformation

A linear transformation is a mathematical operation that maps vectors to vectors while preserving the operations of vector addition and scalar multiplication. This concept is fundamental in linear algebra and is widely used in various fields such as computer graphics, data science, and physics. Linear transformations are typically represented using matrices, which describe how the transformation affects standard basis vectors.

Overview

A linear transformation in Euclidean space involves expressing new coordinates as linear combinations of old coordinates. This transformation is represented using square matrix multiplications. Linear transformations generalize operations such as rotation and scaling but do not include translation, meaning the origin remains fixed. The properties of linear transformations include:

  • Additivity: For vectors u and v, T(u + v) = T(u) + T(v).
  • Homogeneity: For a scalar s and vector v, T(s v) = sT(v).
  • Retention of Parallelism: Parallel lines remain parallel after transformation.
  • Zero Point Invariance: The origin (0, 0) is always mapped to itself.
  • Symmetry: Transformations are symmetrical with respect to both the x and y axes.

Visualizing Linear Transformations

Linear transformations can be visualized by observing their effects on geometric shapes and vectors. For example, a rotation transformation is a common linear transformation that preserves vector sums and scalar multiples.

Example: Rotation

A counterclockwise rotation about the origin is a linear transformation. This can be visualized in the following figure:

Applying a linear transformation (rotation by 60°) to points making up a triangle. The result is a rotated triangle (on the left). Figure 4.29

Representing Linear Transformations with Matrices

Linear transformations are represented using matrices, which describe how transformations affect standard basis vectors. In 2D space, knowing how a transformation affects the standard basis vectors e1 and e2 allows computation of T(v) for any vector v.

Matrix Multiplication

Applying a linear transformation to a vector is equivalent to multiplying a matrix by a vector. This operation results in a new vector and is a special case of matrix multiplication. The composition of multiple linear transformations can be achieved through matrix multiplication.

Each entry of a product matrix is a dot product of a row of the first matrix with a column of the second matrix. Figure 5.2

Applications in 3D Animation

In 3D animation, linear transformations manipulate models over time. By applying different transformations specified by matrices, a model can appear to move or change. This is achieved by redrawing a transformed version of the original model in each frame, creating the illusion of motion.

Example: Rotation in 3D

Consider a rotation counterclockwise by 90° about the z-axis. This transformation affects the standard basis vectors e1 = (1, 0, 0), e2 = (0, 1, 0), and e3 = (0, 0, 1), resulting in (0, 1, 0), (−1, 0, 0), and (0, 0, 1), respectively.

Two machines that do the same linear transformation. Geometric reasoning powers the machine on the top, while nine numbers power the one on the bottom. Figure 5.1

Importance of Linear Transformations

Linear transformations are crucial in various fields due to their ability to preserve vector sums and scalar multiples, which means they also preserve linear combinations. This property is particularly useful in applications like 3D modeling, where maintaining the structure of models is essential. Additionally, linear transformations are foundational in understanding more complex transformations and operations in mathematics and applied sciences.

Computing Linear Transformations

To compute the matrix for a linear transformation, symbolic computation tools such as SymPy can be used. The following code snippet demonstrates how to determine the matrix elements for a linear transformation using two points before and after the transformation:

from sympy import *

a11, a12, a21, a22 = symbols('a11 a12 a21 a22')    #1
x1, y1, x2, y2 = symbols('x1 y1 x2 y2')            #2
xt1, yt1, xt2, yt2 = symbols('xt1 yt1 xt2 yt2')    #3

solution = solve([
    a11 * x1 + a12 * y1 - xt1,                     #4
    a21 * x1 + a22 * y1 - yt1,
    a11 * x2 + a12 * y2 - xt2,
    a21 * x2 + a22 * y2 - yt2
], (a11, a12, a21, a22))

print(solution)
#1 Four coefficients for the linear transformation
#2 Two points before the transformation
#3 Two points after the transformation
#4 This line is the “xt = a11xi + a12yi” formula applied to point (x1, y1).

This code uses symbolic variables to represent the coefficients of the transformation matrix and the coordinates of two points before and after the transformation. By solving the system of equations, one can determine the matrix elements that define the linear transformation.

| Book Title | Usage of Linear Transformation | Technical Depth | Connections to Other Concepts | Examples Used | Practical Application |
|------------|-------------------------------|-----------------|------------------------------|---------------|-----------------------|
| [Exploring Math for Programmers and Data Scientists](https://www.manning.com/books/exploring-math-for-programmers-and-data-scientists) | Discusses linear transformations as mappings that preserve vector addition and scalar multiplication, crucial in fields like computer graphics and physics. [more](https://livebook.manning.com/book/exploring-math-for-programmers-and-data-scientists/chapter-5/11) | Explains matrix representation and multiplication, and how transformations affect standard basis vectors. [more](https://livebook.manning.com/book/exploring-math-for-programmers-and-data-scientists/chapter-5/12) | Connects to concepts like vector spaces, matrix multiplication, and 3D animation. [more](https://livebook.manning.com/book/exploring-math-for-programmers-and-data-scientists/chapter-5/86) | Uses examples like rotation transformations and visualizations of geometric shapes. [more](https://livebook.manning.com/book/exploring-math-for-programmers-and-data-scientists/chapter-4/160) | Highlights applications in 3D animation and modeling, emphasizing the preservation of vector structure. [more](https://livebook.manning.com/book/exploring-math-for-programmers-and-data-scientists/chapter-4/172) |
| [Geometry for Programmers](https://www.manning.com/books/geometry-for-programmers) | Describes linear transformations in Euclidean space as operations using square matrix multiplications, excluding translations. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-4/72) | Details the computation of transformation matrices using symbolic computation tools like SymPy. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-4/102) | Discusses properties like retention of parallelism and symmetry, and their implications in geometry. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-4/72) | Provides visual examples of transformations, highlighting symmetry and invariance of the origin. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-4/92) | Focuses on the mathematical foundation and computation of transformations, useful for programming geometric operations. [more](https://livebook.manning.com/book/geometry-for-programmers/chapter-4/102) |

FAQ (Frequently asked questions)

Can the origin (0, 0) be transformed into another point using a linear transformation?

Are linear transformations computationally cost-effective on SDFs?