Reputation: 2007
So I have 3 3D Vectors, W, T1 and T2 that satisfy the relationship W = T1*cos(theta) + T2*sin(theta).
I need to come up with an algorithm that can find theta given these 3 vectors. However I'm stuck and don't know where to start even.
Upvotes: 0
Views: 266
Reputation: 6365
If T1 and T2 are not collinear, you can use cross product:
If they are collinear, just project them on a line and solve scalar equation A=B*cos(theta)+C*sin(theta)
Upvotes: 1
Reputation: 4996
Use techniques from linear algebra to solve for the possibilities of cos(theta) and sin(theta).
[ T1_1 | T2_1 | W_1 ]
[ T1_2 | T2_2 | W_2 ]
[ 1 | T2_1 / T1_1 | W_1 / T1_1 ]
[ T1_2 | T2_2 | W2 ]
[ 1 | T2_1 / T1_1 | W_1 / T1_1 ]
[ 0 | T2_2 - T1_2 * T2_1 / T1_1 | W2 - T1_2 * W_1 / T1_1 ]
[ 1 | T2_1 / T1_1 | W_1 / T1_1 ]
[ 0 | 1 | (W2 - T1_2 * W_1 / T1_1) / (T2_2 - T1_2 * T2_1 / T1_1) ]
[ 1 | 0 | W_1 / T1_1 - T2_1 / T1_1 * (W2 - T1_2 * W_1 / T1_1) / (T2_2 - T1_2 * T2_1 / T1_1) ]
[ 0 | 1 | (W2 - T1_2 * W_1 / T1_1) / (T2_2 - T1_2 * T2_1 / T1_1) ]
So,
cos(theta) = alpha * W_1 / T1_1 - T2_1 / T1_1 * (W2 - T1_2 * W_1 / T1_1) / (T2_2 - T1_2 * T2_1 / T1_1)
sin(theta) = alpha * (W2 - T1_2 * W_1 / T1_1) / (T2_2 - T1_2 * T2_1 / T1_1)
We know that
cos(theta)^2 + sin(theta)^2 = 1
Plugging the previous equations for cos(theta)
and sin(theta)
into that last equation, we can solve for alpha
. Knowing that, we can calculate the actual value of theta
by using either arccosine or arcsine.
Note, that I have not checked my work in any of these steps, so I do not make any guarantees about the accuracy of the equations. I leave that as an exercise for you.
Upvotes: 0