Example #1
0
 public function draw_getexy($a, $b, $d)
 {
     $d = deg2rad($d);
     $arrayXY = array(round($a * Cos($d)), round($b * Sin($d)));
     //var_dump($arrayXY);
     return $arrayXY;
 }
function toGps($x, $y, $h = 0)
{
    global $kon;
    $y = ($y - 500000) / 0.9999;
    $x = (1 * $x + 5000000) / 0.9999;
    // 1*x  !!!!!!!!!!!
    $ab = 1 * $kon['bessel_a'] + 1 * $kon['bessel_b'];
    $fi0 = 2 * $x / $ab;
    $dif = 1.0;
    $p1 = $kon['bessel_a'] * (1 - $kon['bessel_e2']);
    $n = 25;
    while (abs($dif) > 0 && $n > 0) {
        $L = $p1 * ($kon['A'] * $fi0 - $kon['B'] * sin(2 * $fi0) + $kon['C'] * sin(4 * $fi0) - $kon['D'] * sin(6 * $fi0) + $kon['E'] * sin(8 * $fi0));
        $dif = 2 * ($x - $L) / $ab;
        $fi0 = $fi0 + $dif;
        $n--;
    }
    $N = $kon['bessel_a'] / sqrt(1 - $kon['bessel_e2'] * pow(sin($fi0), 2));
    $t = tan($fi0);
    $t2 = pow($t, 2);
    $t4 = pow($t2, 2);
    $cosFi = cos($fi0);
    $ni2 = $kon['bessel_e2_'] * pow($cosFi, 2);
    $lambda = 0.261799387799149 + $y / ($N * $cosFi) - (1 + 2 * $t2 + $ni2) * pow($y, 3) / (6 * pow($N, 3) * $cosFi) + (5 + 28 * $t2 + 24 * $t4) * pow($y, 5) / (120 * pow($N, 5) * $cosFi);
    $fi = $fi0 - $t * (1 + $ni2) * pow($y, 2) / (2 * pow($N, 2)) + $t * (5 + 3 * $t2 + 6 * $ni2 - 6 * $ni2 * $t2) * pow($y, 4) / (24 * pow($N, 4)) - $t * (61 + 90 * $t2 + 45 * $t4) * pow($y, 6) / (720 * pow($N, 6));
    $N = $kon['bessel_a'] / sqrt(1 - $kon['bessel_e2'] * pow(Sin($fi), 2));
    $X = ($N + $h) * cos($fi) * cos($lambda);
    $Y = ($N + $h) * cos($fi) * sin($lambda);
    $Z = ($kon['bessel_b2'] / $kon['bessel_a2'] * $N + $h) * sin($fi);
    $X -= $kon['dX'];
    $Y -= $kon['dY'];
    $Z -= $kon['dZ'];
    $X /= 1 + $kon['dm'];
    $Y /= 1 + $kon['dm'];
    $Z /= 1 + $kon['dm'];
    $X1 = $X - $kon['M0'][1] * $Y - $kon['M0'][2] * $Z;
    $Y1 = -1 * $kon['M1'][0] * $X + $Y - $kon['M1'][2] * $Z;
    $Z1 = -1 * $kon['M2'][0] * $X - $kon['M2'][1] * $Y + $Z;
    $p = sqrt(pow($X1, 2) + pow($Y1, 2));
    $O = atan2($Z1 * $kon['wgs84_a'], $p * $kon['wgs84_b']);
    $SinO = sin($O);
    $Sin3O = pow($SinO, 3);
    $CosO = cos($O);
    $Cos3O = pow($CosO, 3);
    $fif = atan2($Z1 + $kon['wgs84_e2_'] * $kon['wgs84_b'] * $Sin3O, $p - $kon['wgs84_e2'] * $kon['wgs84_a'] * $Cos3O);
    $lambdaf = atan2($Y1, $X1);
    $N = $kon['wgs84_a'] / sqrt(1 - $kon['wgs84_e2'] * pow(sin($fif), 2));
    $hf = $p / cos($fif) - $N;
    $fif = $fif * 180 / pi();
    $lambdaf = $lambdaf * 180 / pi();
    $retVal = array($fif, $lambdaf, $hf);
    return $retVal;
}
function getSunTimes($fh, $La, $Lo, $mois, $jour)
{
    $returnArray = array("sunrise" => null, "sunset" => null);
    if ($fh == "") {
        $fh = date("H") - gmdate("H");
    }
    if ($La == "") {
        $La = 48.833;
    }
    if ($Lo == "") {
        $Lo = -2.333;
    }
    if ($mois == "") {
        $mois = date("m");
    }
    if ($jour == "") {
        $jour = date("d");
    }
    // Fuseau horaire et coordonnées géographiques
    $k = 0.0172024;
    $jm = 308.67;
    $jl = 21.55;
    $e = 0.0167;
    $ob = 0.4091;
    $PI = 3.1415926536;
    //Hauteur du soleil au lever et au coucher
    $dr = $PI / 180;
    $hr = $PI / 12;
    $ht = -40 / 60;
    $ht = $ht * $dr;
    $La = $La * $dr;
    $Lo = $Lo * $dr;
    //Date
    if ($mois < 3) {
        $mois = $mois + 12;
    }
    //Heure TU du milieu de la journée
    $h = 12 + $Lo / $hr;
    //Nombre de jours écoulés depuis le 1 Mars O h TU
    $J = floor(30.61 * ($mois + 1)) + $jour + $h / 24 - 123;
    //Anomalie et longitude moyenne
    $M = $k * ($J - $jm);
    $L = $k * ($J - $jl);
    //Longitude vraie
    $S = $L + 2 * $e * Sin($M) + 1.25 * $e * $e * Sin(2 * $M);
    //Coordonnées rectangulaires du soleil dans le repère équatorial
    $X = Cos($S);
    $Y = Cos($ob) * Sin($S);
    $Z = Sin($ob) * Sin($S);
    //Equation du temps et déclinaison
    $R = $L;
    $rx = Cos($R) * $X + Sin($R) * $Y;
    $ry = -Sin($R) * $X + Cos($R) * $Y;
    $X = $rx;
    $Y = $ry;
    $ET = atan($Y / $X);
    $DC = atan($Z / Sqrt(1 - $Z * $Z));
    //Angle horaire au lever et au coucher
    $cs = (Sin($ht) - Sin($La) * Sin($DC)) / Cos($La) / Cos($DC);
    $CalculSol = "";
    if ($cs > 1) {
        $CalculSol = "Ne se lève pas";
    }
    if ($cs < -1) {
        $CalculSol = "Ne se couche pas";
    }
    if ($cs == 0) {
        $ah = $PI / 2;
    } else {
        $ah = atan(Sqrt(1 - $cs * $cs) / $cs);
    }
    if ($cs < 0) {
        $ah = $ah + $PI;
    }
    //Lever du soleil
    $Pm = $h + $fh + ($ET - $ah) / $hr;
    if ($Pm < 0) {
        $Pm = $Pm + 24;
    }
    if ($Pm > 24) {
        $Pm = $Pm - 24;
    }
    $hs = floor($Pm);
    $Pm = floor(60 * ($Pm - $hs));
    if (strlen($hs) < 2) {
        $hs = "0" . $hs;
    }
    if (strlen($Pm) < 2) {
        $Pm = "0" . $Pm;
    }
    if ($CalculSol == "") {
        $lev = $hs . ":" . $Pm;
    } else {
        $lev = "00:00";
    }
    //Coucher du soleil
    $Pm = $h + $fh + ($ET + $ah) / $hr;
    if ($Pm > 24) {
        $Pm = $Pm - 24;
    }
    if ($Pm < 0) {
        $Pm = $Pm + 24;
    }
    $hs = floor($Pm);
    $Pm = floor(60 * ($Pm - $hs));
    if (strlen($hs) < 2) {
        $hs = "0" . $hs;
    }
    if (strlen($Pm) < 2) {
        $Pm = "0" . $Pm;
    }
    if ($CalculSol == "") {
        $couch = $hs . ":" . $Pm;
    } else {
        $couch = "00:00";
    }
    $returnArray["sunrise"] = date("d/M/y G:i:s", strtotime($lev));
    $returnArray["sunset"] = date("d/M/y G:i:s", strtotime($couch));
    $returnArray["sunrise"] = DateTime::createFromFormat('H:i', $lev);
    $returnArray["sunset"] = DateTime::createFromFormat('H:i', $couch);
    return $returnArray;
}
Example #4
0
 /**
  * 求角度$d对应的椭圆上的点坐标,$a为横轴长,$b为纵轴长。
  * 先通过百分比得到弧度,再通过得到的弧度得出终点坐标。
  * 最后将图形画上去。
  * @param  [type] $a [椭圆横轴长]
  * @param  [type] $b [椭圆纵轴长]
  * @param  [type] $d [要画的弧度]
  * @return [type]    [反回弧度终点的坐标]
  */
 public function draw_getexy($a, $b, $d)
 {
     $d = deg2rad($d);
     return array(round($a * Cos($d)), round($b * Sin($d)));
 }
Example #5
0
<?php

$obrazek = imagecreatetruecolor(600, 600);
$white = imagecolorallocate($obrazek, 255, 255, 255);
$black = imagecolorallocate($obrazek, 0, 0, 0);
$red = imagecolorallocate($obrazek, 255, 0, 0);
$green = imagecolorallocate($obrazek, 0, 255, 0);
$blue = imagecolorallocate($obrazek, 0, 0, 255);
imagefilledrectangle($obrazek, 0, 0, 600, 600, $white);
imageline($obrazek, 300, 0, 300, 600, $black);
imageline($obrazek, 0, 300, 600, 300, $black);
for ($i = 0; $i <= 600; $i = $i + 20) {
    imageline($obrazek, $i, 297, $i, 303, $black);
    imageline($obrazek, 297, $i, 303, $i, $black);
}
for ($i = -600; $i < 600; $i += 0.01) {
    $y = Sin($i * (M_PI / 180)) * 50;
    imagesetpixel($obrazek, 300 + $i, 300 - $y, $black);
}
header("Content-type:image/jpeg");
imagejpeg($obrazek);
imagedestroy($obrazek);
Example #6
0
function getArcCords($cords, $start, $end, $dir, $prev_lat = 0, $prev_lon = 0)
{
    $start = modulo($start, 360);
    $end = modulo($end, 360);
    $out = "";
    $out2 = "";
    $angularDistance = $cords[2] / 6371000;
    $count = 0;
    if ($dir < 0) {
        $total_angle = -($end - $start);
    } else {
        $total_angle = $end - $start;
    }
    $total_angle = modulo($total_angle, 360);
    if ($total_angle == 0) {
        $total_angle = 360;
    }
    for ($i = $start; $count <= 48; $i += $dir * $total_angle / 48) {
        //$out.= "$i";
        $bearing = deg2rad($i);
        $lat = Asin(Sin($cords[0]) * Cos($angularDistance) + Cos($cords[0]) * Sin($angularDistance) * Cos($bearing));
        $dlon = Atan2(Sin($bearing) * Sin($angularDistance) * Cos($cords[0]), Cos($angularDistance) - Sin($cords[0]) * Sin($lat));
        $lon = fmod($cords[1] + $dlon + M_PI, 2 * M_PI) - M_PI;
        $latOut = rad2deg($lat);
        $lonOut = rad2deg($lon);
        $out .= encode($latOut - $prev_lat) . encode($lonOut - $prev_lon);
        $out2 .= "{$lonOut},{$latOut},0 ";
        $prev_lat = $latOut;
        $prev_lon = $lonOut;
        $count++;
    }
    return array($out, $out2);
}
Example #7
0
 /**
  * @param $coord
  * @return string
  */
 public function get_circle_cords($coord)
 {
     $out = "";
     $angularDistance = $coord->radius / 6378137;
     $center_lat = deg2rad($coord->lat);
     $center_lon = deg2rad($coord->lon);
     for ($i = 0; $i <= 360; $i++) {
         $bearing = deg2rad($i);
         $lat = Asin(Sin($center_lat) * Cos($angularDistance) + Cos($center_lat) * Sin($angularDistance) * Cos($bearing));
         $dlon = Atan2(Sin($bearing) * Sin($angularDistance) * Cos($center_lat), Cos($angularDistance) - Sin($center_lat) * Sin($lat));
         $lon = fmod($center_lon + $dlon + M_PI, 2 * M_PI) - M_PI;
         $latOut = rad2deg($lat);
         $lonOut = rad2deg($lon);
         $out .= $lonOut . ',' . $latOut . ',' . 0 . ' ';
     }
     return $out;
 }
Example #8
0
function _effect_distort($image, $factor = 40, $grad = 1, $method = 0)
{
    // from http://www.codeproject.com/aspnet/CaptchaNET_2.asp Farshid Hosseini
    $width = imagesx($image);
    $height = imagesy($image);
    $fact = $factor / 25;
    $disx = rand(4, 10) * (rand(0, 1) ? 1 : -1) * $fact;
    $disy = rand(4, 12) * (rand(0, 1) ? 1 : -1) * $fact;
    $yf = rand(30, 45) * $fact;
    $xf = rand(80, 95) * $fact;
    // from http://www.captcha.ru/captchas/multiwave/
    // KCAPTCHA randomize
    // periods
    $rand1 = mt_rand(750000, 1200000) / 10000000;
    $rand2 = mt_rand(750000, 1200000) / 10000000;
    $rand3 = mt_rand(750000, 1200000) / 10000000;
    $rand4 = mt_rand(750000, 1200000) / 10000000;
    // phases
    $rand5 = mt_rand(0, 31415926) / 10000000;
    $rand6 = mt_rand(0, 31415926) / 10000000;
    $rand7 = mt_rand(0, 31415926) / 10000000;
    $rand8 = mt_rand(0, 31415926) / 10000000;
    // amplitudes
    $rand9 = mt_rand(330, 420) / 110;
    $rand10 = mt_rand(330, 450) / 110;
    // make new canvas img
    $canvas = imagecreate($width, $height);
    $bgcolor = imagecolorsforindex($image, 0);
    $new = imagecolorallocate($canvas, $bgcolor['red'], $bgcolor['green'], $bgcolor['blue']);
    $fgcolor = imagecolorsforindex($image, 1);
    $new = imagecolorallocate($canvas, $fgcolor['red'], $fgcolor['green'], $fgcolor['blue']);
    imagepalettecopy($canvas, $image);
    for ($y = 0; $y < $height; $y++) {
        for ($x = 0; $x < $width; $x++) {
            if (empty($method)) {
                // Adds a simple wave
                $newX = $x + $disx * Sin(3.141592 * $y / $xf);
                $t = ($x - $width / 2) / $yf * 2.4;
                $t = $t * $t;
                $newY = $y + $disy * exp(-$t) * sin(3.141592 * $x / $yf);
            } else {
                // KCAPTCHA method
                $newX = $x + (sin($x * $rand1 + $rand5) + sin($y * $rand3 + $rand6)) * $rand9;
                $newY = $y + (sin($x * $rand2 + $rand7) + sin($y * $rand4 + $rand8)) * $rand10;
            }
            if ($grad) {
                # with gradient effect based on above functions
                if ($newY > $height or $newY < 0) {
                    $newY = 0;
                }
                if ($newX < 0) {
                    $newX = 0;
                } else {
                    if ($newX > $width) {
                        $newX = $width;
                    }
                }
                $newcolor = _antialias_color($image, $x, $y, $newX, $newY);
                if ($newcolor === false) {
                    // this is background color
                    $newcolor = $bgcolor;
                }
                $r = $newcolor['red'];
                $g = $newcolor['green'];
                $b = $newcolor['blue'];
                $gratio = 120;
                $bratio = 100;
                $pratio = 125;
                $red = (int) $r;
                $green = (int) ($newX / $width * $gratio + $g / 255 * $pratio);
                $blue = (int) ($newY / $height * $bgatio + $b / 255 * $pratio);
                $new = imagecolorallocate($canvas, $red, $green, $blue);
                $new = imagecolorclosest($canvas, $red, $green, $blue);
                imageSetPixel($canvas, $x, $y, $new);
            } else {
                if ($newX < 0 || $newY < 0 || $newX >= $width - 1 || $newY >= $height - 1) {
                    continue;
                }
                $newcolor = _antialias_color($image, $x, $y, $newX, $newY);
                // ignore background
                if ($newcolor === false) {
                    continue;
                }
                $red = $newcolor['red'];
                $green = $newcolor['green'];
                $blue = $newcolor['blue'];
                $new = imagecolorallocate($canvas, $red, $green, $blue);
                $new = imagecolorclosest($canvas, $red, $green, $blue);
                imageSetPixel($canvas, $x, $y, $new);
            }
        }
    }
    imageCopy($image, $canvas, 0, 0, 0, 0, $width, $height);
}
 function E_N_to_Long($East, $North, $a, $b, $e0, $n0, $f0, $PHI0, $LAM0)
 {
     #Un-project Transverse Mercator eastings and northings back to longitude.
     #Input: - _
     #eastings (East) and northings (North) in meters; _
     #ellipsoid axis dimensions (a & b) in meters; _
     #eastings (e0) and northings (n0) of false origin in meters; _
     #central meridian scale factor (f0) and _
     #latitude (PHI0) and longitude (LAM0) of false origin in decimal degrees.
     #REQUIRES THE "Marc" AND "InitialLat" FUNCTIONS
     #Convert angle measures to radians
     $Pi = 3.14159265358979;
     $RadPHI0 = $PHI0 * ($Pi / 180);
     $RadLAM0 = $LAM0 * ($Pi / 180);
     #Compute af0, bf0, e squared (e2), n and Et
     $af0 = $a * $f0;
     $bf0 = $b * $f0;
     $e2 = (pow($af0, 2) - pow($bf0, 2)) / pow($af0, 2);
     $n = ($af0 - $bf0) / ($af0 + $bf0);
     $Et = $East - $e0;
     #Compute initial value for latitude (PHI) in radians
     $PHId = $this->InitialLat($North, $n0, $af0, $RadPHI0, $n, $bf0);
     #Compute nu, rho and eta2 using value for PHId
     $nu = $af0 / sqrt(1 - $e2 * pow(sin($PHId), 2));
     $rho = $nu * (1 - $e2) / (1 - $e2 * pow(Sin($PHId), 2));
     $eta2 = $nu / $rho - 1;
     #Compute Longitude
     $X = pow(cos($PHId), -1) / $nu;
     $XI = pow(cos($PHId), -1) / (6 * pow($nu, 3)) * ($nu / $rho + 2 * pow(tan($PHId), 2));
     $XII = pow(cos($PHId), -1) / (120 * pow($nu, 5)) * (5 + 28 * pow(tan($PHId), 2) + 24 * pow(tan($PHId), 4));
     $XIIA = pow(Cos($PHId), -1) / (5040 * pow($nu, 7)) * (61 + 662 * pow(tan($PHId), 2) + 1320 * pow(Tan($PHId), 4) + 720 * pow(tan($PHId), 6));
     $E_N_to_Long = 180 / $Pi * ($RadLAM0 + $Et * $X - pow($Et, 3) * $XI + pow($Et, 5) * $XII - pow($Et, 7) * $XIIA);
     return $E_N_to_Long;
 }
Example #10
0
 /** Function for computing the meridional arc - used internally
  * @access public
  * @param $bFo
  * @param $n
  * @param $P1
  * @param $P2
  */
 private function _marc($bFo, $n, $P1, $P2)
 {
     $n2 = $n * $n;
     $n3 = $n * $n * $n;
     $Marc = $bFo * ((1 + $n + 5 / 4 * $n2 + 5 / 4 * $n3) * ($P2 - $P1) - (3 * $n + 3 * $n2 + 21 / 8 * $n3) * Sin($P2 - $P1) * Cos($P2 + $P1) + (15 / 8 * $n2 + 15 / 8 * $n3) * Sin(2 * ($P2 - $P1)) * Cos(2 * ($P2 + $P1)) - 35 / 24 * $n3 * Sin(3 * ($P2 - $P1)) * Cos(3 * ($P2 + $P1)));
     return $Marc;
 }
Example #11
0
 /** Un-project Transverse Mercator eastings and northings back to longitude.
  * @uses marc
  * @uses InitialLat
  * @param string $East easting in metres
  * @param string $North northing in metres
  * @param string $a ellipsoid axis in metres
  * @param string $b ellipsoid axis in metres
  * @param string $e0 eastings false origin
  * @param string $n0 northings false origin
  * @param integer $f0 central meridian scale factor
  * @param double $PHI0 latitude of false origin in dec degrees
  * @param double $LAM0 longitude of false origin in dec degrees
  */
 private function _eNtoLong($East, $North, $a, $b, $e0, $n0, $f0, $PHI0, $LAM0)
 {
     //Convert angle measures to radians
     $RadPHI0 = $PHI0 * (self::PI / 180);
     $RadLAM0 = $LAM0 * (self::PI / 180);
     //Compute af0, bf0, e squared (e2), n and Et
     $af0 = $a * $f0;
     $bf0 = $b * $f0;
     $e2 = (pow($af0, 2) - pow($bf0, 2)) / pow($af0, 2);
     $n = ($af0 - $bf0) / ($af0 + $bf0);
     $Et = $East - $e0;
     //Compute initial value for latitude (PHI) in radians
     $PHId = $this->_initialLat($North, $n0, $af0, $RadPHI0, $n, $bf0);
     //Compute nu, rho and eta2 using value for PHId
     $nu = $af0 / sqrt(1 - $e2 * pow(sin($PHId), 2));
     $rho = $nu * (1 - $e2) / (1 - $e2 * pow(Sin($PHId), 2));
     $eta2 = $nu / $rho - 1;
     //Compute Longitude
     $X = pow(cos($PHId), -1) / $nu;
     $XI = pow(cos($PHId), -1) / (6 * pow($nu, 3)) * ($nu / $rho + 2 * pow(tan($PHId), 2));
     $XII = pow(cos($PHId), -1) / (120 * pow($nu, 5)) * (5 + 28 * pow(tan($PHId), 2) + 24 * pow(tan($PHId), 4));
     $XIIA = pow(Cos($PHId), -1) / (5040 * pow($nu, 7)) * (61 + 662 * pow(tan($PHId), 2) + 1320 * pow(Tan($PHId), 4) + 720 * pow(tan($PHId), 6));
     $E_N_to_Long = 180 / self::PI * ($RadLAM0 + $Et * $X - pow($Et, 3) * $XI + pow($Et, 5) * $XII - pow($Et, 7) * $XIIA);
     return $E_N_to_Long;
 }
Example #12
0
 private static function solarsystem($tjd, $body, $origin, &$pos, &$vel)
 {
     $ierr = 0;
     $pos2 = array();
     $p = array();
     //3x3
     if (SolarTerm::$tlast == 0.0) {
         $oblr = 0.40909280420293637;
         SolarTerm::$sine = sin($oblr);
         SolarTerm::$cose = cos($oblr);
         SolarTerm::$tmass = 1.0;
         for ($i = 0; $i < 4; $i += 1) {
             SolarTerm::$tmass += 1.0 / SolarTerm::$pm[(int) $i];
         }
         SolarTerm::$tlast = 1.0;
     }
     $pos = array();
     $vel = array();
     if ($body == 0 || $body == 1 || $body == 10) {
         for ($i = 0; $i < 3; $i += 1) {
             $pos[(int) $i] = $vel[(int) $i] = 0.0;
         }
     } else {
         if ($body != 2 && $body != 3) {
             return 2;
         }
         for ($i = 0; $i < 3; $i += 1) {
             $qjd = $tjd + doubleval($i - 1) * 0.1;
             $ras = 0;
             $decs = 0;
             $diss = 0;
             SolarTerm::sun_eph($qjd, $ras, $decs, $diss);
             Novas::radec2vector($ras, $decs, $diss, $pos2);
             Novas::precession($qjd, $pos2, 2451545.0, $pos);
             $p[$i][0] = -$pos[0];
             $p[$i][1] = -$pos[1];
             $p[$i][2] = -$pos[2];
         }
         for ($i = 0; $i < 3; $i += 1) {
             $pos[(int) $i] = $p[1][(int) $i];
             $vel[(int) $i] = ($p[2][(int) $i] - $p[0][(int) $i]) / 0.2;
         }
     }
     if ($origin == 0) {
         if (abs($tjd - SolarTerm::$tlast) >= 1.0E-6) {
             for ($i = 0; $i < 3; $i += 1) {
                 SolarTerm::$pbary[(int) $i] = SolarTerm::$vbary[(int) $i] = 0.0;
             }
             for ($i = 0; $i < 4; $i += 1) {
                 $dlon = SolarTerm::$pl[(int) $i] + SolarTerm::$pn[(int) $i] * ($tjd - 2451545.0);
                 $dlon %= 6.283185307179586;
                 $sinl = Sin($dlon);
                 $cosl = Cos($dlon);
                 $x = SolarTerm::$pa[(int) $i] * $cosl;
                 $y = SolarTerm::$pa[(int) $i] * $sinl * SolarTerm::$cose;
                 $z = SolarTerm::$pa[(int) $i] * $sinl * SolarTerm::$sine;
                 $xdot = -SolarTerm::$pa[(int) $i] * SolarTerm::$pn[(int) $i] * $sinl;
                 $ydot = SolarTerm::$pa[(int) $i] * SolarTerm::$pn[(int) $i] * $cosl * SolarTerm::$cose;
                 $zdot = SolarTerm::$pa[(int) $i] * SolarTerm::$pn[(int) $i] * $cosl * SolarTerm::$sine;
                 $f = 1.0 / (SolarTerm::$pm[(int) $i] * SolarTerm::$tmass);
                 SolarTerm::$pbary[0] += $x * $f;
                 SolarTerm::$pbary[1] += $y * $f;
                 SolarTerm::$pbary[2] += $z * $f;
                 SolarTerm::$vbary[0] += $xdot * $f;
                 SolarTerm::$vbary[1] += $ydot * $f;
                 SolarTerm::$vbary[2] += $zdot * $f;
             }
             SolarTerm::$tlast = $tjd;
         }
         for ($i = 0; $i < 3; $i += 1) {
             $pos[(int) $i] -= SolarTerm::$pbary[(int) $i];
             $vel[(int) $i] -= SolarTerm::$vbary[(int) $i];
         }
     }
     return $ierr;
 }
Example #13
0
function getArcCords($cords, $start, $end, $dir, $prev_lat = 0, $prev_lon = 0)
{
    $out = "";
    $out2 = array();
    $angularDistance = $cords[2] / geometry::EARTH_RADIUS;
    $count = 0;
    if ($dir < 0) {
        $totat_angle = $end - $start;
    } else {
        if ($start > $end) {
            $end += 360;
            $totat_angle = -($start - $end);
        } else {
            $totat_angle = -($start - $end) - 360;
        }
    }
    for ($i = $start; $count <= 48; $i += $totat_angle / 48) {
        //$out.= "$i";
        $bearing = deg2rad($i);
        $lat = Asin(Sin($cords[0]) * Cos($angularDistance) + Cos($cords[0]) * Sin($angularDistance) * Cos($bearing));
        $dlon = Atan2(Sin($bearing) * Sin($angularDistance) * Cos($cords[0]), Cos($angularDistance) - Sin($cords[0]) * Sin($lat));
        $lon = fmod($cords[1] + $dlon + M_PI, 2 * M_PI) - M_PI;
        $latOut = rad2deg($lat);
        $lonOut = rad2deg($lon);
        $out .= encode($latOut - $prev_lat) . encode($lonOut - $prev_lon);
        $out2[] = array($lonOut, $latOut);
        $prev_lat = $latOut;
        $prev_lon = $lonOut;
        $count++;
    }
    return array($out, $out2);
}