我正在尝试建立一个太阳系的三维模拟,但是我很难找到这个2dpython代码的三维等价物
# Compute the force of attraction
f = G * self.mass * other.mass / (d**2)
# Compute the direction of the force.
theta = math.atan2(dy, dx)
fx = math.cos(theta) * f
fy = math.sin(theta) * f
return fx, fy
Tags:
二维码的效率低得离谱。你根本不需要三角学。它只是把力的大小乘以(dx,dy)方向的单位向量。假设你已经知道向量的长度,
d
,你所需要的就是在三维中
相关问题 更多 >
编程相关推荐