0% found this document useful (0 votes)
69 views2 pages

Project 1 Robotics 1 - Mechanics ENGR 6411: Function

This MATLAB program generates rotational matrices using the Z-Y-X Euler angle method. It takes in three rotation angles as inputs around the z, y, and x axes and calculates the overall rotation matrix. It then visualizes the rotations by plotting the changing coordinate axes in 3D as each subsequent rotation is applied. The program is useful for modeling rotational transformations in 3 dimensions.

Uploaded by

diablo999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views2 pages

Project 1 Robotics 1 - Mechanics ENGR 6411: Function

This MATLAB program generates rotational matrices using the Z-Y-X Euler angle method. It takes in three rotation angles as inputs around the z, y, and x axes and calculates the overall rotation matrix. It then visualizes the rotations by plotting the changing coordinate axes in 3D as each subsequent rotation is applied. The program is useful for modeling rotational transformations in 3 dimensions.

Uploaded by

diablo999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Project 1

Robotics 1 - Mechanics
ENGR 6411
This program can be use to generate rotational matrix for rotation about Cartesian coordinate system at any initial condition. Here method use to calculate rotation matrix is
Z-Y-X Euler angles calculation method.
This package developed in MATLAB software. File name is rotmax, below are the
codes (program) of this package.
MATLAB program
1. Program to generate rotation matrix
2. Program for visualization by plotting graphs for each and every rotation
function [Rxyz] = rotmax(theta,gamar,alphar)
%This program uses ZYX Euler angles method to generate rotation matrix
%rotmax to generate rotational matrix for rotations
%call syntax;
%[Rxyz] = rotmax(thetar,gamar,alphar)
%--------------------------------------------thetar = input('Enter rotation angle about z axis: ');
gamar = input('Enter rotation angle about y axis: ');
alphar = input('enter rotation angle about x axis: ');
% to change the angles to radians from degrees
theta = thetar*pi/180;
gama = gamar*pi/180;
alpha = alphar*pi/180;
%rotational matrix for rotation around z axis
Rz = [cos(theta) -sin(theta) 0;sin(theta) cos(theta) 0;0 0 1];
Ry = [cos(gama) 0 sin(gama);0 1 0;-sin(gama) 0 cos(gama)];
Rx = [1 0 0;0 cos(alpha) -sin(alpha);0 sin(alpha) cos(alpha)];
% according to Euler's method we can calculate the rota\tional
% matrix Rzyx
Rzyx = Rz*Ry*Rx
%animation of the rotation
%for graph initial condition can be shown in vector form
x=[1; 0 ;0];
y=[0; 1 ;0];
z=[0; 0 ;1];
%after first rotation nex axis can be found (x1,y1,z1)
x1=Rz*x;
y1=Rz*y;
z1=Rz*z;
%after second rotation intermediate matrix Ry2
Ry2 = Ry*[x1,y1,z1];
%new axis system after second rotation (x2,y2,z2)
x2=Ry2*x;
y2=Ry2*y;
z2=Ry2*z;
%after third rotation corresponding rotational matrix
Rx2=Rx*[x2,y2,z2];

%new axis system with respect to last rotation


x3=Rx2*x;
y3=Rx2*y;
z3=Rx2*z;
a=0:pi/100:2*pi;
% Three graphs can be plot for each rotation as per changes of the
% axes system. it will visualize rotation.
% figure (1) shows the rotation around Z axis
figure (1)
plot3(a.*x1(1),a.*x1(2),a.*x1(3),'green')
hold on
plot3(a.*y1(1),a.*y1(2),a.*y1(3),'blue')
hold on
plot3(a.*z1(1),a.*z1(2),a.*z1(3),'yellow ')
hold on
% figure (2) shows the rotation around y axis
figure (2)
plot3(a.*x2(1),a.*x2(2),a.*x2(3),'green')
hold on
plot3(a.*y2(1),a.*y2(2),a.*y2(3),'blue')
hold on
plot3(a.*z2(1),a.*z2(2),a.*z2(3),'yellow ')
hold on
% figure (3) shows the rotation around x axis
figure (3)
plot3(a.*x3(1),a.*x3(2),a.*x3(3),'green')
hold on
plot3(a.*y3(1),a.*y3(2),a.*y3(3),'blue')
hold on
plot3(a.*z3(1),a.*z3(2),a.*z3(3),'yellow ')
hold on

You might also like