function [xc,yc] = camprofile(Ro,y,yp,theta) % % FUNCTION [xc,yc] = camprofile(Ro,y,yp,theta) % % This function finds the cam profile for a disk cam with an reciprocating % flat-face follower. It accepts the base circle radius Ro, vectors of y % and yp (all in displacement units), and cam angle theta (RAD). These % vectors should all correspond to a full cycle of cam rotation from 0 to % 2*PI. Obviously the smaller the stepsize the more accurate and smoother % the final plot of cam profile. % % Vectors xc and yc containing the coordinates of the cam profile are % returned. The cam profile points are generated so the follower axis is % vertical (i.e. pi/2 has been added to follower angle). % % NOTE: This function assumes the cam rotates CLOCKWISE. If your cam % rotates CCW you must make a very minor change to the equations. N = length(theta); % Find number of points in motion for i = 1:N xc(i) = (Ro+y(i))*cos(theta(i)+pi/2)+yp(i)*cos(theta(i)+pi); yc(i) = (Ro+y(i))*sin(theta(i)+pi/2)+yp(i)*sin(theta(i)+pi); end