Trying to calculate the Angle between 2 Vectors..

Started by
2 comments, last by Jedite 21 years ago
Ok this is what im trying to do... I am trying to do z sorting for my particle system... What I was thinking of doing is this.. LookAT of the Camera = A. Right Vector of Camera = B. Origin Set at 0,0,1 = C. Angle = Dot(B,C)*90; Angle = Angle * 3.14/180 were am I going wrong here.... cause I am getting floating point numbers instead of the angle.. I might be missing something since Im on the last 2 weeks of my Game project and my brain is fried =) Thanx for Any help that comes
Advertisement
you don't have the equation right.
equation for smallest angle between 2 vectors is:

angle = acosf( dot(v1,v2)/ (||v1|| * ||v2||) );

where ||v1|| is magnitude of v1...

answer will be in radians.

-me

[edited by - Palidine on April 18, 2003 6:33:22 PM]
also, why are you using smallest angle to do z-sorting? just calculate the distance of each particle to the camera and sort on that. no need to calculate angles.

-me
Well i originally did that... However... when u move the camera a certain way i was getting really bad z sorting..... Like i u were facing the Particles and u turned too far right it would look like crapy zsorting with all the alpha messed up but u could go as far left as u like and no problem


Then i got together with one of my instructures and he told me to try and use the ATVector of the camera to determine the angle....

Any suggestions are welcome...

This topic is closed to new replies.

Advertisement