Ejemplo n.º 1
0
 public function systemEnergyAt($distance)
 {
     $energy = '0';
     foreach ($this->stars as $star) {
         $energy = $this->math->add($energy, $star->getEnergyPerMeterAt($distance));
     }
     return $energy;
 }
Ejemplo n.º 2
0
 public function matchBest($value, $pos = 9)
 {
     if ($pos > 6 && $pos < 12) {
         if ($value < 1) {
             $newVal = MathProvider::multiply($value, $this->scale);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * 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');
 }
Ejemplo n.º 4
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())));
 }
Ejemplo n.º 5
0
 /**
  * @param Quantity[] $mults
  * @param Quantity[] $divides
  */
 public static function naiveMultiOpt($mults, $divides, $precision = 2)
 {
     $newUnit = self::getMultiUnits($mults, $divides);
     $newVal = 1;
     foreach ($mults as $quantity) {
         $newVal = MathProvider::multiply($newVal, $quantity->toNative()->getValue());
     }
     foreach ($divides as $quantity) {
         $newVal = MathProvider::divide($newVal, $quantity->toNative()->getValue(), $precision);
     }
     return $newUnit->preConvertedAdd($newVal);
 }
Ejemplo n.º 6
0
 public function convert($value, $from, $to)
 {
     return MathProvider::divide(MathProvider::multiply($value, $this->getConversionRate($from)), $this->getConversionRate($to));
 }
Ejemplo n.º 7
0
 /**
  * Surface gravity in meters per second squared
  *
  * @return string
  */
 public function getSurfaceGravity()
 {
     return $this->math->divide($this->math->multiply($this->mass, self::$GRAVITATION), $this->math->exp($this->radius, '2'), 2);
 }