-1

Suppose if I have two vectors, A and B, and an axis (normalized vector), how do I find the angle between A and B such that the angle difference between A after rotation(axis, angle) and B wrt to the given axis is 0. A doesnt have to be equal to B after the rotation. Basically I want to find the angle difference between A and B in a specified plane.

Note: this is different than finding the shortest angle between 2 vectors since the axis is not the cross product between A and B. Thus, technique here (and many SO answers) does not apply. This needs to work in 3D.

user80667
  • 64
  • 6
  • 6
    I'm voting to close this question as off-topic because it is about geometry / [math.se] instead of programming or software development. – Pang Jul 21 '16 at 01:13
  • w/e I guess computer physics and computer graphics are not programming or software development right? Stuff like this: http://stackoverflow.com/questions/11022446/direction-of-shortest-rotation-between-two-vectors is offtopic too right? – user80667 Jul 21 '16 at 20:30

2 Answers2

0

I don't think the problem has a solution unless both A and B are the same length and A and B both make the same angle (in the usual sense of shortest angle between vectors) with the axis. I will assume that these are given.

In that case, one solution would be to compute the orthogonal projection of both A and B into a plane that is orthogonal to the axis. This could be done by subtracting the component that is in the direction of the axis. So if I have a unit vector in the direction of the axis and call it X, the computation would be something like

Aproj = A - dot(A, X)X
Bproj = B - dot(B, X)X

Then the angle between Aproj and Bproj (in the usual sense of shortest angle) is the angle of rotation around the axis that you are asking about.

I'm not sure if this is the simplest way to compute it, but it should work pretty generally.

Evan VanderZee
  • 727
  • 5
  • 9
  • Reading your answer made me realize I worded the question incorrectly. I should say that the angle difference between A after rotation(axis, angle) and B wrt to the given axis is 0. Basically I want to find the angle difference between A and B in a specified plane. I hope this is clear now. – user80667 Jul 20 '16 at 01:05
  • If I understand your question correctly, the answer is still the same. Project the vectors into the plane. Then compute the angle between the projected vectors. – Evan VanderZee Jul 20 '16 at 01:22
0

The dot product give the angle between A & B. In Fortran something like: dotAB = DASIN(DOT(A/|A|, B/|B|)).

A cross product gives a vector orthongal to A and B.

The projection of the Xproduct-vector towards the planes (or axis) should get you there when multiplied by the angle DotAB. You'll probably be a sine or cosine in there.

Holmz
  • 41
  • 2