Jump to content
  • Advertisement

Archived

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

Jedite

Trying to calculate the Angle between 2 Vectors..

This topic is 5547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!