geometry25 min

Transformations

Translations, rotations, and reflections -- moving shapes on the coordinate plane

0/9Not Started

Why This Matters

Every animation you have ever watched, every drag-and-drop interaction, and every game character moving across a screen involves geometric transformations. A transformation takes a shape and produces a new version of it: moved, spun, or flipped. The three fundamental transformations are translation (sliding), rotation (spinning), and reflection (mirroring).

Translations shift every point by the same amount in x and y. Rotations spin every point around a center by the same angle. Reflections flip every point across a line, creating a mirror image. These three operations can be combined to produce any rigid motion -- any movement that preserves the size and shape of the original figure.

Understanding transformations is critical for computer graphics (where every frame involves transforming thousands of objects), robotics (where motors rotate joints through angles), and even machine learning (where data augmentation applies random translations, rotations, and flips to training images). Transformations are where geometry becomes dynamic.

Define Terms

Visual Model

Original ShapeStarting position
TranslationSlide by (dx, dy)
RotationSpin by angle theta
ReflectionMirror across a line
Translated Shape(x+dx, y+dy)
Rotated ShapeUses cos and sin
Reflected ShapeMirror image
CompositionChain transformations
Rigid MotionPreserves size and shape

The full process at a glance. Click Start tour to walk through each step.

The three fundamental transformations -- translation, rotation, and reflection -- can be composed to produce any rigid motion.

Code Example

Code
// Translation: shift a point by (dx, dy)
function translate(x, y, dx, dy) {
  return [x + dx, y + dy];
}
console.log("Translate (3,4) by (2,-1):", translate(3, 4, 2, -1)); // [5, 3]

// Rotation: rotate a point around the origin by angleDeg degrees
function rotate(x, y, angleDeg) {
  const rad = angleDeg * (Math.PI / 180);
  const newX = x * Math.cos(rad) - y * Math.sin(rad);
  const newY = x * Math.sin(rad) + y * Math.cos(rad);
  return [parseFloat(newX.toFixed(4)), parseFloat(newY.toFixed(4))];
}
console.log("Rotate (1,0) by 90 deg:", rotate(1, 0, 90));   // [0, 1]
console.log("Rotate (1,0) by 45 deg:", rotate(1, 0, 45));   // [0.7071, 0.7071]
console.log("Rotate (3,4) by 180 deg:", rotate(3, 4, 180)); // [-3, -4]

// Reflection across an axis
function reflectX(x, y) { return [x, -y]; }  // across x-axis
function reflectY(x, y) { return [-x, y]; }  // across y-axis
function reflectOrigin(x, y) { return [-x, -y]; } // across origin

console.log("Reflect (3,4) across x-axis:", reflectX(3, 4));    // [3, -4]
console.log("Reflect (3,4) across y-axis:", reflectY(3, 4));    // [-3, 4]
console.log("Reflect (3,4) across origin:", reflectOrigin(3, 4)); // [-3, -4]

// Compose: translate then rotate
function translateThenRotate(x, y, dx, dy, angleDeg) {
  const [tx, ty] = translate(x, y, dx, dy);
  return rotate(tx, ty, angleDeg);
}
console.log("Translate (1,0) by (1,0) then rotate 90:",
  translateThenRotate(1, 0, 1, 0, 90)); // [0, 2]

Interactive Experiment

Try these exercises:

  • Translate the point (5, 3) by (-2, 4). Then translate the result by (2, -4). What do you get? Why?
  • Rotate the point (1, 0) by 90, 180, 270, and 360 degrees. Trace the path.
  • Reflect the triangle with vertices (1, 1), (3, 1), (2, 3) across the x-axis. Draw both triangles. Is the reflected triangle a mirror image?
  • Apply a rotation of 45 degrees followed by a rotation of 45 degrees. Is this the same as a single rotation of 90 degrees?
  • Translate (0, 0) by (3, 0), then rotate 90 degrees. Now reverse the order: rotate 90 degrees first, then translate by (3, 0). Are the results the same? Why not?

Quick Quiz

Coding Challenge

Point Transformer

Write a function called `transform` that takes a point [x, y], a transformation type (the string 'translate', 'rotate', or 'reflect'), and parameters. For 'translate', the parameter is [dx, dy]. For 'rotate', the parameter is an angle in degrees (around the origin). For 'reflect', the parameter is a string 'x-axis' or 'y-axis'. Return the transformed point as [newX, newY] with values rounded to 2 decimal places.

Loading editor...

Real-World Usage

Transformations are at the heart of many technologies:

  • Computer graphics and animation: Every frame of a 3D game or movie involves translating, rotating, and scaling thousands of objects. GPU hardware is optimized for these matrix transformations.
  • Image processing: Cropping, rotating, and flipping images are all geometric transformations. Panorama stitching uses transformations to align overlapping photos.
  • Machine learning: Data augmentation applies random translations, rotations, and reflections to training images, making models more robust to variations in input.
  • Robotics: Robot arms are chains of rotations at each joint. Computing the position of the end effector requires composing multiple rotation transformations.
  • CAD and manufacturing: Designers transform parts to assemble them into products. CNC machines translate tool paths from design coordinates to machine coordinates.

Connections