Tag: 物理学

轨道力学

有没有人有一个实施轨道力学的例子(最好是在XNA中)? 我目前使用的代码如下,但它执行时并没有“感觉正确”。 物体只是稍微向地球弯曲,无论我调整多少变量,我都无法进入轨道,甚至是部分轨道。 shot.Position += shot.Velocity; foreach (Sprite planet in planets) { Vector2 directionToPlanet = (planet.Position – shot.Position); directionToPlanet.Normalize(); float distance = Vector2.DistanceSquared(shot.Position, planet.Position); float gPull = (float)(planet.gravityStrength * (planet.Mass * shot.Mass) / distance) + planet.gravityField; shot.Position += new Vector2(directionToPlanet.X * gPull, directionToPlanet.Y * gPull); } 编辑标记Mendelt的答案是正确的,指出我需要更新速度,而不是位置。 我还需要将gPull的计算更改为 float gPull = shot.Mass * planet.Mass / […]

实施弹丸运动

我已经在互联网上搜索了很多有用的信息,但他们是数学网站试图告诉我如何解决一个对象到达y位置的角度。 但是,我正在尝试运行模拟,并且没有找到可以实现代码来模拟抛物线的任何实体方程。 那些具有一定物理知识的人可以帮助我吗?