コード例 #1
0
 private Vector AccelerationTowards( Planet otherPlanet )
 {
     var toOtherVector = otherPlanet.Position - this.Position;
     var distance = toOtherVector.Length;
     var accelerationSize = GravityConstant * otherPlanet.Mass / ( distance * distance );
     return toOtherVector / distance * accelerationSize;
 }
コード例 #2
0
 public void AccelerateTowards( Planet otherPlanet )
 {
     Velocity += AccelerationTowards( otherPlanet );
 }