I hope you can help me with a mathematical problem I'm trying to solve (for many days) and so far no success.
Given 2 sets P=[p_1,p_2,p_3] and Q=[q_1,q_2,q_3] of 3 infinite lines each in 3D space (each p_i and q_i (i=1,2,3) is a 3D line represented by a 3D point and a unit vector). so overall we have 6 lines.
I need to find a rotation matrix R (3x3) so that if I rotate all the lines in P by R then I get new lines P_rotate=[p_1_rotate, p_2_rotate, p_3_rotate] so that p_i_rotate and q_i (i=1,2,3) intersect each other.
I know there might not be such a rotation matrix and in some cases there might be infinite rotation matrices (for example if all the 6 lines are on the same plane and the axis of rotation is perpendicular to that plane). but the assumption here that for sure there exists such a rotation matrix and if there are more than one, then I can choose any of them.
This is what I tried to do so far:
It's actually solving 3 equations of 3 variables (the variables are the 3 angles around the axises x,y,z).
but the equations were extremely complex that I couldn't solve them (and I'm not even sure they are solvable).
You can calculate the rotated lines as a function of the 3 angles. meaning each rotated line will contain a new point and a new vector both as a function of the 3 angles. then I calculate for each line the distance to the relevant line in Q. and I need to find for which angles the 3 distances are zero. I assumed here that first I rotate around Z axis, then around Y axis and then around X axis. I think the order doesn't matter since whatever order I choose I may get different angles but the final rotation matrix will be the same.
Anyway, the final 3 equations were extremely long and with many multiplications of the unknown variables so it was actually impossible for me to solve them.
I also tried to solve it in a different way. not using rotation matrix. but Rodrigues' rotation formula. in Rodrigues' formula I rotate around an axis line that passes through the origin by an angle theta. so I actually need to find v_x,v_y,theta where v_x, v_y are the x and y components of a unit vector of the axis line (v_z can be calculated by v_x and v_y since the vector is unit). and theta is an angle of rotation around this axis. again, I got 3 very long and complex equations that I couldn't solve.
Anyone has any idea of how to solve it? or can refer me to a link that (hopefully) explains about it? Will appreciate any help!
Thank you
David
This is not an answer to the question as posed, but rather a rough sketch if the rotations could be about any axis.
Fix the set $P=\{P_1,P_2,P_3\}$ of lines. The set $Q=\{Q_1,Q_2,Q_3\}$ will be moved. Rotate $Q$ about an axis through the origin, with the axis not parallel to the directions of the three $Q$-lines, and not orthogonal to the directions of the three $P$-lines, until $Q_1$ bangs into $P_1$ at point $a$. I believe if the axis is generic enough, $Q_1$ will hit $P_1$. Not sure I have the genericity conditions correct, but some assumptions will work.
Now spin $Q$ about the vector from the origin to $a$ until $Q_2$ bangs into $P_2$ at point $b$. Again I need to assume no accidental degeneracies to ensure the collision. Note the $Q_1 \cap P_1$ intersection is maintained.
Finally, spin $Q$ about the line containing $ab$. This axis is (in general) not through the origin. Barring degeneracies, $Q_3$ will bang into $P_3$, while the $Q_1 \cap P_1$ and $Q_2 \cap P_2$ intersections remain.