得到正確的長度這裏是我的代碼:鋼瓶不Vpython
from vpython import *
from math import *
import numpy as np
from __future__ import division
stick = cylinder()
stick.pos = vec(0,5,-15)
stick.axis = vec(0,1,0)
stick.length = 30
stick.radius = 0.75
stick.color = vec(.5,.5,.8)
scene.forward = vec(-1,-1,-2)
scene.range = 15
spheres = []
for i in range (0, 15):
s = sphere()
s.radius = 1.5
s.theta_0 = -0.5
s.period = 75/(50+i)
s.color = color.hsv_to_rgb(vec(i/15, 0.75,0.9))
s.wire = cylinder()
s.wire.color = s.color
s.wire.pos = stick.pos + vec(0,0,i+0.5)*stick.length/15
s.wire.axis = vec(0,-1,0)
s.wire.length = 2*np.pi*9.81*s.period*s.period
s.wire.radius = 0.1
spheres.append(s)
dt = 0.2
t = 0
while True:
rate(1/dt)
for i in range(0, len(spheres)):
s = spheres[i]
theta = s.theta_0 * cos(2*pi*t/s.period)
s.wire.axis = vec(np.sin(theta),-np.cos(theta),0)
s.pos = s.wire.pos + s.wire.axis*s.wire.length
t = t + dt
我希望做一個跳舞擺。但是,應該將球體連接到棒上的導線長度不正確。我如何使電線長度正確?