My knowledge of trigonometry on how its used in games is flucutating back and forth (I have trouble seeing the whole picture), I need to solidify it in my mind.
I have a couple questions below: any help is appreciated.
Atan (Hypothenus) is main math function used to find angles between X and (Z or Y)
Arcos(The X) is used to find angles between the X, How can it find angles purely based off the X axis? Arcsin(The Y) is used to find angles between the Y, How can it find angles purely based off the Y axis? They both have only one axis to measure from? so it cant be used to find angles? unless I combine it using Atan?
Can this (Atan Visual Demonstration) be used for Arcos and Arcsin to find angles between objects?
When it comes to game development, what you really need to know is that there’s this function called Atan2 which can tell you the angle between vectors but unlike the dot product approach, it can also tell you the side it is on.
Trigonometry only works for things with right angles. The hypotenuse is always the longest side and the other sides (adjacent and opposite) are all relative to where you measure from. In your picture, for example, if we defined the angle to be between x and H then the adjacent would be x, the hypotenuse would be H and the opposite would be Z. A triangle always adds up to 180 degrees because trigonometry only works for right angles it means that the 2 angles you can calculate will add up to 90 degrees.
You can apply the functions inverses (their arc functions, so atan, acos, asin) to convert the ratio to the angle which all of your ratios are relative to in order to find the angle there.
It’s a bit weird because you’re talking about an angle as if it can be defined with only 2 points (the grey Parts). You always need 3 points to define an angle.
Looking at your figure you actually do have a third point, the corner of the angle, but you don’t define it as a freely moving Part like the other two points. Instead you define it as the intersection between two lines that pass through each Part and that are parallel to either the X or Z axis, respectively. This effectively locks the X and Z segments into being parallel to two different axes, and since we’re working in a right-angled coordinate system the angle between X and Z is always going to be 90 no matter where you place the points! Here’s an animation showing what I’m talking about in 2D:
As you can see, moving the points doesn’t change the angle and the line segments are always parallel to the coordinate system axes. All this means that it’s pointless to try and compute the angle like this, because the way you’ve defined the problem it’s always going to be the same independently of where the Parts are.
What you might be more interested in is the angle between the line segment formed by two Parts and some axis of the coordinate system, like this:
It’s used for all sorts of things in games programming