Matlab Code for Peek a Bear
function [projfourbar] = projfourbar(theta2,guessL4,guesstheta3)
L1=96;
L2=13;
L3=68;
theta2=theta2*pi/180;
theta4=115*pi/180;
guesstheta3=guesstheta3*pi/180;
options = optimset('Display','off');
function F = root2d(x)
F = [L2*cos(theta2)+L3*cos(x(2))+x(1)*cos(theta4); L2*sin(theta2)+L3*sin(x(2))+x(1)*sin(theta4)-L1];
end
x0 = [guessL4,guesstheta3];
x = fsolve(@root2d,x0,options);
x(2)=x(2)*180/pi;
projfourbar=x;
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
clear all
high=360;
theta2=linspace(0,high,200);
x=projfourbar(0,44,100);
L4(1)=x(1);
theta3(1)=x(2);
for n=2:length(theta2)
x=projfourbar(theta2(n),L4(n-1),theta3(n-1));
L4(n)=x(1);
theta3(n)=x(2);
end
linklength=56-L4;
linklength=linklength-min(linklength);
%%%
L5=20;
Lm=15;
for n=1:length(linklength)
theta5(n)=atan(linklength(n)/L5);
mouthopen(n)=2*Lm*sin(theta5(n));
height(n)=33-linklength(n); %finding angle of arm
thetaArm(n)=atan(height(n)/12);
LengthArmExposed(n)=35-sqrt(height(n)^2+144);
handpos(n)=50*cos(thetaArm(n))+35*cos(thetaArm(n)+pi/2); %finding x position of hand
end
for n=1:length(handpos)
distance(n)=2*(handpos(n)-min(handpos));
end
figure
hold on
plot(theta2,linklength)
title('Exposed Length of Neck')
xlabel('Input Angle (degrees)')
xlim([0 high])
ylabel('Length (mm)')
hold off
figure
hold on
plot(theta2,mouthopen)
title('How Open the Mouth is')
xlabel('Input Angle (degrees)')
xlim([0 high])
ylabel('Width of Mouth (mm)')
hold off
figure
hold on
plot(theta2,distance)
title('Distance Between Hands')
xlabel('Input Angle (degrees)')
xlim([0 high])
ylabel('Distance (mm)')
hold off
%end of program
Welcome to the University Wiki Service! Please use your IID (yourEID@eid.utexas.edu) when prompted for your email address during login or click here to enter your EID. If you are experiencing any issues loading content on pages, please try these steps to clear your browser cache.