Archived

This topic is now archived and is closed to further replies.

RPGman

angle of 2 normals

Recommended Posts

RPGman    122
this is a question on how to get the angle between 2 normals... I read numerous places that you use the Dot Product of the 2 normals, but that does not return in the form of an angle! can anyone help me? Edited by - rpgman on August 2, 2001 4:22:41 PM

Share this post


Link to post
Share on other sites
davepermen    1047
if the two normals ( or simply, the two vectors ) are length 1, the returnvalue of the dotproduct is the cosine of the angle between the two vectors.. to get the angle, just use the "inverse cosine", arcus cosinus, or arc-sine in english, to get it, means float angle = acosf( dot( normalize( v0 ), normalize( v1 ) );

but normaly you dont need the angle, just the acosf, except you need to call something like glRotatef or such stuff..

we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites
Dragonus    122
This is the formula you need...

If A and B are vectors and q is the angle between them, then

A.B = |A| * |B| * cos(q)

where A.B refers to the dot product of the two vectors and |A| refers to the length (or magnitude) of the two vectors.

So to get the angle q, find the dot product, and then divide that by the product of lengths of the two vectors, and then take the arc-cosine of it.

~ Dragonus

Share this post


Link to post
Share on other sites