#### Archived

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

# finding the angle

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

## Recommended Posts

Hello I have my camera located at (x,y,z), and looking at the direction (x1,y1,z1). If i have a model at (x2,y2,z2), how do i find the angle between the model(x2,y2,z2) and my camera(x,y,z) ??? thanks , Bruno

##### Share on other sites
The short answer is to use the dot product.

But please, use the search feature to find "angle between two vectors". It will be more detailed.

Thank you,

Cédric

##### Share on other sites
your three points define a triangle. Use the law of cosines:

a2 + b2 - 2ab cosA = c2

where A is the angle between sides a and b. so, in your case, you want to know a, so you rewrite the equation:

(a2 + b2 - c2)/2ab = cosA
arccos((a2 + b2 - c2)/2ab) = A

a2=dx12 + dy12 + dz12

b2=dx22 + dy22 + dz22

dx1 = x1 - x
dy1 = y1 - y
dz1 = z1 - z
dx2 = x2 - x
dy2 = y2 - y
dz2 = z2 - z

check the time on my post. If it is more than 10 minutes old, then I don't have any corrections pending.

Do you use your powers for good or for awesome?
|My site | Association of Computing Machinery

[edited by - capn_midnight on September 2, 2003 4:05:21 PM]

[edited by - capn_midnight on September 2, 2003 4:09:02 PM]

• 17
• 11
• 15
• 9
• 49
• ### Forum Statistics

• Total Topics
631393
• Total Posts
2999774
×