Ejemplo n.º 1
0
        public Vector3 AttractionFrom(Body bodyB)
        {
            //gravitation
            var dir = bodyB.Location - Location;
            var distance = MathHelper.Clamp(dir.Length, 5f, 20);
            var strength = (G * Mass * bodyB.Mass) / (distance * distance);

            return strength * dir.Normalized();
        }
Ejemplo n.º 2
0
 public Vector3 Drag(Body b)
 {
     var p = b.Location;
     if (!Bounds.Contains(p.X, p.Y, p.Z))
     {
         return Vector3.Zero;
     }
     float speed = b.Velocity.Length;
     if (0.01f > speed) return Vector3.Zero;
     float dragMagnitude = DragCoefficient * speed * speed;
     var drag = -b.Velocity;
     drag /= speed;
     drag *= dragMagnitude;
     return drag;
 }