tengo un punto . Quiero rotar los ejes para que las nuevas coordenadas sean . Defina las siguientes matrices de rotación:
, , y .
Quiero y ser tal que si ; si la rotación se puede obtener ajustando solo ; si la rotación se puede obtener ajustando solo y . ¿Alguna pista?
EDITAR : Siguiendo la respuesta de JordiC: sí, la distancia al origen es la misma para y ; puedo configurar y la matriz de rotación se simplificará:
.
Encontré esto: encuentre la rotación que asigna un punto a su objetivo , que parece ser la misma pregunta.
Si usa solo rotaciones para convertir las coordenadas de P0 a P1, necesitará solo 2 rotaciones para la conversión. También la distancia al origen de P0 y P1 debe ser la misma. En este caso siempre puedes considerar que:
α = 0.
Así que solo tienes que pensar en β y γ.
Y β será siempre 0 si z0 = z1.
Ok, he encontrado una solución rápida. Breve ejemplo con comentarios en Matlab.
% P0 and P1 are two vectors on a unit sphere:
P0 = randn(3, 1); P0 = P0 / norm(P0);
P1 = randn(3, 1); P1 = P1 / norm(P1);
% theta and phi are the respective spherical coordinates:
phi_0 = acos(P0(3));
theta_0 = atan2(P0(2), P0(1));
phi_1 = acos(P1(3));
theta_1 = atan2(P1(2), P1(1));
% Show that the coordinates are equivalent:
P0b = zeros(3, 1);
P0b(1) = sin(phi_0) .* cos(theta_0);
P0b(2) = sin(phi_0) .* sin(theta_0);
P0b(3) = cos(phi_0);
all(fix(1e12 * (P0 - P0b)) == 0)
% R1: Rotation matrix to move P0 to the north pole:
P0_y = -phi_0; P0_z = -theta_0;
R1 = [cos(P0_y) * cos(P0_z) -cos(P0_y) * sin(P0_z) sin(P0_y);
sin(P0_z) cos(P0_z) 0;
-sin(P0_y) * cos(P0_z) sin(P0_y) * sin(P0_z) cos(P0_y)];
% R2: Rotation matrix to move P1 to the north pole ...
P1_y = -phi_1; P1_z = -theta_1;
R2 = [cos(P1_y) * cos(P1_z) -cos(P1_y) * sin(P1_z) sin(P1_y);
sin(P1_z) cos(P1_z) 0;
-sin(P1_y) * cos(P1_z) sin(P1_y) * sin(P1_z) cos(P1_y)];
% ... and back to its original position:
R2 = R2 ^ (-1);
% Rotation matrix to move P0 to the north pole and from the north pole to P1
R = R2 * R1;
% New coordinates of P0 after rotation:
P0_rot = R * P0;
% Check that the new coordinates of P0 are the same as P1
all(fix(1e12 * (P0_rot - P1)) == 0)
% Rotation matrix to move back the rotated point P0 to its original coordinates
R_back = R^(-1);
% Coordinates rotated back
P0_rot_back = R_back * P0_rot;
% Check the new coordinates of P0, once rotated back:
all(fix(1e12 * (P0_rot_back - P0)) == 0)
Espero que haya una forma más obvia de hacerlo, pero por ahora esta solución parece funcionar bien.
al azar en el usuario