当else运行并且距离<= 250时,if继续运行而else运行
好的,你的意思是 distance <=250 那么 的 下一个 强> 转身 distance>250
distance <=250
distance>250
这种情况发生在计算出的速度/覆盖距离过高且火箭穿过火星到达另一侧远远超过250(或火箭进入火星内?)之后 时间 ,这意味着你必须改变
y_pos = initial_y_pos - ((vel_y * time) - ((gravity * time)/2)); x_pos = initial_x_pos + ((vel_x * time) - ((gravity * time)/2)); ... distance = sqrt(pow((y_pos-(y+312)),2)+(pow((x_pos-(x+440)),2))); mars_dist = sqrt(pow((y_pos-150),2)+pow((x_pos-1150),2));
如果太高,在这种情况下降低速度/覆盖距离。或者可能是速度/覆盖距离是正确的但火箭到达地面或火星的距离小于 时间 ,所以新的位置是不正确和不可能的,因为假设火箭可以越过火星表面,你必须检测到这种情况。