Vertical angle from normal

BlitzMax Forums/BlitzMax Programming/Vertical angle from normal

JoshK(Posted 2008) [#1]
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?


Canardian(Posted 2008) [#2]
Maybe something like: cos(angle) = X1*X2 + Y1*Y2 + Z1*Z2


fredborg(Posted 2008) [#3]
Method Yaw:Float() 'expose
	Return -ATan2( x,z )
End Method
	
Method Pitch:Float() 'expose
	Return -ATan2( y, Sqr( x*x+z*z ) )
End Method



JoshK(Posted 2008) [#4]
Actually ASin(ny) will always return the angle. The normal (0.577,0.577,0.577) has a pitch less than 45 degrees.