Rotation VPython对象旋转

Rotation VPython对象旋转,rotation,translate-animation,vpython,Rotation,Translate Animation,Vpython,目前必须使用VPython,我想做一个太阳系的模型 目前我有所有的行星和轨道环,然而,实际的轨道是我发现非常困难的 GlowScript 2.7 VPython from visual import * # Declaring Celestial Body Objects Sun = sphere(pos = vec(0, 0, 0), radius = 10, color = color.yellow) Mercury = sphere(pos = vec(25

目前必须使用VPython,我想做一个太阳系的模型

目前我有所有的行星和轨道环,然而,实际的轨道是我发现非常困难的

GlowScript 2.7 VPython
from visual import *



# Declaring Celestial Body Objects
Sun     = sphere(pos =     vec(0, 0, 0), radius =   10, color = color.yellow)
Mercury = sphere(pos =    vec(25, 0, 0), radius =    2, color =  color.green)
Venus   = sphere(pos =    vec(40, 0, 0), radius =  2.5, color =    color.red)
Earth   = sphere(pos =    vec(50, 0, 0), radius = 2.65, color =   color.blue)
Mars    = sphere(pos =    vec(70, 0, 0), radius =  2.3, color =    color.red)
Jupiter = sphere(pos =    vec(90, 0, 0), radius =    3, color = color.orange)
Saturn  = sphere(pos =   vec(105, 0, 0), radius =  2.9, color = color.orange)
Uranus  = sphere(pos = vec(117.5, 0, 0), radius =  2.9, color = color.orange)
Neptune = sphere(pos =   vec(135, 0, 0), radius =  2.8, color =   color.blue)
Pluto   = sphere(pos =   vec(165, 0, 0), radius =  1.5, color =  color.white)



# Declaring Orbital Rings of Celestial Body Objects
Mercury.ring = ring(pos = vec(0, 0, 0), axis = vec(0, 1, 0), size = vec(0.1, Mercury.pos.x * 2, Mercury.pos.x * 2))
Venus.ring   = ring(pos = vec(0, 0, 0), axis = vec(0, 1, 0), size = vec(0.1, Venus.pos.x * 2, Venus.pos.x * 2))
Earth.ring   = ring(pos = vec(0, 0, 0), axis = vec(0, 1, 0), size = vec(0.1, Earth.pos.x * 2, Earth.pos.x * 2))
Mars.ring    = ring(pos = vec(0, 0, 0), axis = vec(0, 1, 0), size = vec(0.1, Mars.pos.x * 2, Mars.pos.x * 2))
Jupiter.ring = ring(pos = vec(0, 0, 0), axis = vec(0, 1, 0), size = vec(0.1, Jupiter.pos.x * 2, Jupiter.pos.x * 2))
Saturn.ring  = ring(pos = vec(0, 0, 0), axis = vec(0, 1, 0), size = vec(0.1, Saturn.pos.x * 2, Saturn.pos.x * 2))
Uranus.ring  = ring(pos = vec(0, 0, 0), axis = vec(0, 1, 0), size = vec(0.1, Uranus.pos.x * 2, Uranus.pos.x * 2))
Neptune.ring = ring(pos = vec(0, 0, 0), axis = vec(0, 1, 0), size = vec(0.1, Neptune.pos.x * 2, Neptune.pos.x * 2))
Pluto.ring   = ring(pos = vec(0, 0, 0), axis = vec(0, 1, 0), size = vec(0.1, Pluto.pos.x * 2, Pluto.pos.x * 2))



# Infinite Loop
while 1 == 1:

    Mercury.rotate(angle = radians(360), axis = vec(Mercury.pos.y, Mercury.pos.x, 0), origin = vec(0, 0, 0))
    rate(50)

print("Error! Escaped While Loop!")
当我用
Mercury.rotate(角度=0.0174533,轴=vec(0,Mercury.pos.x,0),原点=vec(0,0,0))关闭旋转方法时,
,它正确地旋转。。。但只有四分之一的轮换。我已经阅读了所有与此有关的内容,但不适用

四分之一公转后,当角度较大时,行星有时会决定猛烈地“攫取”。这似乎是某种障碍。

您应该编写axis=vec(0,1,0)。旋转轴必须始终指向上