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
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started