Exemplo n.º 1
0
 /**
  * Creates a new Cartesian vector instance
  *
  * @param Frame           $frame Reference frame
  * @param Epoch|AstroDate $epoch Observation epoch
  * @param Distance        $x     x position
  * @param Distance        $y     y position
  * @param Distance $z     z position
  * @param Velocity $vx    x velocity
  * @param Velocity $vy    y velocity
  * @param Velocity $vz    z velocity
  */
 public function __construct(Frame $frame, $epoch, Distance $x, Distance $y, Distance $z, Velocity $vx = null, Velocity $vy = null, Velocity $vz = null)
 {
     // Set reference frame and observation epoch
     $this->frame = $frame;
     $this->epoch = $epoch instanceof Epoch ? $epoch : $epoch->toEpoch();
     // Set position components
     $this->x = $x;
     $this->y = $y;
     $this->z = $z;
     // Set velocity components
     $this->vx = $vx;
     $this->vy = $vy;
     $this->vz = $vz;
     // Set default rounding and units
     $this->decimalPlaces = 13;
 }
Exemplo n.º 2
0
 /**
  * Converts this instance to an AstroDate instance
  * @return AstroDate
  */
 public function toDate()
 {
     if ($this->dt) {
         return $this->dt;
     } else {
         return AstroDate::jd($this->jd, TimeScale::TT());
     }
 }
Exemplo n.º 3
0
 /**
  * Finds the accurate time of a solstice or equinox using the complete VSOP87
  * theory
  *
  * @param int   $year  The year to find a solstice or equinox for
  * @param array $terms An array of the mean terms for the desired equinox or
  *                     solstice
  * @param int   $month The month of the equinox or solstice to find
  *
  * @return float The JD of the solstice or equinox in TD
  */
 private static function accurate($year, array $terms, $month)
 {
     $Y = $year < 1000 ? (int) $year / 1000 : ((int) $year - 2000) / 1000;
     $q = intval($month / 3) - 1;
     $jde0 = static::Horner($Y, $terms);
     for ($i = 0; $i < 100; $i++) {
         // TODO:: use vsop 87, but use IAU apparent stuff?
         $λ = Solar::ApparentEclVSOP87(AstroDate::fromJD($jde0))->λ->rad;
         $Δ = 58 * sin(deg2rad($q * 90) - $λ);
         $jde0 += $Δ;
         if (abs($Δ) < 5.0E-7) {
             break;
         }
     }
     return $jde0;
 }
Exemplo n.º 4
0
 /**
  * @covers Marando\AstroDate\Epoch::toDate
  */
 public function testToDate()
 {
     $dt = Epoch::J2000()->toDate();
     $expected = AstroDate::jd(2451545.0, TimeScale::TT());
     $this->assertEquals($expected->toJD(), $dt->toJD());
 }