A Little help with trigonometry

Started by
7 comments, last by nilkn 18 years, 3 months ago
Okay, I've used Sin, Cos, Tan and their recipricals right through high school mathematics, asked some questions on gamedev on rotation and got an answer containing at least one of them, I know Sin = Y/R and cos = X/R and so on and so forth, and i know they return the ratios of the hypotenuse and adjacent side and what not, but i have know idea how they work, why do they do the things they do, why does using sin and cos allow me to rotate a line ? Could any one explain to me how to apply these things properly, they sound pretty important and i would like to know how to use these ratio's to solve my problems but i have know idea what they do or when to use them. so if any one could show me the ropes on this stuff it would be much appreciated. Thanks a million.
Advertisement
Im assuming you have a line connecting 2 points... A & B

Now the thing that sin and cosine help out with is the fact that when you rotate
a point about the origin (think of a circles circumfrence) it always stays the same distance from the center point. By using this we can work out what the Adjacent & Opp sides are, now Look at this picture

[Source]              P          //|      //    |   //       |// R        |____________|


Now if R is the angle we used to find the rotation then X Axis is the Adjacent side and the Y Axis is the Opposing side.

So say we want to find a Point F which lies on a Circle of 10units, and it is at 33 Degrees, we simple plug it into this thing and find

Adjacent = Radius * Cos(33)
Opposing = Radius * Sin(33)
Thus
X = Radius * Cos(33)
Y = Radius * Sin(33)

And by replacing 33 with Angle we can draw a circle using
Radius = 100
for angle = 0 to 360 do
{
X = Radius * Cos(Angle)
Y = Radius * Sin(Angle)
PutPixel(x,y);
}

Now this is the 1 way it goes, so if we know a unit is Facing 66 Degrees we can work out its Facing Normal by using the top
-----------------------
Normal.X = Cos(FacingAngle)
Normal.Y = Sin(FacingAngle)

And now if the unit moved 5m then we can find its new location by
Speed = 5m
Position = Position + Normal * Speed


--------------------------
Thats the easy part, the difficult part is going backwards ie, from the normal to the angle.

And anyways its beyond the scope of this
----------------------------

http://djoubert.co.uk
Visualise this your standing at a point and your looking in a direction so increasing the Z,X will not move you proporly so you define the speed you want to move in , thats the radius of the cirle now you wanna know the increase that should happen in the x , z so you draw line from the point your standing in to the radius with angle 0 thats the z then draw a cord to connect the two radiis thats the x now you have a right angle triangle so x is the oppiste and z is the adjacent if you rembemer from your math lessons

SOH Sin(Angle) = Oppiste / Hypotense
CAH Cos(Angle) = Adjacent / Hypotense

the angle is the angle we wanna move with and the hypotnese is the speed we moved with so by some Algebra we could do this

oppiste = Sin(Angle) * Hypotense
Adjacent = Cos(Angle) * Hypotense

Which Simplifies to
X = Sin(Angle) * Hypotense
Z = Cos(Angle) * Hypotense

So Now We have the two coord we can compute the point on the circumfrunce we want to move to (X,Z) , any 2 axis can be seen as 2d so you can do this with x,z y,x y,z how ever you like and with some modification this can be used to compute Rotation , Intersection etc.. if your intersted in how is it actually computed you just get the sin,cos of one number and by Cross-Muliplication you can find any other number.
Good Luck :D
What is the difference between Jurassic Park and Microsoft? One is an over-rated high tech theme park based on prehistoric information and populated mostly by dinosaurs, the other is a Steven Spielberg movie.
To add one short answer:
I am quite sure when you heard about sin, cos and tan at school you saw the unit circle and how sin and cos can be shown in that circle.
Every point on the circle has the same distance to the center. So by ROTATING one point around the circle, you can receive all other points on the circle.
Lets say you have the point (x,y) = (1,0), wich means it is that point on the x-axis, and you want to rotate it by some degree counter clockwise. What coordinates would it have?
Add this to what you know about the unit circle, sin and cos and you got it.

Same does apply when you "rotate the viewpoint", which just means you just rotate all points around the view point ;)
Thanks for the responses guys, but i think you're misinterpreting my question, i don't want to know how Sin and Cos work in relation to rotation only, but how all trigonometric ratios work in all situations, i need someone to explain what Sin Cos and tan do when I use them, What excactly does my calculator do when i type in Sin45 and topics such as that.
Hmm a tough question. Uhhm, your calculator comes up with an approximation of the ratio by doing something fancy with fractions I believe.

Click Here AND Click Here

Now have a look there at the graphics and you might begin to understand what AP was talking about with the unit circle.

Now, when you see Sin45, have a look at the second link I gave you - Sin45 = 1/sqrt(2) = .707 do you see where 45 is around about on the graph? The y-coordinate of that is at about .707

Another example, by looking at that same graph can you see what Sin90 will be? Sin180? Sin270?

Hrrm this probably isn't very clear and might seem unrelated to your question but I hope it led you into a little more of an understanding. You just have to fiddle around yourself and you will start to comprehend I guess.

Merry Christmas, take it easy
-Jemburula
What we do in life... Echoes in eternity
Sin/Tan/Cos are all related and are all infact RATIOS
------------------------------------------------------
When That idiot founded the pythagoras theorem (a^2 = b^2 + c^2) which works on 90 degree angles they took this further and built a table of ratios saying.

Opp/Hyp = Sin(Theta)

Where Theta is the angle in a triangle, then they went and did this for all angles (with a bit of logic).

Now since we know the ratio(sin look up table) and the Angle Theta we can work out the Oppor Hyp if we know either 2, so the connection is

Sin(Theta) = Opp/Hyp

So now we know that Theta is 45 Degrees, look it up (or use the calc) and you are left with
(numbers are fictional)
12 = Opp/8

And so in effect SIN/COS/TAN are all derived from the Pythagorean Theorem

Now Cos is essentially the same as sin in that sin(x) = cos(x-90)

And to look at some graphs of the COS/SIN table look at
http://www.mathsrevision.net/gcse/sin_cos_tan.php
----------------------------

http://djoubert.co.uk
ok this is short and simple if you understand the pythagoran theorm you will understand this someone brought a right angle triangle and kept changing the lenght of each side they found that they have a ratio between them so they mesured one right angle triangles sides and angles and began recording them into a table they called the angle they were trying to get Theta and the side oppisite to it well OPPISITE and the side oppisite to the Right angle hypotense and the side thats left adjacent , they called the ratio between the oppisite and the Hypotense Sine and the ratio between the Adjacent and the hypotense Cosine and the ratio between the oppisite and the adjacent Tan and they started using the tables of the ratios since then.
Hope This Helps

EDIT:
here is a guess if i made a calc i would do it like this
i would get a right angle triangle with an angle thats lets say 40 then get the mesure of the oppisite side and the hypotense then divide them to get the ratio and that would be sin 40(0.642) then when you wanna get the sin of another number i would do a cross multiplication like this (0.642 * Num) / 40
that would get the sin of the other number.
What is the difference between Jurassic Park and Microsoft? One is an over-rated high tech theme park based on prehistoric information and populated mostly by dinosaurs, the other is a Steven Spielberg movie.
The standard formula for rotating a vector about the origin may be easily derived with complex numbers.

We may write a complex number with the Euler formula as
z = |z|(cos(x) + i*sin(x)) = |z|eix


where x is the complex argument. If we interpret x to be the angle of elevation of z in the complex plane, then we see that complex multiplication induces simultaneous rotation and scaling:
z1 = |z1|*ei*a1z2 = |z2|*ei*a2z1*z2 = |z1*z2|*ei*(a1+a2)


where a1 and a2 are the angles of elevation (or the complex arguments) of z1 and z2, respectively.

So, if we have a vector v, we may write it as a complex number z = v_x + i*v_y, and rotate it theta degrees by multiplying z by ei*theta, which gives:
z' = z*ei*theta = (v_x, v_y)*(cos(theta), sin(theta)) // in tuple form   = (v_x*cos(theta) - v_y*sin(theta), v_y*cos(theta) + v_x*sin(theta))


The latter part of that equation gives the standard formula for rotating a vector about the origin.

This derivation, of course, requires faith that the Euler formula is correct. Surprisingly, it can be proven rather easily. For some proofs, see the end of this Wikipedia article.

HTH,
nilkn

This topic is closed to new replies.

Advertisement