示例#1
0
文件: Ship.php 项目: JordanRL/eden
 /**
  * This method returns the time, in days, to get to a target using conventional thrust. Possible units:
  *
  * - AU (Astronomical Units)
  * - km (kilometers)
  * - m (meters)
  * - ly (light years)
  *
  * @param $distance
  * @param $unit
  * @return Time
  */
 protected function getTimeToDistance($distance, $unit = 'AU')
 {
     $distance = new Length($distance, $unit);
     $distance->preConvertedSubtract(MathProvider::divide($distance->getValue(), 2, 2));
     $acceleration = $this->getAcceleration();
     $time = PhysicsProvider::timeFromConstantAccel($distance, $acceleration);
     $time->preConvertedAdd($time->getValue());
     return $time->to('d');
 }
示例#2
0
 /**
  * @param Length       $distance
  * @param Acceleration $acceleration
  *
  * @return Time
  */
 public static function timeFromConstantAccel(Length $distance, Acceleration $acceleration)
 {
     $distance->toNative();
     $acceleration->toNative();
     return new Time(MathProvider::squareRoot(MathProvider::multipleMultiply(2, $distance->getValue(), $acceleration->getValue())));
 }