Video summary

What Kind of Math Should Game Developers Know?

Main summary

Key takeaways

Educational

Main ideas / lessons conveyed

  • Game-dev math is less intimidating than it looks: many core techniques used in games reduce to a small set of simple, reusable math ideas.
  • Start with the most practically useful tools and build understanding from there: interpolation, angles/trigonometry, vectors, dot products, matrices, and rotation representations.
  • Use the right representation for the task:
    • Simple formulas for interpolation and motion.
    • Trig for smooth animation and directional movement.
    • Vectors for movement/physics and “alignment” checks.
    • Matrices for linear transformations (and translation via homogeneous coordinates).
    • Choose rotation representations that interpolate well and avoid common pitfalls.

Methodologies / techniques presented (detailed)

1) Linear interpolation (“lerp” / “lurp”)

  • Core formula:
    • A + (B - A) * T
  • What it means:
    • Interpolates between values A and B as parameter T changes.
    • A and B can be virtually anything, not just numbers.
  • Practical uses in games:
    • Fade something in: interpolate opacity (or a visibility value).
    • Move an object from one screen position to another.
    • Interpolate scale (shrink/grow over time).
    • Interpolate UI/game stats:
      • Example: health bar amount.
      • Interpolate color as health drops.
  • Enhancement: shaping functions (nonlinear T)
    • Straight interpolation may not feel smooth/desired.
    • Apply shaping to T (e.g., smoothstep) to make motion/transition ease in/out.
    • Optionally use more exotic shaping curves for different feel.
  • Advanced: interpolate in different spaces
    • Instead of interpolating RGB directly, interpolate in alternative color spaces:
      • Example: convert to HSV for different gradient behavior.
      • Example: convert to Lab for (claimed) more aesthetically pleasing gradients.

2) Angles and why radians matter (especially for trig)

  • Angles describe the “opening” between two rays/lines.
  • Degrees in everyday life: typically 0–360.
  • Math preference: radians
    • Definition using the unit circle (radius = 1):
      • Walking arc length equal to radius (1 unit) corresponds to 1 radian.
  • Why radians are useful
    • They make trig relationships cleaner and more directly compatible with calculus/graphs.

Trigonometric definitions from the unit circle

For a point at angle θ:

  • sin(θ) = vertical component
  • cos(θ) = horizontal component
  • tan(θ) = vertical/horizontal ratio (undefined where the denominator is 0)

Key trig insight for game dev needs

  • With just these relationships, much of what games need can be computed.

3) Trigonometry for animation

  • Use trig functions to modulate properties over time.
  • Examples from the video:
    • Pulsating: scale modulation using sin(time).
    • Hovering: height modulation using sin(time) (with possible offsets).
    • Spirals / orbiting movement:
      • Compute positions using circle parametric forms:
        • X via cosine
        • Y via sine
      • Conceptually, this uses coordinates on the circle.

4) Vectors: position vs direction, and operations for movement/physics

Vector types and meanings

  • Position vector: a point in space (e.g., (x, y)).
  • Velocity/force vector: a direction + magnitude (often treated as a generic “vector” in code).

Vector operations used in games

  • Add position + vector → new position
    • Used for updating where something is.
  • Add/subtract vectors → new vector
    • Useful for accumulating forces, combining velocities, etc.
  • Subtract position - position → displacement vector
    • Gives direction and distance between two points.
  • Multiply vector by scalar → scale vector
    • Used for scaling velocity by time or tuning magnitudes.

Movement and “Euler integration” (simple physics update)

Given:

  • Current position P
  • Velocity vector v
  • Acceleration vector a
  • Delta time Δt

Update idea:

  • New position ≈ P + (v * Δt)
  • Update velocity ≈ v + (a * Δt)

The video frames this as Euler integration:

  • “imperfect but super simple”
  • and suggests looking up more stable integration methods if needed.

5) Dot product for alignment tests (e.g., field-of-view / “in front”)

Setup

  • Use unit vectors (length 1).
  • Define two vectors:
    • a = turret forward direction
    • b = direction from turret to the target

Core result

  • The dot product gives cos(θ) where θ is the angle between the vectors:
    • dot(a, b) = cos(θ) (for unit vectors)

How to interpret the sign/magnitude

  • cos(θ) → 1: vectors aligned (same direction)
  • cos(θ) → 0: perpendicular (90°)
  • cos(θ) → -1: opposite direction (180°)

Field-of-view visibility method

  • Narrow turret FOV to 60°
  • Compare using half-angle:
    • Half-angle = 30°
    • Compute cutoff: cos(30°) ≈ 0.866
  • Steps (conceptual):
    • Normalize vector from turret to player (b)
    • Compute dot(turretForward, b)
    • If dot ≥ cutoff, player is within the FOV; otherwise not visible.

6) Matrices as linear transformations (and translation via homogeneous coordinates)

Core framing

  • Matrices are best understood as linear transformations applied to vectors.

2D example approach

  • Choose a basis/grid (x and y basis vectors).
  • A matrix “replaces”/maps those basis vectors to new directions/lengths.
  • Example described:
    • Scaling the basis vectors (e.g., stretch x by 3 and y by 2) via matrix columns.
  • Rotation matrix example:
    • Constructing basis vectors aligned with rotated axes yields a 90° rotation matrix.
  • Shear concept:
    • When axes aren’t orthogonal (not 90°), the transformation behaves like shear.

Translation requires a trick: homogeneous coordinates

  • Add a third coordinate (w/z-like constant) so that translation can be represented within matrix multiplication.
  • Using homogeneous coordinates allows:
    • rotation + scale + translation all in one matrix multiply.

7) Representing rotations: matrices vs Euler angles vs quaternions

A) Why matrices are problematic for rotation interpolation

  • Rotation matrices are:
    • Data-heavy in 3D (many values).
  • Interpolation between matrices can produce problematic results (“freaks out” / not ideal).

B) Euler angles (yaw/pitch/roll)

  • Definition: rotations around axes in a fixed order.
  • Often used in UI because they’re:
    • compact (3 components)
    • intuitive (airplane-like rotations)
  • Problems:
    • Hard to interpolate smoothly (naive interpolation gives poor results).
    • Gimbal lock:
      • happens when two rotation axes align, losing a degree of freedom.

C) Quaternions (the preferred interpolatable representation)

  • Claimed benefits:
    • Uses 4 values (compact-ish relative to 3D rotation matrices).
    • Avoids gimbal lock when not derived from Euler angles “naively.”
    • Interpolates smoothly using Slerp (spherical linear interpolation).
  • Interpolation contrast:
    • The video compares matrix/Euler interpolation problems vs
    • quaternion-based slerp giving more expected motion.
  • What quaternions are (high-level):
    • Complex rotational math objects:
      • “scalar + three imaginary components”
    • They’re difficult to visualize/understand directly, but they work well.

8) Intuition bridge: complex numbers to explain rotation-like behavior (why quaternions “feel related”)

  • Complex numbers basics
    • Imaginary unit: i, with i^2 = -1.
  • Geometric interpretation
    • Multiplying by i corresponds to a 90° rotation in the 2D real/imag plane.
  • Unit circle connection
    • A point on the unit circle corresponds to cos(θ) + i*sin(θ).
  • Multiplication matches rotation behavior
    • The video claims the algebra aligns with matrix rotation results, providing a conceptual bridge for why rotations work like this.
  • Takeaway
    • Math may feel scary at first, but concepts can be learned step-by-step.

Resources / sources mentioned

  • Mentions the presenter’s course: packaged math course for game developers (details not provided beyond existence).
  • Recommends specific creators/content (not fully identified in the subtitles):
    • three brown one blue
    • Freya
    • Homer
    • George Rodriguez

Original video