This is my second article. I hope you enjoy it. It is aimed at all klikkers, especially those who do not know how to use trigonometry and want to.

What is trigonomentry?
Trigonometry is a maths technique, used to work out angles and side lengths in a right-angled triangle, by using the other angles and side lengths.

Why is it useful?
It can be used for all sorts of problems. In Click products it can be used for several things, such as working out the distances between two objects.

How does it work?
In the diagram below, the names of the sides of the triangle correspond to the angle being used. The bottom side is between the angle used and the right-angle, so it's called the adjacent. The right side is opposite the angle, so it's called the opposite. The hypotenuse is the name of the slanted side.

Image

Now, remember Soh - Cah - Toa

The o's, a's, and h's you know already. (opposite, adjacent, hypotenuse).
S means Sine
C means Cosine
T means Tanjent

So the long version in short: Sin = Opp/Hyp, Cos = Adj/hyp, Tan = opp/adj

So if you knew the angle and adjacent values, you can work out:
the opposite by using Tangent (Toa)
the hypotenuse by using Cosine (Cah)

so, to work out opposite use: <adj>Tan<A>
(replace adj with adjacent value, replace A with angle value)

TIP: On a scientific calculator, or on a clickteam product's expression calculator, Sine, Cosine, and Tanjent are displayed as Sin, Cos + Tan

I hope you get the idea so far.

Working Backwards
So we can Work out a sides length. But how do we work out an angle from 2 sides? We work backwards
We know Tan=opp/adj, so we need to reverse this.
The inverse of Tan, Cos and Sin is: ATan, ACos, and ASin.
So the calculation is: ATan*(opp/adj)

One big calculation
To make sure you understand, we will put this into practice. Let's find the distance between two objects using their x and y values.
Player 1's x and y values will be P1x and P1y
Player 2's x and y values will be P2x and P2y

The adjacent (horisontal dist. between objects) will be P2x - P1x.
The opposite (vertical dist. between objects) will be P2y - P1y.
The Angle is therefore: ATan ((P2y-P1y)/(P2x-P1x ))

The hypotenuse (distance between both objects) can be worked out by either Sin and the Opp, or Cos and the Adj. I will use Sin.
Hypotenuse: <opp> Sin<angle>. The opp must be replaced by P2y-P1y, and angle must be replaced by the worked out angle: ATan ((P2y-P1y)/(P2x-P1x ))

So the final equasion would be: (P2y-P1y) Sin ATan ((P2y-P1y)/(P2x-P1x ))



i hope you managed to stay awake, and didn't fall over in confusion. Thank you for reading this tutorial, I hope it becomes useful

Klikmaster