Find rotation angle between two point for a 3D object

I have 2 point A, B. I have a 3D object placed at B. I want to know the angle between my two points along z axis, so that I can apply the same rotation to my object 3D.


Look at the image attached. Initially my points are like t1. And with time it changes like this. I mean the points are rotated. I have a 3D object placed at B and I wsnt to view its rotation along A,B. Its like, flip a object along in z axis, i mean rotate the object vertically along z axis. Consider any front view of an object, ehich initially leans towards the screen and gradually becomes straight. The distance between A, B is constant.

The diagram is not clear to me, but here are several examples that rotate an object to face another point:

Hi, i saw all these implementation but I think my case is different. However I have calculated the rotation, but the problem is another.


Look at thithiese picture I attached. This is my real world situation. Lets say, I have a 3D object(a box in this example). I know its position and the position of the camera in real world. Both of theor position actually updating continuously, but they are always in same distance and same orientation. Now according to this picture, since my camera is sitting in right side of the box, i should see the right plane of the box? Isn’t it? But I cant achieve this thing. I always see the side view of the box. How come this happens?

Currently I am rotating my object Math.PI/2 along y axis, to get the expected view.

Make a demo like this that shows the problem.

1 Like

Just let say the demo above, I want to see the other side of the sphere. I know the sphere position, I have a camera position which is = sphere_position + some_offset. Camera looks at sphere_position. But I cant see the exact other side of the sphere. It looks like I see the sphere from an angle. But I want to exactly see the other side of the sphere.

Just rotate camera or object

Hi, thats what I want to know actually. If my camera position is set on the other side of the cube, doesn’t it means that I will automatically see the other side of the cube?

use function lookAt and camera will be rotated to object