Project 1 Robotics 1 - Mechanics ENGR 6411: Function
Project 1 Robotics 1 - Mechanics ENGR 6411: Function
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];