%% Animate Pose Using poseplot
% Animate a series of poses using the poseplot function. First, define the initial and final positions.

ps = [0 0 0];
pf = [10 0 0];

% Then, define the initial and final orientations using the quaternion object.

qs = quaternion([45,0,0],'eulerd','ZYX','frame');
qf = quaternion([-45,0,0],'eulerd','ZYX','frame');

% Show the starting pose.

patch = poseplot(qs,ps);
ylim([-2 2])
xlim([-2 12])
xlabel("North-x (m)")
ylabel("East-y (m)")
zlabel("Down-z (m)");

%
% Change the position and orientation continuously using coefficients, and update the pose using the set object function.

for coeff = 0:0.01:1
    q = slerp(qs,qf,coeff);
    position = ps + (pf - ps)*coeff;
    set(patch,Orientation=q,Position=position); 
    drawnow
end

% Copyright 2020 The MathWorks, Inc.