- #1
jrgoodin
- 2
- 0
This is what I have, and for some reason it won't move...I trust all you smart people could point me in the right direction...thanks
from visual import *
from visual.graph import *
relaxedlength = vector(.60,0,0) # length of spring when it isn't stretched or compressed
spring = helix(pos=(-.75,0,0),axis=relaxedlength, radius=.1,coils=8,thickness=.01,color=color.green)
spring.constant = 25 # k
weight = box(pos=(0,0,0),size=(.3,.3,.3),color=color.yellow)
weight.mass = 10 # kg
weight.velocity = vector(.30,0,0)
weight.acceleration = vector(.01,0,0)
weight.force = vector(0.3,0,0)
frictionlessSurface = box(size=(2,.02,.5),pos=(0,-.16,0))
wall = box(size=(.04,.5,.3),pos=(-.77,.1,0),color=color.red)
spring.displacement = weight.pos # the weight starts at (0,0,0) and is attached to spring
spring.axis = relaxedlength + spring.displacement
dt = .01 # seconds
t = 0 # total time
while 1:
rate(100)
t += dt
# Calculate the spring force using Hooke's Law
spring.force = -spring.constant * spring.displacement
# The spring force acts on the weight
weight.force = spring.force
# calculate the new spring displacement
spring.displacement = weight.pos
# update the length of the spring
spring.axis = relaxedlength + spring.displacement
from visual import *
from visual.graph import *
relaxedlength = vector(.60,0,0) # length of spring when it isn't stretched or compressed
spring = helix(pos=(-.75,0,0),axis=relaxedlength, radius=.1,coils=8,thickness=.01,color=color.green)
spring.constant = 25 # k
weight = box(pos=(0,0,0),size=(.3,.3,.3),color=color.yellow)
weight.mass = 10 # kg
weight.velocity = vector(.30,0,0)
weight.acceleration = vector(.01,0,0)
weight.force = vector(0.3,0,0)
frictionlessSurface = box(size=(2,.02,.5),pos=(0,-.16,0))
wall = box(size=(.04,.5,.3),pos=(-.77,.1,0),color=color.red)
spring.displacement = weight.pos # the weight starts at (0,0,0) and is attached to spring
spring.axis = relaxedlength + spring.displacement
dt = .01 # seconds
t = 0 # total time
while 1:
rate(100)
t += dt
# Calculate the spring force using Hooke's Law
spring.force = -spring.constant * spring.displacement
# The spring force acts on the weight
weight.force = spring.force
# calculate the new spring displacement
spring.displacement = weight.pos
# update the length of the spring
spring.axis = relaxedlength + spring.displacement