I created a DCM from Euler angle sequence 1-2-3. Then I found the Principal Rotation Parameters from the DCM. Then I used the Principal Rotation Parameters to find the DCM again. But I produced a different DCM both times. Can you help me fix the MATLAB code, so I produce the same DCM both times? EA = [pi/3; -pi/4; -pi/6]; EA123toDCM = EA123DCM(EA) [theta, lambda] = DCMtoPRP(EA123toDCM) PRPtoDCM = PRP2DCM(theta, lambda)   function [R] = EA123DCM(EA)     theta1 = EA(1,1);     theta2 = EA(2,1);     theta3 = EA(3,1);               R1 = @(a)[1    0      0    ;               0  cos(a) sin(a);               0  -sin(a) cos(a)];                R2 = @(a)[cos(a)  0 -sin(a) ;                 0     1   0    ;               sin(a) 0 cos(a)];                R3 = @(a)[ cos(a) sin(a) 0;                -sin(a) cos(a)  0;                   0      0     1];           R = R3(theta1)*R2(theta2)*R1(theta3); end function [theta, lambda] = DCMtoPRP(EA123toDCM)     theta = acos((1/2)*(trace(EA123toDCM)) - 1);     lambda = (1/(2*sin(theta))) * [EA123toDCM(2,3) - EA123toDCM(3,2);                                    EA123toDCM(3,1) - EA123toDCM(1,3);                                    EA123toDCM(1,2) - EA123toDCM(2,1)]; end function [PRPtoDCM] = PRP2DCM(theta, lambda)     C11 = lambda(1,1)^2*(1-cos(theta))+cos(theta);     C12 = lambda(1,1)*lambda(2,1)*(1-cos(theta))+lambda(3,1)*sin(theta);     C13 = lambda(1,1)*lambda(3,1)*(1-cos(theta))-lambda(2,1)*sin(theta);     C21 = lambda(1,1)*lambda(2,1)*(1-cos(theta))-lambda(3,1)*sin(theta);     C22 = lambda(2,1)^2*(1-cos(theta))+cos(theta);     C23 = lambda(3,1)*lambda(2,1)*(1-cos(theta))+lambda(1,1)*sin(theta);     C31 = lambda(1,1)*lambda(3,1)*(1-cos(theta))+lambda(2,1)*sin(theta);     C32 = lambda(3,1)*lambda(2,1)*(1-cos(theta))-lambda(1,1)*sin(theta);     C33 = lambda(3,1)^2*(1-cos(theta))+cos(theta);     PRPtoDCM = [C11 C12 C13;                            C21 C22 C23;                            C31 C32 C33]; end

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I created a DCM from Euler angle sequence 1-2-3. Then I found the Principal Rotation Parameters from the DCM. Then I used the Principal Rotation Parameters to find the DCM again. But I produced a different DCM both times. Can you help me fix the MATLAB code, so I produce the same DCM both times?

EA = [pi/3; -pi/4; -pi/6];
EA123toDCM = EA123DCM(EA)

[theta, lambda] = DCMtoPRP(EA123toDCM)

PRPtoDCM = PRP2DCM(theta, lambda)

 

function [R] = EA123DCM(EA)

    theta1 = EA(1,1);
    theta2 = EA(2,1);
    theta3 = EA(3,1);
    
    
    R1 = @(a)[1    0      0    ;
              0  cos(a) sin(a);
              0  -sin(a) cos(a)];
          
    R2 = @(a)[cos(a)  0 -sin(a) ;
                0     1   0    ;
              sin(a) 0 cos(a)];
          
    R3 = @(a)[ cos(a) sin(a) 0;
               -sin(a) cos(a)  0; 
                 0      0     1];
     
    R = R3(theta1)*R2(theta2)*R1(theta3);

end

function [theta, lambda] = DCMtoPRP(EA123toDCM)

    theta = acos((1/2)*(trace(EA123toDCM)) - 1);
    lambda = (1/(2*sin(theta))) * [EA123toDCM(2,3) - EA123toDCM(3,2);
                                   EA123toDCM(3,1) - EA123toDCM(1,3);
                                   EA123toDCM(1,2) - EA123toDCM(2,1)];
end

function [PRPtoDCM] = PRP2DCM(theta, lambda)
    C11 = lambda(1,1)^2*(1-cos(theta))+cos(theta);
    C12 = lambda(1,1)*lambda(2,1)*(1-cos(theta))+lambda(3,1)*sin(theta);
    C13 = lambda(1,1)*lambda(3,1)*(1-cos(theta))-lambda(2,1)*sin(theta);
    C21 = lambda(1,1)*lambda(2,1)*(1-cos(theta))-lambda(3,1)*sin(theta);
    C22 = lambda(2,1)^2*(1-cos(theta))+cos(theta);
    C23 = lambda(3,1)*lambda(2,1)*(1-cos(theta))+lambda(1,1)*sin(theta);
    C31 = lambda(1,1)*lambda(3,1)*(1-cos(theta))+lambda(2,1)*sin(theta);
    C32 = lambda(3,1)*lambda(2,1)*(1-cos(theta))-lambda(1,1)*sin(theta);
    C33 = lambda(3,1)^2*(1-cos(theta))+cos(theta);

    PRPtoDCM = [C11 C12 C13;
                           C21 C22 C23;
                           C31 C32 C33];

end

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Counting Problems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education