Number types, 3D space, handedness, and the trigonometry that underpins all of game math.
Game math deals with three categories of numbers:
...-3, -2, -1, 0, 1, 2, 3...2/3, 5.6, 15/16A 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.
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.
sin, cos) operate in radians and radians simplify arc-length and angular-velocity calculations. Convert to degrees only for UI display.
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.
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.
For a right triangle with angle θ, opposite side opp, adjacent side adj, and hypotenuse hyp:
For a terminal vector of any length r in standard position, with point (x, y) on the terminal ray:
This generalizes SohCahToa to any angle, including obtuse angles, because it no longer requires a "triangle" — just a point on the terminal ray.
For any right triangle with legs a and b and hypotenuse c:
Derived directly from the unit circle definition — these hold for any angle θ:
sin θ you can recover cos θ (up to sign) without an expensive trig call: cos θ = √(1 - sin²θ).
Works for any triangle (not just right triangles). Each angle is opposite its corresponding side:
Generalizes the Pythagorean theorem to any triangle:
When angle A = 90°, cos A = 0 and this reduces to the Pythagorean theorem.
Convert 135° to radians, and convert 5π/6 to degrees.
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.
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?
Why do game engines store angles as radians rather than degrees internally?
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.
What is the difference between left-handed and right-handed coordinate systems, and how does it affect cross product direction?