Hey guys im stuck on this problem, if you could explain what you do so i can get
ID: 3210376 • Letter: H
Question
Hey guys im stuck on this problem, if you could explain what you do so i can get an understanding of it that would be great. Cheers
Rotation matrices. Rotation matrices are useful when you have a vector in 2 or 3 dimensions that must be rotated around some central pivot point. Lsin(?) cos(8) where (xo, yo) is a position vector that defines the initial position of a point, (x, yi) is a position vector defining the final location of the point and ? is the angle of rotation. Rotating rods: Consider two rods lying on a 2D plane and fused to each other at one end (Bo) with the angle betweern the rods given by 0, . The first rod is attached to a small motor that rotates the first rod by ?2 radians (and by extension the second rod as well).Explanation / Answer
part 1. MATLAB code
function B1 = Rot(B1,t) % Rot for rotation & arguments: position B0 and time t
clear all;
tht2 = sin(2*t/pi); % defining formula for angle theta2
R = [cos(tht2) , -sin(tht2); sin(tht2), cos(tht2)]; % Defining Rotation matrix
B1 = (R * (B0)')'; % R acting on B0 transpose
end
part 2. MATLAB code
function [B1, C0, C1] = Rot(B0, t, L, tht1) %Rot for rotation & arguments:
position B0, time t , Length L and angle theta1
clear all;
tht2 = sin(2*t/pi); % definjng formula for angle theta2
R = [cos(tht2) , -sin(tht2); sin(tht2), cos(tht2)]; % Defining Rotation matrix
B1 = (R * (B0))'; % R acting on B0 transpose
C0 = B0 + [L*cos(pi - tht1) , L*sin(pi - tht1)];
tht3 = (pi-tht1)+tht2; % inclination of link B1C1 with the horizontal
C1 = B1 + [L*cos(tht3) , L*sin(tht3)];
end
part 3. MATLAB code
[Note: We need to take L=1, B0=[1,0] and theta1=2*pi/3 ]
function [B1, C0, C1] = Rot(B0, t, L, tht1) %Rot for rotation & arguments: position B0, time t , Length L and angle theta1
clear all;
tht2 = sin(2*t/pi); % definjng formula for angle theta2
R = [cos(tht2) , -sin(tht2); sin(tht2), cos(tht2)]; % Defining Rotation matrix
B1 = R * (B0)'; % R acting on B0 transpose
C0 = B0 + [L*cos(pi - tht1) , L*sin(pi - tht1)];
plot(B0(1),B0(2), 'ko');
grid on;
xlim([0,2*L]);
ylim([0,2*L]);
hold on;
plot(B1(1), B1(2),'bo');
plot(C0(1), C0(2),'ko');
plot(C1(1),C1(2),'bo');
% filling the space between points with lines
plot([0,B0(1)],[0,B0(2)],'k','linewidth',2);
plot([0,B1(1)],[0,B1(2)],'b','linewidth',2);
plot([C0(1),B0(1)],[C0(2),B0(2)],'k','linewidth',2);
plot([C1(1),B1(1)],[C1(2),B1(2)],'b','linewidth',2);
end
Note: The angle theta1 or the inclination between the two links w.r.t each other will always be constant irrespective of the angle theta2 by which link 1 is rotated.
Observation: The angle theta1 increases till time t= 2 secs and goes on decreasing after time t= 3 secs. Thus the links rotated in anti-clockwise direction till t=2 secs but then again move in clockwise direction after t =3secs