% EXTRA DEMO:   POSITION OF A BICYCLE STEM VS TIME
%
% Program:      bicycle_wheel.m
% Written by:   
% For:          EE 311
%               Extra Demo Computer Lab 2
% Date:         7-3-2001
% Purpose:      This program plots the motion of a bike stem vs. time
%               using the idea of a rotating phasor
clear all, close all

j=sqrt(-1);
w=2*pi;						% omega = pi radians per second
r=5;						% radius of 5 meters
t=0:2*pi/(100*w):6*pi/w; 	% show 6*pi/w worth of seconds
							% 3 rotations of the tire
ot=ones(1,length(t));       % ones vector for element by element
                            % addition of vectors

% Position of the axle at time t
z1=r*w*t+j*r*ot;

% The stem represented as a rotating phasor
z2=r*exp(-j*w*t);

% The position of the stem is represented by the sum of the two equations
z=z1+z2;
figure
plot(real(z),imag(z))
hold on
grid
title('Plot of the Position of a Bike Tire Stem vs. Time Using Rotating Phasors')

% The same plot is generated using parametric equations
x=r*(w*t+cos(w*t));
y=r*(1*ot-sin(w*t));
figure
plot(x,y)
hold on
grid
title('Plot of the Position of a Bike Tire Stem vs. Time Using Parametric Equations')
