The next problem that i forsee is that I am unable to come up with a way to stear the car so that it can do donuts. I really dont want to resort to taking out the momentum and position update for one of the front wheels because i feel as thought that would be somehow cheating. Any ideas on this part of my problem would be very welcome as well.
from visual import*
from visual.graph import*
lfM=sphere(pos=(0,2.46,0),mom=vector(0,0,0),radius=.25,color=color.red,mass=251.748)
rfM=sphere(pos=(1.2,2.46,0),mom=vector(0,0,0),radius=.25,color=color.red,mass=251.748)
lbM=sphere(pos=(0,0,0),mom=vector(0,0,0),radius=.25,color=color.red,mass=428.652)
rbM=sphere(pos=(1.2,0,0),mom=vector(0,0,0),radius=.25,color=color.red,mass=428.652)
eRf=(rfM.pos-lfM.pos)#equilibrium lengths of all the springs
eRl=(lfM.pos-lbM.pos)
eRr=(rfM.pos-rbM.pos)
eRb=(rbM.pos-lbM.pos)
k=1e12#k of springs connecting masses
Fw=16589.4#force wheels
lost=.2#the amount of force lost by the tires spinning
Fwr=Fw/2 #amount of force actually translated to the road per wheel but I took out the lost force to see if could model #the correct 0-60 time of a porche
dt=.00001
t=0
while t<20:
Rf=(rfM.pos-lfM.pos)#new vectors of all the springs
Rl=(lfM.pos-lbM.pos)
Rr=(rfM.pos-rbM.pos)
Rb=(rbM.pos-lbM.pos)
vRf=norm(Rf-norm(Rf)*mag(eRf))#normal vectors in the orientation of current vectors
vRl=norm(Rl-norm(Rl)*mag(eRl))
vRr=norm(Rr-norm(Rr)*mag(eRr))
vRb=norm(Rb-norm(Rb)*mag(eRb))
xRf=mag(Rf)-mag(eRf)#change in length to figure out spring force
xRl=mag(Rl)-mag(eRl)
xRr=mag(Rr)-mag(eRl)
xRb=mag(Rb)-mag(eRb)
FsRf=k*xRf*norm(Rf)
FsRl=k*xRl*norm(Rl)
FsRr=k*xRr*norm(Rr)
FsRb=k*xRb*norm(Rb)
FlfM=FsRf-FsRl#forces by the springs on the masses
FrfM=-FsRr-FsRf
FlbM=FsRl+FsRb
FrbM=FsRr-FsRb
FwlbM=Fwr*norm(Rl)#direction of force of wheels
FwrbM=Fwr*norm(Rr)
NlfM=FlfM#Net forces on each object
NrfM=FrfM
NlbM=FlbM+FwlbM
NrbM=FrbM+FwrbM
lfM.mom=lfM.mom+NlfM*dt
lfM.pos=lfM.pos+lfM.mom/lfM.mass*dt
rfM.mom=rfM.mom+NrfM*dt
rfM.pos=rfM.pos+rfM.mom/rfM.mass*dt
lbM.mom=lbM.mom+NlbM*dt
lbM.pos=lbM.pos+lbM.mom/lbM.mass*dt
rbM.mom=rbM.mom+NrbM*dt
rbM.pos=rbM.pos+rbM.mom/rbM.mass*dt
#position and momentum updates
vCM=mag(lfM.mom+rfM.mom+lbM.mom+rbM.mom)/(lfM.mass+rfM.mass+lbM.mass+rbM.mass)
print vCM
print t
t=t+dt
This post has been edited by andrewsw: 08 December 2013 - 03:37 PM
Reason for edit:: Fixed code tags

New Topic/Question
Reply


MultiQuote



|