speak on oh mathemagician!
Hardly, though I can give some tasty bits of knowledge.
Trigonometry is so elegant. Take for instance SOHCAHTOA - Pronounced Sow-Caw-Toe-Ah.
SOHCAHTOA means Sin(Theta) = Opposite/Hypotenuse, Cos(Theta)= Adjacent/Hypontenuse, Tan(Theta) = Opposite/Adjacent.
Now don't get freaked out yet, save that for the next part. Here are a few explanations:
Theta - Theta means the rotation/angle.
Sin - Sin is short for Sine, not the number of evil things you have done.
Cos - Cos is short for Cosine.
Tan - Tan is short for Tangent.
Opposite - This means the opposite leg from Theta(The angle/rotation)
Adjacent - This means the neighbor leg from Theta(The angle/rotation) that isn't the hypotenuse.
Hypotenuse - Line that goes from leg 1 to leg 2, it is always the largest leg.
Now just for the record, I am specifically
only talking about right triangles. I don't have enough knowledge for any other.
Alright, so now you know the definitions. Now what? I'll show you, in song.(Kidding instead I will use a picture)
So now you may understand a little more, though how do you actual use these neat tools for your projects?
Easily, for example what if you only have the angle(which is 34 degrees) and the adjacent leg(which is 5 meters) of the triangle?
Just look through your 3 equations, pick the right one and plug 'er in. Like so:
You can also reverse engineer it if you have the adjacent and opposite but no angle:
(1) Tan(Theta/Angle) = 3.3725 / 5
(2) Theta/Angle = Tan-1(3.3725 / 5)
(3) Theta/Angle = Tan-1(.6745)
(4) Theta/Angle = 34 Degrees
So what's Tan-1? Tan-1 is the ArcTangent, it is basically the opposite and undoes what Tangent does.
Like an evil clone.You can find the Tan-1(.6745) in your handy dandy Calculator application by typing .6745, holding the shift key, and clicking tan-1.
Voila! Now you know all this neat info on finding angles and legs with these unique little equations though... how in the world do you apply this to an application? Or how about, a game? With sprites?
Easily! Glad you asked, I'll show you how.
Let's say that you are a Ranger going through the woods at night. You have this neat ability called "Tracking". It's where somehow you just know that a monster is near by.
Suddenly! Your senses go wild and you detect a monster close by, you pull your sword from your sheath and look around. Though... the programmer of the game has no trigonometry knowledge, you have no idea in which direction the monster is. Suddenly you hear a growl, something jumps on your back and everything goes black...
Well, that bites. I guess you wouldn't be dead if the cruddy programmer had just decided to learn a little about angles and such. Then you would be able to know at what angle the monster is.
So let's do just that. There's a ranger and a monster. Ranger's coordinates are 0,0 and the monster's coordinates are 25, 25. Let's save this ranger and show him what angle he should face.
Suddenly! Your senses go wild and you detect a monster close by, you pull your sword from your sheath and look around. Your nose detects a putrid smell, you notice tracks on the ground, (Immediately the game finds the angle in which you should face), and you turn toward the oncoming monster right as it jumps to attack...So Silver, if Al's GameMaker has a rotate sprite function, I can help you with some code to allow a sprite to rotate towards something. It's very useful in puzzle, rpg, shooting(very useful), and arcade games.
If you want, I can help conjure up some code to do whatever your need may be that involves with angles and trigonometry.
Hope I didn't bore you guys to death, and it would be very awesome if some of you could apply this to your games.
-Gandolf