Vertical angle from normal
BlitzMax Forums/BlitzMax Programming/Vertical angle from normal
| ||
I want to retrieve the angle of a terrain slope given the normal at that position. Both these normals would have a slope of 45 degrees: ( 0.707, 0.707, 0.0 ) ( 0.577, 0.577, 0.577 ) How the heck do I calculate this? |
| ||
Maybe something like: cos(angle) = X1*X2 + Y1*Y2 + Z1*Z2 |
| ||
Method Yaw:Float() 'expose Return -ATan2( x,z ) End Method Method Pitch:Float() 'expose Return -ATan2( y, Sqr( x*x+z*z ) ) End Method |
| ||
Actually ASin(ny) will always return the angle. The normal (0.577,0.577,0.577) has a pitch less than 45 degrees. |