A brief post how to calculate the three angles (roll, pitch and yaw) of a moving plane defined by three points.

Matlab code:

filename_points = 'Points.xlsx'; % Excel file name
data = xlsread(filename_points); % Reading data from excel file
index = length(data); % Length of the data
rad2degree = 57.3; % Radians to degrees factor

for i=1:index
    Point_1 = [data(i,1),data(i,2),data(i,3)];
    Point_2 = [data(i,4),data(i,4),data(i,5)];
    Point_3 = [data(i,7),data(i,8),data(i,9)];
    % k
    V_1 = Point_1-Point_3;
    V_Magnitude = norm(V_1); % Magnitude V_Magnitude= sqrt(Vk(1)^2 + Vk(2)^2 + Vk(3)^2);
    V_1 = V_1 / V_Magnitude;
    Vector1 = Point_2-Point_1; 
    % i
    V_2 = cross(Vector1,V_1);
    V_Magnitude = norm(V_2); % Magnitude V_Magnitude= sqrt(Vk(1)^2 + Vk(2)^2 + Vk(3)^2);
    V_2 = V_2/V_Magnitude;
    % j
    V_3 = cross(V_1,V_2);
    V_Magnitude = norm(V_3);
    V_3 = V_3/V_Magnitude;
    Rotation_matrix = [V_2(1) V_3(1) V_1(1); V_2(2) V_3(2) V_1(2); V_2(3) V_3(3) V_1(3)]; % Creating the rotation matrix
    eulZYX = rotm2eul(Rotation_matrix); % Convert rotation matrix to Euler angles
    Angle_yaw(i,1) = eulZYX(1,1)*rad2degree;
    Angle_pitch(i,1) = eulZYX(1,2)*rad2degree;
    Angle_roll(i,1) = eulZYX(1,3)*rad2degree;        
end


RECENT POSTS