CS代考计算机代写 fprintf( ‘————————————- ’ );

fprintf( ‘————————————-
’ );
fprintf( ‘Q 1
’ );
fprintf( ‘————————————-
’ );

a = [ 0 0 1 ]’;
b = [ 1 0 1 ]’;
c = [ 0 1 1 ]’;

S_y2 = [ 1 0 0; 0 2 0; 0 0 1 ];
T_IfromABC = S_y2;
fprintf( ‘T_IfromABC (homogenous):
’)
fprintf( ‘%5.2f %5.2f %5.2f
’, (T_IfromABC)’ );
fprintf( ‘
’)

% Scale y=2 followed by R(180) and Translate by x = 1 and y = 2
R_180 = [ cos(pi) -sin(pi) 0; sin(pi) cos(pi) 0; 0 0 1 ];
T_x1y2 = [ 1 0 1; 0 1 2; 0 0 1];
T_IIfromABC = T_x1y2 * R_180 * S_y2;
fprintf( ‘T_IIfromABC (homogenous):
’)
fprintf( ‘%5.2f %5.2f %5.2f
’, (T_IIfromABC)’ );
fprintf( ‘
’)

fprintf( ‘————————————-
’ );
fprintf( ‘Q 2
’ );
fprintf( ‘————————————-
’ );

fprintf( ‘Q 2.1
’ );

a = [ -5 4 6 1 ]’;

theta = 30/180*pi;

R_x30 = [ 1 0 0 0;
0 cos(theta) sin(theta) 0;
0 -sin(theta) cos(theta) 0;
0 0 0 1 ];
T_x1y3z_2 = [ 1 0 0 1;
0 1 0 3;
0 0 1 -2;
0 0 0 1 ];
T_trans = T_x1y3z_2 * R_x30;
fprintf( ‘T_object (homogenous):
’)
fprintf( ‘%5.2f %5.2f %5.2f %5.2f
’, (T_trans)’ );
fprintf( ‘
’)
a_trans = T_trans * a;
aCartesian = a_trans(1:3)/a_trans(4);
fprintf( ‘a_trans:
’)
fprintf( ‘[ %5.2f %5.2f %5.2f ]^T
’, aCartesian );
fprintf( ‘
’)

fprintf( ‘Q 2.2
’ );

theta = 90/180*pi;

R_z90 = [ cos(theta) -sin(theta) 0 0;
sin(theta) cos(theta) 0 0;
0 0 1 0;
0 0 0 1 ];
T_x_2y_2z1 = [ 1 0 0 -2;
0 1 0 -2;
0 0 1 1;
0 0 0 1 ];

F_0in2 = R_z90 * T_x_2y_2z1;

R_transpose = F_0in2(1:3,1:3)’;
F_2from0 = [ R_transpose, -R_transpose*F_0in2(1:3,4);
0 0 0 1 ];
fprintf( ‘Inverse frame transform F_2from0 (homogenous):
’)
fprintf( ‘%5.2f %5.2f %5.2f %5.2f
’, (F_2from0)’ );
fprintf( ‘
’)
org_trans = F_2from0(1:3,4);
fprintf( ‘Origin with F_2from0:
’)
fprintf( ‘[ %5.2f %5.2f %5.2f ]^T
’, org_trans );
fprintf( ‘

’)
clear all;

fprintf( ‘————————————-
’ );
fprintf( ‘Q 3
’ );
fprintf( ‘————————————-
’ );

% Using object transform
% Naming the blocks from lower left to upper right
% 4 5 6
% 3
% 1 2
% Pick the lower-left-front as origin of coordinate system. Orientation
% as shown for the cube x to the right, y up and z out of the paper

% scale in y by 2
T_0from1 = [ 1 0 0 0;
0 2 0 0;
0 0 1 0;
0 0 0 1 ];
fprintf( ‘Scale in y by 2 (homogenous) T_0from1 =
’)
fprintf( ‘%5.2f %5.2f %5.2f %5.2f
’, (T_0from1)’ );
fprintf( ‘
’)

% scale in y by 2 and translate 2 over
T_0from2 = [ 1 0 0 2;
0 2 0 0;
0 0 1 0;
0 0 0 1 ];
fprintf( ‘Scale in y by 2 and translate 2 over (homogenous) T_0from2 =
’)
fprintf( ‘%5.2f %5.2f %5.2f %5.2f
’, (T_0from2)’ );
fprintf( ‘
’)

% Scale in x by 3 and translate 2 up
T_0from3 = [ 3 0 0 0;
0 1 0 2;
0 0 1 0;
0 0 0 1 ];
fprintf( ‘Scale in x by 3 and translate 2 up (homogenous) T_0from3 =
’)
fprintf( ‘%5.2f %5.2f %5.2f %5.2f
’, (T_0from3)’ );
fprintf( ‘
’)

% Scale in y by 1.5 and translate 4.5 up, 0.5 right and 0.5 in
T_0from4 = [ 1 0 0 0.5;
0 1.5 0 4.5;
0 0 1 -0.5;
0 0 0 1 ];
fprintf( ‘Scale in y by 1.5 and translate 4.5 up and 0.5 right and in
’ )
fprintf( ‘T_0from4 =
’)
fprintf( ‘%5.2f %5.2f %5.2f %5.2f
’, (T_0from4)’ );
fprintf( ‘
’)

% Scale in y by 2 move 1 right and 3 up
T_0from5 = [ 1 0 0 1;
0 2 0 3;
0 0 1 0;
0 0 0 1 ];
fprintf( ‘Scale in y by 2 and translate 1 right and 3 up
’ )
fprintf( ‘T_0from5 =
’)
fprintf( ‘%5.2f %5.2f %5.2f %5.2f
’, (T_0from5)’ );
fprintf( ‘
’)

% Scale in y by 1.5 and translate 4.5 up, 2.5 right and 0.5 in
T_0from6 = [ 1 0 0 2.5;
0 1.5 0 4.5;
0 0 1 -0.5;
0 0 0 1 ];
fprintf( ‘Scale in y by 1.5 and translate 4.5 up, 2.5 right and 0.5 in
’ )
fprintf( ‘T_0from6 =
’)
fprintf( ‘%5.2f %5.2f %5.2f %5.2f
’, (T_0from6)’ );
fprintf( ‘
’)

Leave a Reply

Your email address will not be published. Required fields are marked *