> |
veer:=proc(x1,y1,x2,y2,n,f,time)
local kappa,lambda,theta,A,B,C,D,h,a,b,c,SIM,i,spring_static,g,k,X1,X2,Y1,Y2:
kappa:=2*n;
#_____________________________________________________
spring_static:=proc(x1,x2,y1,y2,n,h)
NumericEventHandler(division_by_zero=proc(operator,operands,defVal): infinity end proc);
lambda:=sqrt((x1-x2)**2+(y1-y2)**2)/kappa;
theta:=arctan((y1-y2)/(x1-x2));
if (evalf(x1)>= evalf(x2) and evalf(y1)>= evalf(y2) and evalf(theta) >=0) then theta:=theta+Pi;end if:
if (evalf(x1)>= evalf(x2) and evalf(y1)<=evalf(y2) and evalf(theta) <=0)then theta:=theta+Pi;end if:
a[5]:=[x1,y1];
a[4]:=[x1,y1],[x1+(lambda/2)*cos(theta),y1+(lambda/2)*sin(theta)];
a[8]:=[x1+(lambda/2)*cos(theta),y1+(lambda/2)*sin(theta)],[x1+(lambda)*cos(theta)-h*sin(theta),y1+(lambda)*sin(theta)+h*cos(theta)];
a[7]:=[x2-(lambda)*cos(theta)-h*sin(theta),y2-(lambda)*sin(theta)+h*cos(theta)],[x2-(lambda/2)*cos(theta),y2-(lambda/2)*sin(theta)];
a[6]:=[x2-(lambda/2)*cos(theta),y2-(lambda/2)*sin(theta)],[x2,y2];
a[3]:=[x2,y2];
A:=seq(line([x1+(3+2*i)*lambda*cos(theta)-h*sin(theta),y1+(3+2*i)*lambda*sin(theta)+h*cos(theta)],[x1+2*(i+1)*lambda*cos(theta)+h*sin(theta),y1+2*(i+1)*lambda*sin(theta)-h*cos(theta)]),i=0..(n-2)/2-1);B:=line(a[4]),line(a[8]),line(a[6]),line(a[7]);
C:=pointplot(a[3],thickness=4),pointplot(a[5],thickness=4);
D:=
seq(line([x1+(1+2*i)*lambda*cos(theta)-h*sin(theta),y1+(1+2*i)*lambda*sin(theta)+h*cos(theta)], [x1+2*(i+1)*lambda*cos(theta)+h*sin(theta),y1+2*(i+1)*lambda*sin(theta)-h*cos(theta)]),i=0..(n- 2)/2-1);
display(A,B,C,D,scaling=constrained);
end proc:
#_____________________________________________________
X1:=unapply(x1,x):
X2:=unapply(x2,x):
Y1:=unapply(y1,x):
Y2:=unapply(y2,x):
#_____________________________________________________
SIM:=[];
for i from 0 to time do
SIM:=[op(SIM),spring_static(X1(i),X2(i),Y1(i),Y2(i),kappa,f)]:
end do:
#_____________________________________________________
display(SIM,insequence=true,axes=none,scaling=constrained);
end proc: |