无法在 VPyhton (GlowScript) 中添加标量和向量错误

Cannot add scalar and a vector error in VPyhton (GlowScript)

我正在 GlowScript 中使用 VPython 实现一个太阳系。现在我在 运行 时收到此错误:错误无法添加标量和向量。我想我做对了。我必须用 pos 改变什么吗? ?

代码如下:

GlowScript 2.7 VPython
from visual import *

scene = display(width = 800, height = 800, center = vec(0,0.5,0))

#sun
sonne = sphere(pos = vec (0,0,0), radius=8, color = color.orange, shininess=1)

#earth
erde = sphere(pos = vec (50,0,0), radius=1.5, color = color.blue, make_trail=True)

erdeV = vector(0,0,5)

#masses
erdeM = 5.97*10**24
sonneM = 1.989*10**30

#Grav-constant
G = 6.67259*10**-11

for i in range (1000):
    rate(1000)
    erde.pos = erde.pos + erdeV

    #distance
    entfernung = sqrt(erde.pos.y**2 + erde.pos.z**2)


    #Gravitational law F = G * m * M / r*r --> G*s*e/AE*AE ae=Astr. Einheit
    Fgrav = G *( erdeM * sonneM) / (entfernung*entfernung)
    erdeV = erdeV + Fgrav
    erde.pos += erdeV

    if entfernung <= sonne.radius: break

问题行:

Fgrav = G *( erdeM * sonneM) / (entfernung*entfernung)
erdeV = erdeV + Fgrav

Fgrav 这里是标量(重力强度),而 erdeV 是矢量。要解决此问题,请包括力的方向:

Fgrav = (-G * (erdeM * sonneM) / (entfernung ** 3)) * erde.pos
erdeV = erdeV + Fgrav