math & physics
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.
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.
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.