views:

69

answers:

1

hello,

i have two coordinates on a 2d plane in 3d space, and am trying to rotate one coordinate (a vector) to face the other coordinate. my vertical axis is the y-axis, so if both of the coordinates are located flat on the 2d plane, they would both have a y-axis of 0, and their x and z coordinates determine their position length/width-wise on the plane. right now, i'm calculating the angle like so (language agnostic):

angle = atan2(z2-z1,x2-x1);

and am rotating/translating in space like so:

pushMatrix();
rotateY(angle);
popMatrix();

this doesn't seem to be working though. are my calculations/process correct?

A: 

I don't really understand your question (see my comment) but if you're looking for the angle difference in radians between two vectors take the arc cos of their dot product. The vectors in the dot product have to be normalized.

You're using tan, either I don't get what you're trying to do or using tan is wrong.

Chris H