开发者

RK4 in 2D gravity simulation probs

In actionscript 3.0, I have two objects (a central red star and a orbiting blue planet). I want to use RK4 to plot the orbit. I'm running the simulation once per frame, and drawing once per frame. I have to relate the position of the blue planet in x,y to the central planet so I may be getting lost in the conversion somewhere. This is just for the 1,1 quadrant. I will be adjusting the gravity vector as the blue planet crosses from quadrant to quadrant.

PROBLEM: If I alter the time step, the orbit c开发者_如何学JAVAhanges drastically. At small time steps, the orbit becomes a straight line. At large time steps, the orbit becomes tighter. The cooefficients for computing the acceleration for each "K" are not being scaled by dt (except for it being passed through the previous velocity vector).

Here is the RK4 code snip:

http://pastebin.com/Ee6HzBQ2

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜