# Why is sin = Y and cosine = X?

I'm new to game development in some phases and I want to understand everything I do (at least most of it) so I've started developing in MonoGames framework (XNA) and I saw a function like this.

rocket.angle = System.Math.Atan2(rocket.rocketdirection.X , -rocket.rocketdirection.Y);


I didn't understand this function (I was following a tutorial) and dove deeper into understanding sin, cos and tan. Now I have some understanding over it but one thing is unclear to me.

This was shown to me in a way to show how you calculate sin, cos and tan and I didn't understand it.

• Why is the circle represented as 1,1 and -1,-1?
• And why is Y = sin and X = cos?
• And through this tan = cos/sin?

Can somebody explain this picture in a better way, in a way that is relatively easy to understand?

• This is not a game development question. You should ask this on math.stackexchange.com – Stephane Hockenhull Feb 12 '17 at 20:41
• Is there a way to transfer this question ? – Bojje Feb 12 '17 at 21:13
• @StephaneHockenhull I believe that math people would get too much carried away and make the answer to this overly complicated. I think here it's better to have an answer from a game dev perspective. – Alexandre Vaillancourt Feb 13 '17 at 2:14
• The short answer is "convention" ;) Unless otherwise specified, we generally agree to measure angles in the xy plane by going counter-clockwise from the positive x axis. If we had a different convention, say we wanted to measure clockwise from the positive y axis (like a clock) then we'd say x = sin(angle) and y = cos(theta) (and in fact, sometimes in gamedev that's exactly what we'll do, if we need an angle to start from a different axis for a particular scenario) – DMGregory Feb 13 '17 at 4:39
• You use atan2 incorrectly, the parameters are in y, x order. – Bálint Feb 13 '17 at 8:52

I will try to answer briefly.

1. Why is the circle represented as 1,1 and -1,1?

This thing is usually called Unit Circle, because its radius equals to 1. How it is relative to trigonometry you're trying to solve? Let's see.

1. Why is Y = sin and X = cos?

Well, let's look at the picture I've made five minutes ago (sorry, it's not the best my work).

You can mention at the picture the point B with coordinates X, Y and builded triangle ABC. First of all, this is the right triangle. So we can continue our mind work.

The definition of sine states: sin(φ) is the ratio of the length of the opposited to angle φ side and the length of the hypotenuse. For our example sin(BAC) = BC/AB because BC is opposited to angle BAC and AB is simply hypotenuse.

As you can see,

a) BC equals to y;

b) AB equals to 1 (because it is a Unit Circle and AB is a radius).

c) BC/AB = y/1 = y, so sin(BAC) = y.

The same logic easilly can be applied for cos but this time we will talk not about opposite side to angle, but adjacent side. In other words, cos(φ) is a ratio of the length of the adjacent to angle φ side to the length of the hypotenuse.

In the same way we see that cos(BAC) = AC/AB = x/1 = x.

1. How we can see that tan = sin/cos?

Well, it is the easiest part. The tan(φ) of the angle φ is the ratio of the length of the opposite to the angle φ side and the length of the adjacent to the angle φ side.

For our example tan(BAC) = BC/AC = y/x. I hope this is a clear starting explanation.

• Your explanation hit it on the nail; however, the mixed usage of x as the angle and as the X position is confusing. I'd recommend you use theta or phi (respectively θ, φ). This prevents confusion between angular coordinates and euclidean coordinates. – KareemElashmawy Feb 13 '17 at 23:12
• @KareemElashmawy you're right, thank you very much! – Ashkariel Eter Feb 14 '17 at 8:31

When you ask Why is sin = Y and cosine = X? I read your question as Why is the function that gives me the Y axis called "sin" and why is the function that gives me the X axis called "cosine"?, so I'll start by answering that...

At its heart, it is a naming convention. If you have a unit circle with the common trigonometric functions...

... you'll see that all the function that go to the Y axis are "co" something (cosine, cosecant, cotangent).

Looking at the same unit circle you will find that cos(θ) and sin(θ) will give the X and Y coordinates respectively for the point on the unit circle that is at θ angle from the X axis.

These functions where historically defined in terms of circles, in fact they come from the Sanskrit Jyā (sine) and koti-jyā (cosine), which where the names of those functions used by Indian mathematicians circa 500 AD. They were later translated to Latin, and from there to English. But, you don't care about that, you care about making games (or solving math problems, or whatever)!

Why is the circle represented as 1,1 and -1,-1?

It is a unit circle, that means that it is a circle with radius = 1, and thus it reaches down to -1 and up to 1. The reason why they use radius = 1 is because this makes it easy to scale the functions to a different radius.

And why is Y = sin and X = cos?

You may wonder why they aren't the other way around. Well, they had to be one way or the other, and whichever it was you would be asking the same... so the answer is: for historic reasons.

And through this tan = cos/sin?

No, this is WRONG. Actually tan(x) = sin(x) / cos(x).

I hope to demostrate this in an intuitive manner. To start let's take the 0BC triangle from the image above:

I have added cos in the triangle for ease of reference (sec was removed because we don't need it).

We can see this triangle is a Right Triangle, and also that it contains another smaller Right Triangle. Furthermore, both triangles have one angle with the value θ, therfore they are Similar Triangles. Which means that we can map one triangle over the other by only scaling, rotating and translating (moving). This can be seen in the following animation.

In the animation we used rotation and scaling, neither of these transformations changes the angles of the triangles.

Pay attention to what segment was mapped over what segment during the transformation. In particular:

• The magenta segment (tan(θ)) was mapped over the black segment (1).
• The olive segment (sin(θ)) was mapped over the green segment (cos(θ))

Now, let's see what does that mean.

First tan(θ) went to 1. Meaning that

scaling_factor * tan(θ) = 1
=>
scaling_factor = 1 / tan(θ)


So the scaling factor is 1 / tan(θ).

Second, sin(θ) went to cos(θ). Meaning that:

scaling_factor * sin(θ) = cos(θ)


By replacing the scaling factor we have:

1 / tan(θ) * sin(θ) = cos(θ)
=>
sin(θ) / tan(θ) = cos(θ)
=>
sin(θ) = cos(θ) * tan(θ)
=>
sin(θ) / cos(θ) = tan(θ)


And that's what we were set to demostrate.