Chapter 01

Cartesian Coordinate Systems

Number types, 3D space, handedness, and the trigonometry that underpins all of game math.

In this chapter

  1. Number Types
  2. 3D Cartesian Space
  3. Trigonometry
  4. SohCahToa & the Six Functions
  5. Trig Identities
  6. Exercises
1

Number Types

Game math deals with three categories of numbers:

GPUs and game engines work almost exclusively with real numbers approximated as floats (32-bit IEEE 754). Understanding their limits — precision loss, floating-point epsilon — is essential for robust game code.

2

3D Cartesian Space

A 3D Cartesian coordinate system has three mutually perpendicular axes (X, Y, Z). There are 48 possible arrangements of a 3D coordinate system — 24 are right-handed and 24 are left-handed.

Handedness

Two coordinate systems are on the same hand if one can be converted to the other via rotation alone. Systems of opposite handedness require a reflection.

Right-Handed
  • Point your right hand's fingers along +X
  • Curl them toward +Y
  • Your thumb points along +Z
  • Used by: OpenGL, Blender, Maya
Left-Handed
  • Same rule, but with the left hand
  • +Z points the opposite direction
  • Used by: DirectX, Unreal Engine, Unity (historically)
  • Left-hand rule also determines positive rotation direction
Mixing handedness between a DCC tool (e.g. Maya/right-handed) and an engine (e.g. Unreal/left-handed) is a common source of mesh-import bugs. Always know which system you're working in.

3

Trigonometry

Degrees vs Radians

1 rad = (180 / π)° ≈ 57.296° 1° = (π / 180) rad ≈ 0.01745 rad
Games use radians internally because math functions (sin, cos) operate in radians and radians simplify arc-length and angular-velocity calculations. Convert to degrees only for UI display.

Standard Position

Standard position is when the vertex of the angle is at the origin and the initial ray points along the positive X axis. The angle is measured counter-clockwise to the terminal ray. This is the assumed setup for all basic trig definitions.

The Unit Circle

A circle of radius 1 centered at the origin. Any point on it can be written as (cos θ, sin θ) for angle θ. This is why normalization "touches the unit circle" — a unit vector has magnitude 1.


4

SohCahToa & the Six Functions

For a right triangle with angle θ, opposite side opp, adjacent side adj, and hypotenuse hyp:

sin θ = opp / hyp csc θ = 1 / sin θ = hyp / opp cos θ = adj / hyp sec θ = 1 / cos θ = hyp / adj tan θ = opp / adj cot θ = 1 / tan θ = adj / opp tan θ = sin θ / cos θ
The hypotenuse does not need to be a unit length. These ratios hold for any right triangle. The angle must be a right angle — for non-right triangles use the Law of Sines or Cosines.

General Form (Any Radius r)

For a terminal vector of any length r in standard position, with point (x, y) on the terminal ray:

cos θ = x / r sin θ = y / r tan θ = y / x sec θ = r / x csc θ = r / y cot θ = x / y

This generalizes SohCahToa to any angle, including obtuse angles, because it no longer requires a "triangle" — just a point on the terminal ray.


5

Trig Identities

Pythagorean Theorem

For any right triangle with legs a and b and hypotenuse c:

a² + b² = c²

Pythagorean Identities

Derived directly from the unit circle definition — these hold for any angle θ:

sin²θ + cos²θ = 1 1 + tan²θ = sec²θ 1 + cot²θ = csc²θ
The first identity is extremely common in game math. Whenever you know sin θ you can recover cos θ (up to sign) without an expensive trig call: cos θ = √(1 - sin²θ).

Law of Sines

Works for any triangle (not just right triangles). Each angle is opposite its corresponding side:

sin A / a = sin B / b = sin C / c

Law of Cosines

Generalizes the Pythagorean theorem to any triangle:

a² = b² + c² - 2bc·cos A b² = a² + c² - 2ac·cos B c² = a² + b² - 2ab·cos C

When angle A = 90°, cos A = 0 and this reduces to the Pythagorean theorem.


6

Exercises

1. Degree / Radian Conversion

Convert 135° to radians, and convert 5π/6 to degrees.

Multiply degrees by π/180 for radians; multiply radians by 180/π for degrees.
135° → 3π/4 rad.   5π/6 → 150°.

2. Right Triangle Trig

A right triangle has hypotenuse 13 and one leg of length 5. Find sin θ, cos θ, and tan θ for the angle opposite the leg of length 5.

The missing leg is √(13² - 5²) = 12. So: sin θ = 5/13, cos θ = 12/13, tan θ = 5/12.

3. Handedness Check

Unreal Engine uses a left-handed coordinate system where +X is forward, +Y is right, and +Z is up. Unity (default) uses left-handed with +X right, +Y up, +Z forward. If you import a mesh from Maya (right-handed, +Y up), what axis flip is typically needed for Unreal?

Maya's +Z depth becomes Unreal's −X, and handedness differs — the standard fix is to negate the X axis on import (or use the FBX exporter's built-in axis conversion).

Interview Question

Why do game engines store angles as radians rather than degrees internally?

Math library functions (sinf, cosf, atan2f) all operate in radians. Angular velocity in physics is naturally in rad/s. Converting every value to degrees and back would be wasteful — degrees are used only at the UI layer for artist-friendliness.

Interview Question

What is the difference between left-handed and right-handed coordinate systems, and how does it affect cross product direction?

In a right-handed system, X × Y = +Z. In a left-handed system, X × Y = −Z. When the cross product is used to compute normals or camera vectors, the wrong-handedness assumption flips the result, causing inside-out geometry or an inverted camera.
↑ Index Chapter 2 →