为了更好地理解矢量是如何工作的,我正在尝试创建一个非常简单的地球绕太阳运行的模拟。目前,我只想让地球绕太阳转一圈。没有考虑任何物理定律。
我认为我正在做的事情会奏效,但是它创造了某种进入斐波那契螺旋的运动。
// initial positions
vec2 sun(0.0,0.0);
vec2 earth(10.0,0.0);
while(true) {
vec2 earthToSun = normalize(sun - earth); // this is the vector 'pointing from the earth towards the sun'
vec2 speedVector = vec2(-earthToSun.y, earthToSun.x); // this is the vector perpendicular to the earthToSun vector
earth = earth + earthToSun + speedVector; // move the earth along the resulting vector
}
我的计算出了什么问题?