# Demo entry 6360926

matlab

Submitted by anonymous on May 03, 2017 at 03:35
Language: Matlab. Code size: 1.7 kB.

```e=input('Collision factor = ');
mball=input('Mass of ball = ');
mc=input('Mass of c (from waist to knee) = ');
md=input('Mass of d (from knee to foot) = ');
cabs=input('Length of c = ');
dabs=input('Length of d = ');
theta1=input('Angle of c to horizon = ');
theta2=input('Angle of d to horizon = ');
dtheta1abs=input('Angular velocity of c = ');
dtheta2abs=input('Angular velocity of d = ');

dtheta1=[0,0,dtheta1abs];
dtheta2=[0,0,dtheta2abs];
c=[cabs*cos(theta1),cabs*sin(theta1),0];
d=[dabs*cos(theta2),dabs*sin(theta2),0];
vc=cross(dtheta1,c);
vd=vc+cross(dtheta2,d);

h1g=[0,0,mc*cabs^2/12*dtheta1abs];
h2g=[0,0,md*dabs^2/12*dtheta2abs];

syms dtheta1absprime dtheta2absprime vball cx cy bx by rball
f1 = norm(cross([0,0,dtheta1absprime],c)+cross([0,0,dtheta2absprime],d))-vball==-norm(vd)*e;
f2 = rball-mball*vball==0;
f3 = md.*(vc+cross(dtheta2,[dabs*cos(theta2)/2,dabs*sin(theta2)/2,0]))+[-rball*sin(theta2),rball*cos(theta2),0]+[cx,cy,0]-md.*(cross([0,0,dtheta1absprime],c)+cross([0,0,dtheta2absprime],[dabs*cos(theta2)/2,dabs*sin(theta2)/2,0]));
f4 = h2g+cross([dabs/2*cos(theta2),dabs/2*sin(theta2),0],[cx,cy,0])+cross([dabs/2*cos(theta2),dabs/2*sin(theta2),0],[-rball*sin(theta2),rball*cos(theta2),0])-[0,0,md*dabs^2/12*dtheta2absprime]==0;
f5 = mc.*cross(dtheta1,c/2)+[-cx+bx,-cy+by,0]-mc.*cross([0,0,dtheta1absprime],cross(dtheta1,c/2))==0;
f6 = h1g+cross([cabs/2*cos(theta1),cabs/2*sin(theta1),0],[-cx,-cy,0])+cross([cabs/2*cos(theta1),cabs/2*sin(theta1),0],[bx,by,0])-[0,0,mc*cabs^2/12*dtheta1absprime]==0;

sol=solve([f1,f2,f3,f4,f5,f6],[bx,by,cx,cy,dtheta1absprime,dtheta2absprime,rball,vball]);
rballSol=sol.rball
vballSol=sol.vball
```

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.