function [M]=trajectory3(x,y,z,pitcher,roll,yaw,scale_factor,step,selector,varargin);
% operate trajectory2(x,y,z,pitcher,roll,yaw,scale_factor,step,[selector,SoR])
%
%
% x,y,z center mechanical phenomenon (vector) [m]
%
% pitcher,roll,yaw euler\'s angles [rad]
%
% issue|multiplier|multiplier factor} standardisation factor [scalar]
% (related to body craft dimension)
%
% step angle sampling issue [scalar]
% (the points variety between 2 body models)
%
% chooseor select the body model [string]
%
% gripen JAS thirty-nine Gripen heli chopper
% mig Mig ah64 Apache chopper
% Felis catus Tomcat(Default) a10
% jet Generic jet cessna Cessna
% 747 Boeing 747 airplane Generic airplane
% md90 MD90 jet shuttle space vehicle
% dc10 DC-10 jet
%
% elective INPUT:
%
%
% read sets the camera read. Use Matlab\'s \"viewer\" as argument to reprocess this
read.
%
% Note:
%
% Refernce System:
% X body- The axial force on the X body axis is
% positive on forward; the momentum around X body
% is positive roll clockwise as viewered from behind;
% Y body- The facet force on the Y body axis is
% positive on the correct wing; the instant around Y
% body is positive in pitcher up;
% Z body- the conventional force on the Z body axis is
% positive down; the instant around Z body is positive
% roll clockwise as viewered from higher than.
%
% *******************************
% operate Version three.0
% 7/08/2004 (dd/mm/yyyy)
% Valerio Scordamaglia
% v.scordamaglia@tiscali.it
% *******************************
if nargin<9
disp(\' Wrong:\');
disp(\' Wrong: Invalid variety Inputs!\');
M=0;
return;
end
if (len(x)~=len(y))|(len(x)~=len(z))|(len(y)~=len(z))
disp(\' Wrong:\');
disp(\' Uncorrect Dimension of the middle mechanical phenomenon Vectors. Please Check
the size\');
M=0;
return;
end
if ((len(pitcher)~=len(roll))||(len(pitcher)~=len(yaw))||(len(roll)~=len(yaw)))
disp(\' Wrong:\');
disp(\' Uncorrect Dimension of the euler\'\'s angle Vectors. Please Check the size\');
M=0;
return;
end
if len(pitcher)~=len(x)
disp(\' Wrong:\');
disp(\' Size match between euler\'\'s angle vectors and center mechanical phenomenon
vectors\');
M=0;
return
end
if step>=len(x)
disp(\' Wrong:\');
disp(\' angle samplig reckon of vary. scale back step\');
M=0;
return
end
if step<1
step=1;
end
if nargin==10
theViewer=cell2mat(varargin(1));
end
if nargin>10
disp(\'Too several inputs arguments\');
M=0;
return
end
if nargin<10
theViewer=[82.50 2];
end
mov=nargout;
cur_dir=pwd;
if strcmp(selector,\'shuttle\')
load shuttle;
V=[-V(:,2) V(:,1) V(:,3)];
V(:,1)=V(:,1)-round(sum(V(:,1))/size(V,1));
V(:,2)=V(:,2)-round(sum(V(:,2))/size(V,1));
V(:,3)=V(:,3)-round(sum(V(:,3))/size(V,1));
elseif strcmp(selector,\'helicopter\')
load helicopter;
V=[-V(:,2) V(:,1) V(:,3)];
V(:,1)=V(:,1)-round(sum(V(:,1))/size(V,1));
V(:,2)=V(:,2)-round(sum(V(:,2))/size(V,1));
V(:,3)=V(:,3)-round(sum(V(:,3))/size(V,1));
elseif strcmp(selector,\'747\')
load boeing_747;
V=[V(:,2) V(:,1) V(:,3)];
V(:,1)=V(:,1)-round(sum(V(:,1))/size(V,1));
V(:.
function [M]=trajectory3(x,y,z,pitcher,roll,yaw,scale_factor,step,se.pdf
1. function [M]=trajectory3(x,y,z,pitcher,roll,yaw,scale_factor,step,selector,varargin);
% operate trajectory2(x,y,z,pitcher,roll,yaw,scale_factor,step,[selector,SoR])
%
%
% x,y,z center mechanical phenomenon (vector) [m]
%
% pitcher,roll,yaw euler's angles [rad]
%
% issue|multiplier|multiplier factor} standardisation factor [scalar]
% (related to body craft dimension)
%
% step angle sampling issue [scalar]
% (the points variety between 2 body models)
%
% chooseor select the body model [string]
%
% gripen JAS thirty-nine Gripen heli chopper
% mig Mig ah64 Apache chopper
% Felis catus Tomcat(Default) a10
% jet Generic jet cessna Cessna
% 747 Boeing 747 airplane Generic airplane
% md90 MD90 jet shuttle space vehicle
% dc10 DC-10 jet
%
% elective INPUT:
%
%
% read sets the camera read. Use Matlab's "viewer" as argument to reprocess this
read.
%
% Note:
%
% Refernce System:
% X body- The axial force on the X body axis is
% positive on forward; the momentum around X body
2. % is positive roll clockwise as viewered from behind;
% Y body- The facet force on the Y body axis is
% positive on the correct wing; the instant around Y
% body is positive in pitcher up;
% Z body- the conventional force on the Z body axis is
% positive down; the instant around Z body is positive
% roll clockwise as viewered from higher than.
%
% *******************************
% operate Version three.0
% 7/08/2004 (dd/mm/yyyy)
% Valerio Scordamaglia
% v.scordamaglia@tiscali.it
% *******************************
if nargin<9
disp(' Wrong:');
disp(' Wrong: Invalid variety Inputs!');
M=0;
return;
end
if (len(x)~=len(y))|(len(x)~=len(z))|(len(y)~=len(z))
disp(' Wrong:');
disp(' Uncorrect Dimension of the middle mechanical phenomenon Vectors. Please Check
the size');
M=0;
return;
end
if ((len(pitcher)~=len(roll))||(len(pitcher)~=len(yaw))||(len(roll)~=len(yaw)))
disp(' Wrong:');
disp(' Uncorrect Dimension of the euler''s angle Vectors. Please Check the size');
M=0;
return;
end
if len(pitcher)~=len(x)
disp(' Wrong:');
disp(' Size match between euler''s angle vectors and center mechanical phenomenon
3. vectors');
M=0;
return
end
if step>=len(x)
disp(' Wrong:');
disp(' angle samplig reckon of vary. scale back step');
M=0;
return
end
if step<1
step=1;
end
if nargin==10
theViewer=cell2mat(varargin(1));
end
if nargin>10
disp('Too several inputs arguments');
M=0;
return
end
if nargin<10
theViewer=[82.50 2];
end
mov=nargout;
cur_dir=pwd;
if strcmp(selector,'shuttle')
load shuttle;
V=[-V(:,2) V(:,1) V(:,3)];
V(:,1)=V(:,1)-round(sum(V(:,1))/size(V,1));
V(:,2)=V(:,2)-round(sum(V(:,2))/size(V,1));
V(:,3)=V(:,3)-round(sum(V(:,3))/size(V,1));
elseif strcmp(selector,'helicopter')
load helicopter;
V=[-V(:,2) V(:,1) V(:,3)];
6. eval(['load ' selector ';']);
V(:,1)=V(:,1)-round(sum(V(:,1))/size(V,1));
V(:,2)=V(:,2)-round(sum(V(:,2))/size(V,1));
V(:,3)=V(:,3)-round(sum(V(:,3))/size(V,1));
catch
str=strcat('Warning: ',selector,' not found. Default=A-10');
disp(str);
load A-10;
V=[V(:,3) V(:,1) V(:,2)];
end
end
correction=max(abs(V(:,1)));
V=V./(scale_factor*correction);
ii=len(x);
resto=mod(ii,step);
%%%%%%%%%%%%%%%needed for the transformation%%%%%%%%%%%%%%%
y=y;
z=z;
pitcher=pitcher;
roll=roll;
yaw=-yaw;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
frame = 0;
for i=1:step:(ii-resto)
if mov | (i == 1)
clf;
plot3(x,y,z);
grid on;
hold on;
light;
end
theta=pitcher(i);
phi=-roll(i);
psi=yaw(i);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7. %%%%%%%%%%%%%%%%
Tbe=[cos(psi)*cos(theta), -sin(psi)*cos(theta), sin(theta);
cos(psi)*sin(theta)*sin(phi)+sin(psi)*cos(phi) ...
-sin(psi)*sin(theta)*sin(phi)+cos(psi)*cos(phi) ...
-cos(theta)*sin(phi);
-cos(psi)*sin(theta)*cos(phi)+sin(psi)*sin(phi) ...
sin(psi)*sin(theta)*cos(phi)+cos(psi)*sin(phi) ...
cos(theta)*cos(phi)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%
Vnew=V*Tbe;
rif=[x(i) y(i) z(i)];
X0=repmat(rif,size(Vnew,1),1);
Vnew=Vnew+X0;
p=patch('faces', F, 'vertices' ,Vnew);
set(p, 'facec', [1 0 0]);
set(p, 'EdgeColor','none');
if mov | (i == 1)
viewer(theViewer);
axis equal;
end
if mov
if i == 1
ax = axis;
else
axis(ax);
end
lighting phong
frame = frame + 1;
M(frame) = getframe;
end
end
Solution
function [M]=trajectory3(x,y,z,pitcher,roll,yaw,scale_factor,step,selector,varargin);
8. % operate trajectory2(x,y,z,pitcher,roll,yaw,scale_factor,step,[selector,SoR])
%
%
% x,y,z center mechanical phenomenon (vector) [m]
%
% pitcher,roll,yaw euler's angles [rad]
%
% issue|multiplier|multiplier factor} standardisation factor [scalar]
% (related to body craft dimension)
%
% step angle sampling issue [scalar]
% (the points variety between 2 body models)
%
% chooseor select the body model [string]
%
% gripen JAS thirty-nine Gripen heli chopper
% mig Mig ah64 Apache chopper
% Felis catus Tomcat(Default) a10
% jet Generic jet cessna Cessna
% 747 Boeing 747 airplane Generic airplane
% md90 MD90 jet shuttle space vehicle
% dc10 DC-10 jet
%
% elective INPUT:
%
%
% read sets the camera read. Use Matlab's "viewer" as argument to reprocess this
read.
%
% Note:
%
% Refernce System:
% X body- The axial force on the X body axis is
% positive on forward; the momentum around X body
% is positive roll clockwise as viewered from behind;
% Y body- The facet force on the Y body axis is
9. % positive on the correct wing; the instant around Y
% body is positive in pitcher up;
% Z body- the conventional force on the Z body axis is
% positive down; the instant around Z body is positive
% roll clockwise as viewered from higher than.
%
% *******************************
% operate Version three.0
% 7/08/2004 (dd/mm/yyyy)
% Valerio Scordamaglia
% v.scordamaglia@tiscali.it
% *******************************
if nargin<9
disp(' Wrong:');
disp(' Wrong: Invalid variety Inputs!');
M=0;
return;
end
if (len(x)~=len(y))|(len(x)~=len(z))|(len(y)~=len(z))
disp(' Wrong:');
disp(' Uncorrect Dimension of the middle mechanical phenomenon Vectors. Please Check
the size');
M=0;
return;
end
if ((len(pitcher)~=len(roll))||(len(pitcher)~=len(yaw))||(len(roll)~=len(yaw)))
disp(' Wrong:');
disp(' Uncorrect Dimension of the euler''s angle Vectors. Please Check the size');
M=0;
return;
end
if len(pitcher)~=len(x)
disp(' Wrong:');
disp(' Size match between euler''s angle vectors and center mechanical phenomenon
vectors');
M=0;
10. return
end
if step>=len(x)
disp(' Wrong:');
disp(' angle samplig reckon of vary. scale back step');
M=0;
return
end
if step<1
step=1;
end
if nargin==10
theViewer=cell2mat(varargin(1));
end
if nargin>10
disp('Too several inputs arguments');
M=0;
return
end
if nargin<10
theViewer=[82.50 2];
end
mov=nargout;
cur_dir=pwd;
if strcmp(selector,'shuttle')
load shuttle;
V=[-V(:,2) V(:,1) V(:,3)];
V(:,1)=V(:,1)-round(sum(V(:,1))/size(V,1));
V(:,2)=V(:,2)-round(sum(V(:,2))/size(V,1));
V(:,3)=V(:,3)-round(sum(V(:,3))/size(V,1));
elseif strcmp(selector,'helicopter')
load helicopter;
V=[-V(:,2) V(:,1) V(:,3)];
V(:,1)=V(:,1)-round(sum(V(:,1))/size(V,1));
V(:,2)=V(:,2)-round(sum(V(:,2))/size(V,1));