Swinging pendulum

%swinging pendulum

P0  = [ 0; 0; 1 ];              % hinge centre
P1  = [ 0; -32.5; 1 ];          % rod end
rod = [ P0 P1 ];
t   = pi/2: pi/60: (5/2)*pi;    % parameter of disk curve
diskx = 2.5*cos(t); disky = 2.5*sin(t);
disk = [ diskx; disky; ones(size(t)) ];
% translate disk to point -35
ndisk = trlate(0, -35)*disk;
pendul = [ rod ndisk ];
plot(pendul(1, :), pendul(2, :)), axis(‘equal’)
hold on
% swing pendulum by 30 degrees
swinged = rtate(30)*pendul;
plot(swinged(1, :), swinged(2, :)), axis(‘equal’)