Example #1
0
 public static Newton ForceBetween(IPhysicalObject physicalObject, IPhysicalObject otherObject)
 {
     Meter distanceBetween = physicalObject.GetCoordinates<Meter>().DistanceFrom<Meter>(otherObject.GetCoordinates<Meter>());
     var distanceSquared = new Meter(System.Math.Pow(distanceBetween.Value, 2));
     var chargeProduct = physicalObject.GetCharge().Multiply(otherObject.GetCharge());
     return new Newton((CoulombsConstant.Multiply(chargeProduct).Divide(distanceSquared)).Value);
 }
Example #2
0
 // using Newton's Law of Universal Gravitation
 // http://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
 public static Newton GravityBetween(IPhysicalObject physicalObject, IPhysicalObject otherObject)
 {
     Meter distanceBetween = physicalObject.GetCoordinates<Meter>().DistanceFrom<Meter>(otherObject.GetCoordinates<Meter>());
     var distanceSquared = new Meter(System.Math.Pow(distanceBetween.Value, 2));
     var productOfMasses = (physicalObject.GetMass<Kilogram>()*otherObject.GetMass<Kilogram>());
     return new Newton(GravitationalConstant.Multiply((productOfMasses).Divide(distanceSquared)).Value);
 }