Convert a 3D vector into a vertical angle

Miscellaneous Forums/General Discussion/Convert a 3D vector into a vertical angle

SohCahToa

Sine = Opposite / Hypoteneuse
Cosine = Adjacent / Hypoteneuse
Tangent = Opposite / Adjacent

The opposite is the length of the line opposite the angle we want to know. That would be the Y of the normal.

The hypoteneuse is the length of the line opposite the right angle in our triangle.

The adjacent is the remaining line which is not the hypoteneuse and which connects to the point at which we are looking for the angle.

So...

./|
/_|

This is our triangle. If you imagine the normal is in a plane, and this triangle is in that plane, the normal is the hypoteneuse. We know the length of it is 1.

Now, the Y component of the normal should tell us the length of the opposite, and thus what the angle is, using ArcSin.

I can't figure out right now why that doesn't work though.

But maybe using ArcCos will work out for you. The adjacent is the length of the X and Z component of the normal. So just square those, add them and square root to get the length and use that.