Trigonometry for game devs, starting from zero

Just a guy who loves to write code and watch anime.
Introduction
This guide assumes you know nothing. We're starting from the actual beginning. By the end, you'll understand what trig is, why it matters for games, and you'll know the handful of formulas that do 90% of the work.
Take it slow. Read each section, sit with it, move on when it feels okay. It's fine if it takes a few passes. As a high school dropout myself, I sometimes struggle with basic concepts for much longer than others. Take it as inspiration.
What does "trigonometry" even mean?
The word comes from two Greek words: "trigon" (triangle) and "metry" (measuring). So "trigonometry" literally means "triangle measuring."
That's its origin. Ancient mathematicians studied triangles a lot because triangles show up everywhere: in buildings, in star positions, in distances across rivers you can't walk. They figured out rules for how the sides and angles of triangles relate to each other. Those rules became trigonometry.
People usually shorten it to trig. Same word. Less typing.
For game dev, we barely use triangles. We use trig for something else: dealing with angles and directions. But the math came from triangles, which is why the function names (sin, cos, tan) feel weird and unrelated to what we actually do with them. Just know that the names are historical baggage. They don't really describe what these functions do in code.
What's an angle?
An angle is how much something is turned.
Imagine you're standing up, facing forward. If you turn your whole body to face right, you've turned 90 degrees. If you keep going and face backward, you've turned 180 degrees. Keep going, face left, that's 270 degrees. Keep going, you're back to facing forward, 360 degrees. Full circle.
So:
90 degrees = quarter turn
180 degrees = half turn
270 degrees = three quarter turn
360 degrees = full turn, back where you started
That's degrees. You've probably seen the little symbol before: 90°.
Angles don't just describe how much you turned. They describe any direction you can point. "Straight up" is an angle. "Slightly to the right of straight up" is an angle. Every direction has an angle.
What's a direction?
A direction is where something is pointing or going.
In 2D (flat, like on a piece of paper), a direction is a pair of numbers. For example:
(1, 0) means "1 step right, 0 steps up." So it's pointing right.
(0, 1) means "0 steps right, 1 step up." Pointing up.
(-1, 0) means "-1 step right" which means 1 step LEFT. So pointing left.
(0, -1) means "1 step down." Pointing down.
That pair of numbers is called a vector. Don't let the word scare you. A vector is just two numbers that describe "how much horizontal, how much vertical."
Vectors can point anywhere:
(1, 1) points up and to the right at a diagonal.
(3, 4) also points up and to the right, but much further.
Angles vs directions: the same thing, two ways
Here's a question. Say something is pointing up and to the right at exactly 45 degrees. How do you describe that?
As an angle, you'd say: "It's at 45 degrees."
As a direction vector, you'd say: "It's pointing (0.707, 0.707)." (Those weird numbers are just what happens when you split "diagonal" into horizontal and vertical parts.)
Both descriptions mean the exact same thing. You can describe any direction in two ways:
As a single angle. One number. Simple to store, easy to say "turn this 10 more degrees."
As a direction vector. Two numbers (x, y). Easier to use when you want to actually move something.
Games constantly need to switch between these two ways of describing things. An enemy has a rotation angle (for drawing it facing a way), but when it fires a bullet, the bullet needs a direction vector (to move in). Different jobs, different representations.
Trig is the bridge between these two representations. That's honestly what trig is for, in game dev. Angle to vector. Vector to angle. Back and forth.
Now, the rest of this guide is just learning the specific tools for that bridge.
The one picture that makes it all work: the unit circle
Draw a circle. Make its center at the spot (0, 0), which we call the origin. Make its size such that it reaches exactly 1 step in every direction. This is called the "unit circle" because "unit" means "one."
Every point on the edge of this circle can be described by an angle. Start from the rightmost point of the circle (that's angle 0). Walk counter clockwise around the circle. As you walk, the angle grows. Quarter way up, you're at 90 degrees. Top of the circle, wait no, quarter way up is the top (because we start from the right and go counter clockwise). Let me restart that.
Start at the rightmost point. Angle is 0.
Walk counter clockwise to the top: angle is 90°.
Keep walking to the leftmost point: angle is 180°.
Keep walking to the bottom: angle is 270°.
Keep walking back to the start: angle is 360° (same as 0°).
Every point on the circle has an angle. And every point on the circle also has a position: an (x, y) pair.
Here's the huge insight, the one thing that matters in all of trig for games:
There's a simple formula that converts any angle into its matching (x, y) position on the unit circle.
That formula uses two functions called cos and sin. They look like this:
x = cos(angle)
y = sin(angle)
So if you have any angle, those two functions hand you back the x and y position on the unit circle for that angle. That's it. That's their whole job in game dev.
You don't have to understand WHY cos and sin work. You don't need to derive them. You just need to know what they do:
Give
cosan angle, it gives you back the x coordinate on the unit circle.Give
sinan angle, it gives you back the y coordinate on the unit circle.
Don't get confused by θ. It's theta. Just greek letter for angle.
Quick side note: radians vs degrees
Here's an annoying thing. When you use cos and sin in actual code, they usually don't want degrees. They want a different unit called radians.
Radians are just another way to measure angles. Like how you can measure distance in meters or feet. Same thing, different numbers.
Full turn = 360 degrees = 2π radians
Half turn = 180 degrees = π radians
Quarter turn = 90 degrees = π/2 radians
π (pi) is a famous number that equals roughly 3.14. So a full turn in radians is about 6.28. A half turn is about 3.14. Weird, but that's the system code uses.
Why radians instead of degrees? Because the math libraries were built that way for good reasons we don't need to care about. Just accept it.
If you prefer thinking in degrees (most people do at first), your game engine has a helper to convert:
Unity:
Mathf.Deg2Radmultiplies degrees to turn them into radians.Godot:
deg_to_rad(90)returns about 1.57.
Or do it manually:
radians = degrees * π / 180
For the rest of this guide I'll sometimes write angles as degrees (like 90°) for readability, but remember that when you actually type code, you'll need to convert them to radians first.
Using cos and sin to move things in a direction
Finally, the game dev part.
Say your player is facing at 30 degrees (30° from pointing right, rotating counter clockwise). They press the shoot button. You want a bullet to fly out in the direction they're facing.
Here's the code:
angle = 30 degrees (converted to radians)
direction_x = cos(angle)
direction_y = sin(angle)
Now you have a direction vector. It's pointing exactly where the player is facing. To actually move the bullet, you multiply the direction by some speed and add it to the bullet's position every frame:
bullet.x = bullet.x + direction_x * speed
bullet.y = bullet.y + direction_y * speed
That's it. That's a bullet flying in any direction you want. You just used trig.
This is the pattern you'll use all the time. "I have an angle, I need a direction." Answer: (cos, sin).
Making something orbit around a point
Want a moon to orbit a planet?
The moon's position needs to be "at distance r from the planet, at some angle that keeps changing." Here's how:
angle = 0 // start angle
every frame:
angle = angle + 0.01 // slowly increase angle each frame
moon.x = planet.x + cos(angle) * r
moon.y = planet.y + sin(angle) * r
What's happening: (cos, sin) gives you a point on the unit circle (a circle of size 1). Multiplying by r scales the circle up to size r. Adding the planet's position shifts the circle so it's centered on the planet instead of (0, 0). As the angle keeps growing, the moon walks around the circle.






