Пример #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;
 }
Пример #2
0
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;
}
Пример #3
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 = Cos($i * (M_PI / 180)) * 50;
    imagesetpixel($obrazek, 300 + $i, 300 - $y, $black);
}
header("Content-type:image/jpeg");
imagejpeg($obrazek);
imagedestroy($obrazek);
Пример #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)));
 }
Пример #5
0
 /**
  * ?
  * @author		肖飞
  * @param float $lat
  */
 function Ed($lat)
 {
     return $this->Ec($lat) * Cos($this->RadLat($lat));
 }
Пример #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);
}
Пример #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;
 }
 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;
 }
Пример #9
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;
 }
Пример #10
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;
 }
Пример #11
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;
 }
Пример #12
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);
}