% ME 106/227 
% Spring Quarter 2002
% Script for Assignment #3 Problem 2
%
% Sample script for calculating the geometry of a double
% wishbone suspension as the vehicle rolls and plotting
% these results.  
%
% This script calls wishbone.m and draw_wishbone.m which, 
% in turn, call fourbart.m and fourbart4.m.  These two
% subroutines handle the four-bar linkage solution for the
% suspension geometry.  
%

% Step 1 - Enter the coordinates of the right side suspension
% link points on the car relative to the car center point 

% y and z values for upper control arm attachment point
ruarmyc = -45;
ruarmzc = 22;

% y and z values for lower control arm attachment point
rlarmyc = -33;
rlarmzc = -22;

% Step 2 - Enter the lengths of the suspension links

% Lower control arm
r2=39;

% Upper control arm
r4=19;


% Distance between the outboard ball joints
r3=50.6;

% Distance from lower ball joint to the tire contact point

r5 = 16.6;

% Step 3 - Enter the following values for plotting purposes

% Height and width of box used to represent car body
hcarbox = 50;
wcarbox = 100;

% Angle between tire vertical axis and kingpin axis
tirekpanglel = -9;
tirekpangler = 9;

% Scrub radius
scrubr = 2;

% Height and width of parallelogram used to represent tire
tireh = 61;
tirew = 21.5;
    
% Step 4 - Enter the height of the car center point and 
% the roll about that point then solve and plot  

carcenterroll = 0*pi/180;
zcarcenter = (44)*cos((pi/180)*carcenterroll);

% Solve for kinematics of the suspension

datavector = wishbone(ruarmyc,ruarmzc,rlarmyc,rlarmzc,r2,r3,r4,r5,zcarcenter,carcenterroll);

% Plot the suspension properties

draw_wishbone(datavector,hcarbox,wcarbox,tireh,tirew,scrubr,tirekpangler,tirekpanglel);

hold;

% This is now the place for you to calculate the roll
% center location and plot it on the same plot as the
% suspension geometry


% After you have finished with this, release the plot
hold;  