Jump to content


- - - - -

Angle between 2 objects eg.


2 replies to this topic

#1 jacko13

    New Member

  • Members
  • PipPip
  • 13 posts

Posted 19 November 2009 - 04:42 PM

Hi, I have question, how can I calculate current angle between 2 objects. Eg. 1st is camera and 2nd is Cube. I need this for check, is angle between this objects are smaller or bigger than 50 degrees etc.

#2 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1059 posts

Posted 19 November 2009 - 04:57 PM

Oh my God, not again, pick some books for Christ' sake and use your brain. Camera is ok, but how can a cube has a property like orientation and direction?? You need two vectors to do this. The 1st is the direction of the camera and the 2nd should be something unknown to be and probably to you. Then you use both vectors as arguments to an operation known as dot product or, alternatively, scalar product.

#3 SyntaxError

    Valued Member

  • Members
  • PipPipPip
  • 139 posts

Posted 19 November 2009 - 07:44 PM

I'm assuming you mean the angel between the vector along which the camera is pointing and the vector from the camera to some point in or on the cube. If you have a vector of length one (a unit vector) describing the direction your camera points and also the point where your camera is located, you can subtract the camera point from the cube point to give you a second vector. Then you normalize that vector (divide it's X,Y and Z components by it's length) to make it a unit vector. Now you take the acos of the dot product of you your two unit vectors and you have your answer.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users