Ya he publicado una pregunta similar. pero dado que el problema sigue sin respuesta y los detalles son un poco cambiado, voy a postear de nuevo.
Estoy tratando de resolver el siguiente problema matemático:
Dados 2 conjuntos de 3 líneas cada uno en el espacio 3D (en la que cada línea está dada por una $3D$ punto y un $3D$ vector): $$ set1=\{ [(px1,py1,pz1), (vx1,vy1,vz1)], [(px2,py2,pz2),(vx2,vy2,vz2)], [(px3,py3,pz3), (vx3,vy3,vz3)] \} $$ $$ set2=\{ [(qx1,qy1,qz1), (ux1,uy1,uz1)], [(qx2,qy2,qz2),(ux2,uy2,uz2)], [(qx3,qy3,qz3), (ux3,uy3,uz3)] \} $$
find the angles of rotation $x,y,z$ (in radians) such that:
$$R=rotate\_x*rotate\_y*rotate\_z$$ $$ {rotar\_x} = \left( {\matriz{ {1} & {0} & {0} \cr {0} & {cos(x)} y {-sin(x)} \cr {0} & {sin(x)} & {cos(x)} \cr } } \right) $$ $$ {rotar\_y} = \left( {\matriz{ {cos(y)} & {0} & {sin(y)} \cr {0} & {1} & {0} \cr {-sin(y)} & {0} & {cos(y)} \cr } } \right) $$ $$ {rotar\_z} = \left( {\matriz{ {cos(z)} y {-sin(z)} & {0} \cr {sin(z)} & {cos(z)} & {0} \cr {0} & {0} & {1} \cr } } \right) $$
and if we rotate $set1$ by $R$ then all the lines in $set1$ will intersect their corresponding lines in $set2$.
Meaning, let's define $set1\_r$ as $set1$ after the above rotation.
Then line $i$ $(i=1,2,3)$ in $set1\_r$ will intersect line $i$ in $set2$.
I already built the 3 equations with 3 variables that needed to be solved. but they seem to be unsolvable.
Here are the equations (only the angles $x,y,z$ are unknown and the rest are known):
eq1 = qx1*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)) + qy1*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)) + ((ux1*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)) + uy1*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)) + uz1*cos(x)*cos(y))*(px1 - qz1*sin(y) - qx1*cos(y)*cos(z) + qy1*cos(y)*sin(z) + (vx1*(qx1*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) - py1 + qy1*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - qz1*cos(y)*sin(x) + ((ux1*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy1*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz1*cos(y)*sin(x))*(px1 - qz1*sin(y) - qx1*cos(y)*cos(z) + qy1*cos(y)*sin(z)))/(uz1*sin(y) + ux1*cos(y)*cos(z) - uy1*cos(y)*sin(z))))/(vy1 - (vx1*(ux1*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy1*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz1*cos(y)*sin(x)))/(uz1*sin(y) + ux1*cos(y)*cos(z) - uy1*cos(y)*sin(z)))))/(uz1*sin(y) + ux1*cos(y)*cos(z) - uy1*cos(y)*sin(z)) + qz1*cos(x)*cos(y) == pz1 + (vz1*(qx1*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) - py1 + qy1*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - qz1*cos(y)*sin(x) + ((ux1*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy1*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz1*cos(y)*sin(x))*(px1 - qz1*sin(y) - qx1*cos(y)*cos(z) + qy1*cos(y)*sin(z)))/(uz1*sin(y) + ux1*cos(y)*cos(z) - uy1*cos(y)*sin(z))))/(vy1 - (vx1*(ux1*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy1*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz1*cos(y)*sin(x)))/(uz1*sin(y) + ux1*cos(y)*cos(z) - uy1*cos(y)*sin(z)))
eq2 = qx2*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)) + qy2*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)) + ((ux2*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)) + uy2*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)) + uz2*cos(x)*cos(y))*(px2 - qz2*sin(y) - qx2*cos(y)*cos(z) + qy2*cos(y)*sin(z) + (vx2*(qx2*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) - py2 + qy2*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - qz2*cos(y)*sin(x) + ((ux2*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy2*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz2*cos(y)*sin(x))*(px2 - qz2*sin(y) - qx2*cos(y)*cos(z) + qy2*cos(y)*sin(z)))/(uz2*sin(y) + ux2*cos(y)*cos(z) - uy2*cos(y)*sin(z))))/(vy2 - (vx2*(ux2*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy2*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz2*cos(y)*sin(x)))/(uz2*sin(y) + ux2*cos(y)*cos(z) - uy2*cos(y)*sin(z)))))/(uz2*sin(y) + ux2*cos(y)*cos(z) - uy2*cos(y)*sin(z)) + qz2*cos(x)*cos(y) == pz2 + (vz2*(qx2*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) - py2 + qy2*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - qz2*cos(y)*sin(x) + ((ux2*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy2*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz2*cos(y)*sin(x))*(px2 - qz2*sin(y) - qx2*cos(y)*cos(z) + qy2*cos(y)*sin(z)))/(uz2*sin(y) + ux2*cos(y)*cos(z) - uy2*cos(y)*sin(z))))/(vy2 - (vx2*(ux2*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy2*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz2*cos(y)*sin(x)))/(uz2*sin(y) + ux2*cos(y)*cos(z) - uy2*cos(y)*sin(z)))
eq3 = qx3*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)) + qy3*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)) + ((ux3*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)) + uy3*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)) + uz3*cos(x)*cos(y))*(px3 - qz3*sin(y) - qx3*cos(y)*cos(z) + qy3*cos(y)*sin(z) + (vx3*(qx3*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) - py3 + qy3*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - qz3*cos(y)*sin(x) + ((ux3*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy3*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz3*cos(y)*sin(x))*(px3 - qz3*sin(y) - qx3*cos(y)*cos(z) + qy3*cos(y)*sin(z)))/(uz3*sin(y) + ux3*cos(y)*cos(z) - uy3*cos(y)*sin(z))))/(vy3 - (vx3*(ux3*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy3*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz3*cos(y)*sin(x)))/(uz3*sin(y) + ux3*cos(y)*cos(z) - uy3*cos(y)*sin(z)))))/(uz3*sin(y) + ux3*cos(y)*cos(z) - uy3*cos(y)*sin(z)) + qz3*cos(x)*cos(y) == pz3 + (vz3*(qx3*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) - py3 + qy3*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - qz3*cos(y)*sin(x) + ((ux3*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy3*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz3*cos(y)*sin(x))*(px3 - qz3*sin(y) - qx3*cos(y)*cos(z) + qy3*cos(y)*sin(z)))/(uz3*sin(y) + ux3*cos(y)*cos(z) - uy3*cos(y)*sin(z))))/(vy3 - (vx3*(ux3*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)) + uy3*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)) - uz3*cos(y)*sin(x)))/(uz3*sin(y) + ux3*cos(y)*cos(z) - uy3*cos(y)*sin(z)))
It can be seen that it's almost impossible (hopefully not impossible) to extract $x,y,z$ from the equations since there are many multiplications between $sin$ and $cos$ de los diferentes ángulos. Yo no podía resolver. y yo también lo he probado en matlab usando el 'resolver' la función pero no funcionó.
Puede alguien sugerir una solución para encontrar los ángulos $x,y,z$? o cualquier otra forma de encontrar la matriz $R$?
Si ayuda, aquí es un ejemplo específico de los 2 conjuntos de líneas en las que sé que el ángulo deseado $x,y,z$ (probablemente hay muchos más trillizos de los ángulos que también resolver el problema).
%set1
px1=0;
py1=0;
pz1=-30;
px2=0;
py2=0;
pz2=-30;
px3=0;
py3=0;
pz3=-30;
vx1 = -0.083717247687439;
vy1 = -0.107930827800543;
vz1 = 0.990627255252918;
vx2 = 0.076364294519742;
vy2 = 0.060269029165473;
vz2 = 0.995256820446840;
vx3 = -0.081460429387834;
vy3 = 0.105021268850622;
vz3 = 0.991128009660183;
%set2
qx1=0;
qy1=0;
qz1=-30;
qx2=0;
qy2=0;
qz2=-30;
qx3=0;
qy3=0;
qz3=-30;
ux1 = -0.079382581863774;
uy1 = -0.095259098236529;
uz1 = 0.992282273297173;
ux2 = 0.079382581863774;
uy2 = 0.095259098236529;
uz2 = 0.992282273297173;
ux3 = -0.086165283952334;
uy3 = 0.103398340742801;
uz3 = 0.990900765451843;
Para el ejemplo anterior, para $x=0.5236$ ($x$ es de 30 grados), $y=0, z=0$, significado, $$ {R} = \left( {\matriz{ {1} & {0} & {0} \cr {0} & {0.866} & {-0.5} \cr {0} & {0.5} & {0.866} \cr } } \right) $$
$$ $i$ ($i=1,2,3$) in $set1$ will intersect $$ $i$ in $set2$.
Also, $x=0, y=0, z=0$ ($R$ is the identity matrix) is also a solution since all the $6$ lines already intersect at the point $(0,0,-30)$.
Y estoy seguro de que hay muchas más soluciones.
Pero, por supuesto, necesito la solución general.
Espero que alguien pueda solucionarlo ya que he estado tratando de resolver por semanas :(.
Gracias