# Linear Transformations

Computer Science I · Algebra · https://tryals.app/learn/computer-science-i/linear-transformations

## Preserving Structure

A **linear transformation** is a function $T$ that preserves vector operations: $T(u + v) = T(u) + T(v)$ and $T(cv) = c T(v)$. Transforming a sum equals summing the transforms.

Every linear transformation between finite spaces is a matrix: $T(v) = Av$. To find $A$, evaluate $T$ on the basis vectors; their outputs form the columns.

| Transformation | Behavior | Matrix Example |
| --- | --- | --- |
| **Rotation** | Rotates vectors | Preserves lengths |
| **Projection** | Flattens space | Drops dimensions |

**Common pitfall:** Assuming every function is linear. A translation $T(v) = v + b$ ($b \neq 0$) is **not** linear because it moves the origin. Linearity strictly demands $T(\mathbf{0}) = \mathbf{0}$.

## Composition and Anatomy

Because transformations are matrices, **composing** them means **multiplying** their matrices. Order matters: rotate-then-reflect $\neq$ reflect-then-rotate.

Two structural quantities define a transformation:
* **Kernel:** The set of vectors sent to the zero vector.
* **Image:** The set of all reachable output vectors.

A transformation is **invertible** if and only if its matrix has a nonzero determinant.

Linear transformations drive computing: 3D graphics pipelines chain matrix transformations, and neural network layers apply linear transformations followed by nonlinear activations.

## Practice questions

5 of this lesson's 9 practice questions, with answers. The full set is in the app.

### 1. Order the steps to find the matrix of a linear transformation T on the plane.

**Answer:**

1. Compute T of the first basis vector (1, 0)
2. Make that image the first column
3. Compute T of the second basis vector (0, 1)
4. Make that image the second column

**Why:** Transform each basis vector and place its image as the corresponding column. Because T is linear, these two columns then reproduce T on every vector via matrix multiplication.

Page: https://tryals.app/practice/computer-science-i/linear-transformations/order-the-steps-to-find-the-matrix-of-a-linear-transformation-t-on

### 2. Select every transformation of the plane that is linear.

A. Rotation about the origin
B. Reflection across a line through the origin
C. Mapping (x, y) to (x + 1, y)
D. Scaling by 3
E. Translation by (2, 5)

**Answer:** A. Rotation about the origin; B. Reflection across a line through the origin; D. Scaling by 3

**Why:** Rotations, scalings, and reflections through the origin fix 0 and preserve the operations, so they are linear. Both translation options move the origin, so neither is linear.

Page: https://tryals.app/practice/computer-science-i/linear-transformations/select-every-transformation-of-the-plane-that-is-linear

### 3. Rotation and scaling are linear transformations of the plane; translation is not. Why does moving every point by a fixed offset fail to qualify?

A. Because a linear transformation must fix the origin, and translation moves it.
B. Because translation is only defined for points and not for vectors.
C. Because translation changes the distances between points, which linearity forbids.
D. Because translation cannot be represented by a matrix of any size.

**Answer:** A. Because a linear transformation must fix the origin, and translation moves it.

**Why:** Linearity requires T(cv) = cT(v), and c = 0 forces T(0) = 0, rotation and scaling fix the origin, translation by definition does not. Note translation preserves all distances exactly; its failure is about the origin, not distortion. And the homogeneous-coordinate trick embeds the plane in three dimensions where translation becomes a shear, which *is* linear.

Page: https://tryals.app/practice/computer-science-i/linear-transformations/rotation-and-scaling-are-linear-transformations-of-the-plane

### 4. 3×3 matrices are sufficient for 3D graphics; the 4×4 convention exists only for historical reasons.

**Answer:** False

**Why:** False. A 3×3 matrix always fixes the origin, so it cannot express translation. Homogeneous coordinates add a fourth component precisely so that translation becomes a matrix multiply and the whole transform chain — rotate, scale, translate, project — composes into a single 4×4 product.

Page: https://tryals.app/practice/computer-science-i/linear-transformations/3-3-matrices-are-sufficient-for-3d-graphics-the-4-4-convention

### 5. Rotating a 3D model by 90° about x then 90° about y gives a different orientation than doing them in the reverse order. Which algebraic fact is that?

A. Non-associativity, since grouping the rotations differently changes the result
B. Floating-point error accumulating differently in each order
C. The rotations are not linear transformations, so composition is undefined
D. Non-commutativity of matrix multiplication, since AB ≠ BA

**Answer:** D. Non-commutativity of matrix multiplication, since AB ≠ BA

**Why:** Composition is matrix multiplication and matrices do not commute, so order is physically visible on a book in your hands. It is why 3D rotation order must be specified, XYZ or ZYX are different conventions, and why quaternions are preferred, since interpolating Euler angles hits gimbal lock.

Page: https://tryals.app/practice/computer-science-i/linear-transformations/rotating-a-3d-model-by-90-about-x-then-90-about-y-gives-a-different
