Search code examples
matlabrotationgeometryplane3d-reconstruction

How can I use the rotation angle and axis to rotate a 3D plane?


I have two planes and know the planes' equations and normals. I want to rotate the points of the blue plane to the orange plane.

I use normals to get the rotation axis and rotation angle and use the Rodrigues' rotation formula to get the rotation matrix.

Multiplying the blue plane's normal by the rotation matrix, it works, the normal is equal to the normal of the orange plane. But when multiplying the points coordinates in the blue plane, the result is not I want. Which part did I ignore?

The blue and orange pane: the blue and orange plane

After rotation:

after rotation

  blue plane:  0.4273x-0.0075y-0.9041z+13.5950=0;
      normal:  [0.4273;-0.0075;-0.9041]
orange plane: -0.8111x+0.0019y-0.5849z+7.8024=0;
      normal:  [-0.811;0.0019;-0.5849]
theta = acos(dot(n_left,n_right)/(norm(n_left)*norm(n_right)));
theta = 1.3876;
axis = cross(n_left,n_right) / norm(cross(n_left,n_right));
axis = (-0.0062;-1.0000;0.0053);
C_matrix = [0     -axis(3) axis(2); 
            axis(3)  0     -axis(1);  
            -axis(2) axis(1)  0];  %cross product matrix
R = diag([1 1 1]) + (1-cos(theta))*C_matrix^2 + sin(theta)*C_matrix;
R = [0.1823,-0.0001,-0.9833;
    0.0104,0.9999,0.0018;
    0.9832,-0.0105,0.1822];
after_rotation = R*blue_points;
  one point of blue plane: [-1.1056;-0.2270;14.8712]
           after rotation: [14.8197;-0.4144;-1.6222]
one point of orange plane: [-0.2366;-0.4296;14.9292)]

I have a new question, like before. But I still cannot solve perfectly. Could you tell me which part should I fill?

left plane: 0.0456x+0.0016y-0.999z+1.1333=0;
normal: [0.0456,0.0016,-0.999]
right plane: -0.0174x+0.0037y-0.998z+0.9728=0;
normal: [-0.0174,0.0037,-0.9998]
rotation matrix:
R = [0.9980   -0.0001    0.0630
    0.0003    1.0000   -0.0021
   -0.0630    0.0021    0.9980]
one point on the left plane:[-2.4 -0.6446 1.0031]
after rotate: [-2.4012 -0.6446 0.9916]
one point on the right plane:[0.4095 -0.6447 0.9634]

Before rotation:

before_rotation before_rotation_2

After rotation:

after rotation after rotation_2

After rotation, I guess they are in the same plane, but they don't meet. What should I do to make the right side of the yellow plane to meet the left side of the blue plane? Which point should I rotate around? Origin? Thanks a lot for your answer!


Solution

  • Your current rotation performs the rotation about the origin.

    If you want the planes to coincide, perform the rotation about a shared point between both planes (assuming the original planes were not parallel).

    You can find a shared point from the 2 plane equations:

    % Store data about plane
    n_left = [0.43273 -0.0075 -0.9041];
    n_left = n_left/norm(n_left);
    b_left = -13.5950;
    
    n_right = [-0.8111 0.0019 -0.5849];
    n_right = n_right/norm(n_right);
    b_right = -7.8024;
    
    % Find a point on both planes
    shared_point = [n_left; n_right]\[b_left; b_right];
    

    To rotate around this shared_point instead of the origin, perform this operation:

    % Transform points
    after_rotation = R*(blue_points - shared_point) + shared_point;