基本的に、私は大衆を作り、速度と勢いを与えました。そして、私は彼らの周りを周回軌道にしようとしています)を重力からの力を使って計算する。2つの大衆を互いの周りを公転しようとする...奇妙な誤差を得る
from visual import *
earth = sphere(radius = 100000000)
newPlanet = sphere(pos = (3.84403*10**8, 0, 0), radius = 10000000)
earth.velocity = vector(0, 100, 0)
newPlanet.velocity = vector(0, 100, 0)
earth.mass = 2*10**30
newPlanet.mass = 1*10**30
earth.p = vector(0, earth.mass*earth.velocity, 0)
newPlanet.p = vector(0, newPlanet.mass*newPlanet.velocity, 0)
dt = 1000
r = newPlanet.pos.x
T = 1.296*10**6
G = 6.673*10**-11
while 1:
Fnet = G*((earth.mass*newPlanet.mass)/r**2)
earth.p += Fnet*dt
newPlanet.p += Fnet*dt
earth.velocity += (earth.p/earth.mass)*dt
newPlanet.velocity += (newPlanet.p/newPlanet.mass)*dt
earth.pos += earth.velocity*dt
newPlanet.pos += newPlanet.velocity*dt
t += 1
rate(100)
これは私が取得していますエラーです:vpythonのドキュメントで、あなたの割り当てearth.p = vector(0, earth.mass*earth.velocity, 0)
でhere
を示すよう
Traceback (most recent call last):
File "Untitled", line 12
earth.p = vector(0, earth.mass*earth.velocity, 0)
Boost.Python.ArgumentError: Python argument types in
vector.__init__(vector, int, vector, int)
did not match C++ signature:
__init__(struct _object *, class cvisual::vector)
__init__(struct _object *)
__init__(struct _object *, double)
__init__(struct _object *, double, double)
__init__(struct _object *, double, double, double)
これにタグを付けたり、この「ビジュアル」モジュールがどこから来ているのかを示すコードにコメントをつけておくと、役に立つかもしれません。トレースバックに基づいて、私はそれがC++で書かれたバイナリ拡張モジュールだと推測します。それから私は、おそらく、Pythonからの大きな整数とおそらく、初期化子が呼び出されていると推測します。任意の精度整数に対する適切なサポートはありませんか? –
どういう意味ですか? –
@BobJohn:彼は、「ビジュアル」は何ですか?これはPythonの組み込みではありません。また、 'vector'に引数の順序が混在している可能性もあります。 –