#### Archived

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

# Trying to calculate the Angle between 2 Vectors..

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

## 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 on other sites
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...

-me

[edited by - Palidine on April 18, 2003 6:33:22 PM]

##### 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 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...

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633718
• Total Posts
3013518
×