<?php
require_once 'localtime2.php';
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
##  Whilst this source code is freely available to view, it is strictly for educational use only. 
##  All the code is written by myself, and most of the equations are derived from 'Astronomical Algorithms' by Jean Meeus. 
##  The code is therefore copyrighted and no part may be reproduced without permission.
##  David Campbell
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
?>
  <link rel="stylesheet" type="text/css" href="printstyle.css" media="print" />  
  <link rel="stylesheet" type="text/css" href="astrowindow.css" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>

<div class="wholepage">

<div id="content">
        
   
 <?php

include("jde.php");
$t = ($JDE 2451545)/365250;
$T 10 $t;

if ( isset(
$_GET['invert']) ) { $_SESSION['invert'] = $_GET['invert'];}
$invert $_SESSION['invert']; 
if (
$invert == "")
{
$invert 'no'; }




/////////////Sun data
include("ptearth.php");

$L = ($L0 + ($L1 $t) + ($L2 $t $t) + ($L3 $t $t $t) + ($L4 $t $t $t $t) + ($L5 $t $t $t $t $t));
$Ldegs rad2deg($L);
$B = ($B0 + ($B1 $t) + ($B2 $t $t) + ($B3 $t $t $t) + ($B4 $t $t $t $t) + ($B5 $t $t $t $t $t));
$Bdegs rad2deg($B);
$Slonpre = (rad2deg($L)+180);
if (
$Slonpre 0){
$Slon $Slonpre + ((- (floor($Slonpre/360)))*360);
}else{
if (
$Slonpre 360){
$Slon $Slonpre - ((floor($Slonpre/360))*360);
}else{
$Slon $Slonpre;
}}

$Slat $Bdegs;
$R = ($R0 + ($R1 $t) + ($R2 $t $t) + ($R3 $t $t $t) + ($R4 $t $t $t $t) +($R5 $t $t $t $t $t));

$tau 0.0057755183 5;
$t $t - ($tau/365250);

//////////////Jupiter Data
include("ptjupiter.php");

$l = ($L0 + ($L1 $t) + ($L2 $t $t) + ($L3 $t $t $t) + ($L4 $t $t $t $t) + ($L5 $t $t $t $t $t));
$ldegs rad2deg($l);
if (
$ldegs 0){
$l1 $ldegs + ((- (floor($ldegs/360)))*360);
}else{
if (
$ldegs 360){
$l1 $ldegs - ((floor($ldegs/360))*360);
}else{
$l1 $ldegs;
}}

$b = ($B0 + ($B1 $t) + ($B2 $t $t) + ($B3 $t $t $t) + ($B4 $t $t $t $t) + ($B5 $t $t $t $t $t));
$bdegs rad2deg($b);

$r = ($R0 + ($R1 $t) + ($R2 $t $t) + ($R3 $t $t $t) + ($R4 $t $t $t $t) +($R5 $t $t $t $t $t));


$x = ($r *(cos($b))*(cos(deg2rad($l1))))+($R *(cos(deg2rad($Slon))));
$y = ($r *(cos($b))*(sin(deg2rad($l1))))+($R *(sin(deg2rad($Slon))));
$z = ($r * (sin($b))) + ($R * (sin(deg2rad($Slat))));

$delta sqrt(($x*$x)+($y*$y)+($z*$z));


$tau 0.0057755183 $delta;
$t = ($JDE 2451545)/365250;
$t $t - ($tau/365250);

//////////////////////////// re-iteration
$l = ($L0 + ($L1 $t) + ($L2 $t $t) + ($L3 $t $t $t) + ($L4 $t $t $t $t) + ($L5 $t $t $t $t $t));
$ldegs rad2deg($l);
if (
$ldegs 0){
$l2 $ldegs + ((- (floor($ldegs/360)))*360);
}else{
if (
$ldegs 360){
$l2 $ldegs - ((floor($ldegs/360))*360);
}else{
$l2 $ldegs;
}}
$b = ($B0 + ($B1 $t) + ($B2 $t $t) + ($B3 $t $t $t) + ($B4 $t $t $t $t) + ($B5 $t $t $t $t $t));
$bdegs rad2deg($b);
$r = ($R0 + ($R1 $t) + ($R2 $t $t) + ($R3 $t $t $t) + ($R4 $t $t $t $t) +($R5 $t $t $t $t $t));


$x = ($r *(cos($b))*(cos(deg2rad($l2))))+($R *(cos(deg2rad($Slon))));
$y = ($r *(cos($b))*(sin(deg2rad($l2))))+($R *(sin(deg2rad($Slon))));
$z = ($r *(sin($b))) + ($R * (sin(deg2rad($Slat))));

$delta sqrt(($x*$x)+($y*$y)+($z*$z));

$lambda0 rad2deg(atan2($y,$x));

if (
$lambda0 0){
$lambda0 $lambda0 + ((- (floor($lambda0/360)))*360);
}else{
if (
$lambda0 360){
$lambda0 $lambda0 - ((floor($lambda0/360))*360);
}else{
$lambda0 $lambda0;
}}

$beta0 rad2deg(atan(($z)/(sqrt(($x*$x)+($y*$y)))));

$epsilon0 23.4392911111 - (0.013004166667 *$T) - ((1.63889/10000000) *$T $T) + ($T*$T*$T * (5.03611/10000000));


$Sra rad2deg(atan2((((sin(deg2rad($lambda0)))*(cos(deg2rad($epsilon0)))) - ((tan(deg2rad($beta0)))* (sin(deg2rad($epsilon0))))),(cos(deg2rad($lambda0)))));
if (
$Sra 0){
$S $Sra + ((- (floor($Sra/360)))*360);
}else{
if (
$Sra 360){
$S $Sra - ((floor($Sra/360))*360);
}else{
$S $Sra;
}}
$Sra $S/15;



$Sdec rad2deg(asin(((sin(deg2rad($beta0)))*(cos(deg2rad($epsilon0))))+((cos(deg2rad($beta0)))*(sin(deg2rad($epsilon0)))*(sin(deg2rad($lambda0)))))       );

$tau 0.0057755183 $delta;

////////////////////
$t $JDE 2443000.5 $tau;

$l1 106.07719 + (203.488955709 $t);
$l2 175.73161 + (101.374724735 $t);
$l3 120.55883 + (50.317609207 $t);
$l4 =  84.44459 + (21.571071177 $t);

$pi1 97.0881 + (0.16138586 $t);
$pi2 154.8663 + (0.04726307 $t);
$pi3 188.1840 + (0.00712734 $t);
$pi4 335.2868 + (0.00184000 $t);

$w1 312.3346 - (0.13279386 $t);
$w2 100.4411 - (0.03263064 $t);
$w3 119.1942 - (0.00717703 $t);
$w4 322.6186 - (0.00175934 $t);

$gamma = (0.033033 * (sin(deg2rad(163.679 + (0.0010512 $t))))) + (0.03439 * (sin(deg2rad(34.486 - (0.0161731 $t)))));
$phi 199.6766 + (0.17379190 $t);
$psi 316.5182 - (0.00000208 $t);
$G 30.23756 + (0.0830925701 $t) + $gamma;
$Gdash 31.97853 + (0.0334597339 $t);
$PI 13.469942;


/////////Periodic Terms in longitude
$E1 = (0.47259 * (sin(deg2rad(2*($l1-$l2)))))
- (
0.03478 * (sin(deg2rad($pi3-$pi4 ))))
+ (
0.01081 * (sin(deg2rad($l2-(2*$l3)+$pi3))))
+ (
0.00738 * (sin(deg2rad($phi))))
- (
0.00674 * (sin(deg2rad($pi1+$pi3 -(2*$PI)-(2*$G) ))))
+ (
0.00666 * (sin(deg2rad($l2-(2*$l3)+$pi4))))
+ (
0.00445 * (sin(deg2rad($l1 -$pi3 ))))
- (
0.00354 * (sin(deg2rad($l1-$l2 ))))
- (
0.00317 * (sin(deg2rad(2*($psi-$PI)))))
+ (
0.00265 * (sin(deg2rad($l1-$pi4))))
- (
0.00186 * (sin(deg2rad($G))))
+ (
0.00162 * (sin(deg2rad($pi2-$pi3))))
+ (
0.00158 * (sin(deg2rad(4*($l1-$l2)))))
- (
0.00155 * (sin(deg2rad($l1-$l3))))
- (
0.00138 * (sin(deg2rad($psi +$w3-(2*$PI)-(2*$G) ))))
- (
0.00115 * (sin(deg2rad(2*($l1 - (2*$l2)+$w2) ))))
+ (
0.00089 * (sin(deg2rad($pi2-$pi4 ))))
+ (
0.00085 * (sin(deg2rad($l1+$pi3 -(2*$PI)-(2*$G)))))
+ (
0.00083 * (sin(deg2rad($w2-$w3))))
+ (
0.00053 * (sin(deg2rad($psi-$w2))));

$E2 
+(
1.06476 * (sin(deg2rad(2*($l2-$l3)))))
+(
0.04256 * (sin(deg2rad($l1-(2*$l2)+$pi3))))
+(
0.03581 * (sin(deg2rad($l2-$pi3))))
+(
0.02395 * (sin(deg2rad($l1-(2*$l2)+$pi4))))
+(
0.01984 * (sin(deg2rad($l2-$pi4))))
-(
0.01778 * (sin(deg2rad($phi))))
+(
0.01654 * (sin(deg2rad($l2-$pi2))))
+(
0.01334 * (sin(deg2rad($l2-(2*$l3)+$pi2))))
+(
0.01294 * (sin(deg2rad($pi3-$pi4))))
-(
0.01142 * (sin(deg2rad($l2-$l3))))
-(
0.01057 * (sin(deg2rad($G))))
-(
0.00775 * (sin(deg2rad(2*($psi-$PI)))))
+(
0.00524 * (sin(deg2rad(2*($l1-$l2)))))
-(
0.00460 * (sin(deg2rad($l1-$l3))))
+(
0.00316 * (sin(deg2rad($psi+$w3 -(2*$PI)-(2*$G)))))
-(
0.00203 * (sin(deg2rad($pi1+$pi3 -(2*$PI)-(2*$G)))))
+(
0.00146 * (sin(deg2rad($psi-$w3))))
-(
0.00145 * (sin(deg2rad(2*$G))))
+(
0.00125 * (sin(deg2rad($psi-$w4))))
-(
0.00115 * (sin(deg2rad($l1-(2*$l3)+$pi3))))
-(
0.00094 * (sin(deg2rad(2*($l1-$w2)))))
+(
0.00086 * (sin(deg2rad(2*($l1-(2*$l2)+$w2)))))
-(
0.00086 * (sin(deg2rad((5*$Gdash)-(2*$G)+52.225))))
-(
0.00078 * (sin(deg2rad($l2-$l4))))
-(
0.00064 * (sin(deg2rad((3*$l3)-(7*$l4)+$pi4))))
+(
0.00064 * (sin(deg2rad($pi1-$pi4))))
-(
0.00063 * (sin(deg2rad($l1-(2*$l3)+$pi4))))
+(
0.00058 * (sin(deg2rad($w3-$w4))))
+(
0.00056 * (sin(deg2rad(2*($psi-$PI-$G)))))
+(
0.00056 * (sin(deg2rad(2*($l2-$l4)))))
+(
0.00055 * (sin(deg2rad(2*($l1-$l3)))))
+(
0.00052 * (sin(deg2rad((3*$l3)-(7*$l4)+$pi3+(3*$pi4)))))
-(
0.00043 * (sin(deg2rad($l1-$pi3))))
+(
0.00041 * (sin(deg2rad(5*($l2-$l3)))))
+(
0.00041 * (sin(deg2rad($pi4-$PI))))
+(
0.00032 * (sin(deg2rad($w2-$w3))))
+(
0.00032 * (sin(deg2rad(2*($l3-$G-$PI)))));

$E3 
+(
0.16490 * (sin(deg2rad($l3-$pi3))))
+(
0.09081 * (sin(deg2rad($l3-$pi4))))
-(
0.06907 * (sin(deg2rad($l2-$l3))))
+(
0.03784 * (sin(deg2rad($pi3-$pi4))))
+(
0.01846 * (sin(deg2rad(2*($l3-$l4)))))
-(
0.01340 * (sin(deg2rad($G))))
-(
0.01014 * (sin(deg2rad(2*($psi-$PI)))))
+(
0.00704 * (sin(deg2rad($l2-(2*$l3)+$pi3))))
-(
0.00620 * (sin(deg2rad($l2-(2*$l3)+$pi2))))
-(
0.00541 * (sin(deg2rad($l3-$l4))))
+(
0.00381 * (sin(deg2rad($l2-(2*$l3)+$pi4))))
+(
0.00235 * (sin(deg2rad($psi-$w3))))
+(
0.00198 * (sin(deg2rad($psi-$w4))))
+(
0.00176 * (sin(deg2rad($phi))))
+(
0.00130 * (sin(deg2rad(3*($l3-$l4)))))
+(
0.00125 * (sin(deg2rad($l1-$l3))))
-(
0.00119 * (sin(deg2rad((5*$Gdash)-(2*$G)+52.225))))
+(
0.00109 * (sin(deg2rad($l1-$l2))))
-(
0.00100 * (sin(deg2rad((3*$l3)-(7*$l4)+$pi4))))
+(
0.00091 * (sin(deg2rad($w3-$w4))))
+(
0.00080 * (sin(deg2rad((3*$l3)-(7*$l4)+$pi3+(3*$pi4)))))
-(
0.00075 * (sin(deg2rad((2*$l2)-(3*$l3)+$pi3))))
+(
0.00072 * (sin(deg2rad($pi1+$pi3 -(2*$PI)-(2*$G)))))
+(
0.00069 * (sin(deg2rad($pi4-$PI))))
-(
0.00058 * (sin(deg2rad((2*$l3)-(3*$l4)+$pi4))))
-(
0.00057 * (sin(deg2rad($l3-(2*$l4)+$pi4))))
+(
0.00056 * (sin(deg2rad($l3+$pi3 -(2*$PI)-(2*$G)))))
-(
0.00052 * (sin(deg2rad($l2-(2*$l3)+$pi1))))
-(
0.00050 * (sin(deg2rad($pi2-$pi3))))
+(
0.00048 * (sin(deg2rad($l3-(2*$l4)+$pi3))))
-(
0.00045 * (sin(deg2rad((2*$l2)-(3*$l3)+$pi4))))
-(
0.00041 * (sin(deg2rad($pi2-$pi4))))
-(
0.00038 * (sin(deg2rad(2*$G))))
-(
0.00037 * (sin(deg2rad($pi3-$pi4+$w3-$w4))))
-(
0.00032 * (sin(deg2rad((3*$l3)-(7*$l4)+(2*$pi3)+(2*$pi4)))))
+(
0.00030 * (sin(deg2rad(4*($l3-$l4)))))
+(
0.00029 * (sin(deg2rad($l3+$pi4 -(2*$PI)-(2*$G)))))
-(
0.00028 * (sin(deg2rad($w3+$psi -(2*$PI)-(2*$G)))))
+(
0.00026 * (sin(deg2rad($l3-$PI-$G))))
+(
0.00024 * (sin(deg2rad($l2-(3*$l3)+(2*$l4)))))
+(
0.00021 * (sin(deg2rad(2*($l3-$PI-$G)))))
-(
0.00021 * (sin(deg2rad($l3-$pi2))))
+(
0.00017 * (sin(deg2rad(2*($l3-$pi3)))));

$E4 
+(
0.84287 * (sin(deg2rad($l4-$pi4))))
+(
0.03431 * (sin(deg2rad($pi4-$pi3))))
-(
0.03305 * (sin(deg2rad(2*($psi-$PI)))))
-(
0.03211 * (sin(deg2rad($G))))
-(
0.01862 * (sin(deg2rad($l4-$pi4))))
+(
0.01186 * (sin(deg2rad($psi-$w4))))
+(
0.00623 * (sin(deg2rad($l4+$pi4 -(2*$PI)-(2*$G))))
+(
0.00387 * (sin(deg2rad(2*($l4-$pi4)))))
-(
0.00284 * (sin(deg2rad((5*$Gdash)-(2*$G)+52.225))))
-(
0.00234 * (sin(deg2rad(2*($psi-$pi4)))))
-(
0.00223 * (sin(deg2rad($l3-$l4))))
-(
0.00208 * (sin(deg2rad($l4-$PI))))
+(
0.00178 * (sin(deg2rad($psi+$w4-(2*$pi4)))))
+(
0.00134 * (sin(deg2rad($pi4-$PI))))
+(
0.00125 * (sin(deg2rad(2*($l4-$G-$PI)))))
-(
0.00117 * (sin(deg2rad(2*$G))))
-(
0.00112 * (sin(deg2rad(2*($l3-$l4)))))
+(
0.00107 * (sin(deg2rad((3*$l3)-(7*$l4)+(4*$pi4)))))
+(
0.00102 * (sin(deg2rad($l4-$G-$PI))))
+(
0.00096 * (sin(deg2rad((2*$l4)-$psi-$w4))))
+(
0.00087 * (sin(deg2rad(2*($psi-$w4)))))
-(
0.00085 * (sin(deg2rad((3*$l3)-(7*$l4)+$pi3+(3*$pi4)))))
+(
0.00085 * (sin(deg2rad($l3-(2*$l4)+$pi4))))
-(
0.00081 * (sin(deg2rad(2*($l4-$psi)))))
+(
0.00071 * (sin(deg2rad($l4+$pi4 -(2*$PI)-(3*$G)))))
+(
0.00061 * (sin(deg2rad($l1-$l4))))
-(
0.00056 * (sin(deg2rad($psi-$w3))))
-(
0.00054 * (sin(deg2rad($l3-(2*$l4)+$pi3))))
+(
0.00051 * (sin(deg2rad($l1-$l4))))
+(
0.00042 * (sin(deg2rad(2*($psi-$G-$PI)))))
+(
0.00039 * (sin(deg2rad(2*($pi4-$w4)))))
+(
0.00036 * (sin(deg2rad($psi+$PI-$pi4-$w4))))
+(
0.00035 * (sin(deg2rad((2*$Gdash)-$G+188.37))))
-(
0.00035 * (sin(deg2rad($l4-$pi4+(2*$PI)-(2*$psi)))))
-(
0.00032 * (sin(deg2rad($l4-$pi4+(2*$PI)-$G))))
+(
0.00030 * (sin(deg2rad((2*$Gdash)-(2*$G)+149.15))))
+(
0.00029 * (sin(deg2rad((3*$l3)-(7*$l4)+(2*$pi3)+(2*$pi4)))))
+(
0.00028 * (sin(deg2rad($l4-$pi4+(2*$psi)-(2*$PI)))))
-(
0.00028 * (sin(deg2rad(2*($l4-$w4)))))
-(
0.00027 * (sin(deg2rad($pi3-$pi4+$w3-$w4))))
-(
0.00026 * (sin(deg2rad((5*$Gdash)-(3*$G)+188.37))))
+(
0.00025 * (sin(deg2rad($w4-$w3)))))
-(
0.00025 * (sin(deg2rad($l2-(3*$l3)+(2*$l4)))))
-(
0.00023 * (sin(deg2rad(3*($l3-$l4)))))
+(
0.00021 * (sin(deg2rad((2*$l4)-(2*$PI)-(3*$G)))))
-(
0.00021 * (sin(deg2rad((2*$l3)-(3*$l4)+$pi4))))
+(
0.00019 * (sin(deg2rad($l4-$pi4-$G))))
-(
0.00019 * (sin(deg2rad((2*$l4)-$pi3-$pi4))))
-(
0.00018 * (sin(deg2rad($l4-$pi4+$G))))
-(
0.00016 * (sin(deg2rad($l4+$pi3-(2*$PI)-(2*$G)))));




$L1 $l1 $E1;
$L2 $l2 $E2;
$L3 $l3 $E3;
$L4 $l4 $E4;

/////////Periodic terms in latitude
$tanB1 0
+ (0.0006393 * (sin(deg2rad($L1 $w1))))
+ (
0.0001825 * (sin(deg2rad($L1 $w2))))
+ (
0.0000329 * (sin(deg2rad($L1 $w3))))
- (
0.0000311 * (sin(deg2rad($L1 $psi))))
+ (
0.0000093 * (sin(deg2rad($L1 $w4))))
+ (
0.0000075 * (sin(deg2rad((3*$L1)-(4*$l2)-(1.9927*$E1)+$w2))))
+ (
0.0000046 * (sin(deg2rad($L1 $psi -(2*($PI+$G))))));

$tanB2 0
+ (0.0081004 * (sin(deg2rad($L2 $w2))))
+ (
0.0004512 * (sin(deg2rad($L2 $w3))))
- (
0.0003284 * (sin(deg2rad($L2 $psi))))
+ (
0.0001160 * (sin(deg2rad($L2 $w4))))
+ (
0.0000272 * (sin(deg2rad($l1-(2*$l3)+(1.0146*$E2)+$w2))))
- (
0.0000144 * (sin(deg2rad($L2 $w1))))
+ (
0.0000143 * (sin(deg2rad($L2 $psi -(2*($PI+$G))))))
+ (
0.0000035 * (sin(deg2rad($L2 $psi $G))))
- (
0.0000028 * (sin(deg2rad($l1-(2*$l3)+(1.0146*$E2)+$w3))));

$tanB3 0
+ (0.0032402 * (sin(deg2rad($L3 $w3))))
- (
0.0016911 * (sin(deg2rad($L3 $psi))))
+ (
0.0006847 * (sin(deg2rad($L3 $w4))))
- (
0.0002797 * (sin(deg2rad($L3 $w2))))
+ (
0.0000321 * (sin(deg2rad($L3 $psi -(2*($PI+$G))))))
+ (
0.0000051 * (sin(deg2rad($L3 $psi +$G))))
- (
0.0000045 * (sin(deg2rad($L3 $psi -$G))))
- (
0.0000045 * (sin(deg2rad($L3 $psi - (2*$PI)))))
+ (
0.0000037 * (sin(deg2rad($L3 $psi -(2*$PI)-(3*$G)))));
+ (
0.0000030 * (sin(deg2rad((2*$L2)-(3*$l3)-(40.3*$E3)+$w2))))
- (
0.0000021 * (sin(deg2rad((2*$L2)-(3*$l3)-(40.3*$E3)+$w2))));

$tanB4 0
- (0.0076579 * (sin(deg2rad($L4 $psi))))
+ (
0.0044134 * (sin(deg2rad($L4 $w4))))
- (
0.0005112 * (sin(deg2rad($L4 $w3))))
+ (
0.0000773 * (sin(deg2rad($L4 $psi -(2*($PI+$G))))))
+ (
0.0000104 * (sin(deg2rad($L4 $psi $G))))
- (
0.0000102 * (sin(deg2rad($L4 $psi $G))))
+ (
0.0000088 * (sin(deg2rad($L4 $psi -(2*$PI)-(3*$G)))))
- (
0.0000038 * (sin(deg2rad($L4 $psi -(2*($PI+$G))))));

$B1 rad2deg(atan($tanB1));
$B2 rad2deg(atan($tanB2));
$B3 rad2deg(atan($tanB3));
$B4 rad2deg(atan($tanB4));


/////////Periodic terms in the radius vector
$r1 =0
- (0.0041339 * (cos(deg2rad(2*($l1 $l2)))))
- (
0.0000387 * (cos(deg2rad($l1 $pi3))))
- (
0.0000214 * (cos(deg2rad($l1 $pi4))))
+ (
0.0000170 * (cos(deg2rad($l1 $l2))))
- (
0.0000131 * (cos(deg2rad(4*($l1 $l2)))))
+ (
0.0000106 * (cos(deg2rad($l1 $l3))))
- (
0.0000066 * (cos(deg2rad($l1+$pi3 -(2*($PI+$G))))));

$r2 0
+ (0.0093848 * (cos(deg2rad($l1 $l2))))
- (
0.0003116 * (cos(deg2rad($l2 $pi3))))
- (
0.0001744 * (cos(deg2rad($l2 $pi4))))
- (
0.0001442 * (cos(deg2rad($l2 $pi2))))
+ (
0.0000553 * (cos(deg2rad($l2 $l3))))
+ (
0.0000523 * (cos(deg2rad($l1 $l3))))
- (
0.0000290 * (cos(deg2rad(2*($l1 $l2)))))
+ (
0.0000164 * (cos(deg2rad(2*($l2 $w2)))))
+ (
0.0000107 * (cos(deg2rad($l1+$pi3 -(2*$l3)))))
- (
0.0000102 * (cos(deg2rad($l2 $pi1))))
- (
0.0000091 * (cos(deg2rad(2*($l1 $l3)))));

$r3 0
- (0.0014388 * (cos(deg2rad($l3 $pi3))))
- (
0.0007919 * (cos(deg2rad($l3 $pi4))))
+ (
0.0006342 * (cos(deg2rad($l2 $l3))))
- (
0.0001761 * (cos(deg2rad(2*($l3 $l4)))))
+ (
0.0000294 * (cos(deg2rad($l3 $l4))))
- (
0.0000156 * (cos(deg2rad(3*($l3 $l4)))))
+ (
0.0000156 * (cos(deg2rad($l1 $l3))))
- (
0.0000153 * (cos(deg2rad($l1 $l2))))
+ (
0.0000070 * (cos(deg2rad((2*$l2)+$pi3 -(3*$l3)))))
- (
0.0000051 * (cos(deg2rad($l3+$pi3 -(2*($PI+$G))))));

$r4 =0
- (0.0073546 * (cos(deg2rad($l4 $pi4))))
+ (
0.0001621 * (cos(deg2rad($l4 $pi3))))
+ (
0.0000974 * (cos(deg2rad($l3 $pi4))))
- (
0.0000543 * (cos(deg2rad($l4+$pi4 -(2*($PI+$G))))))
- (
0.0000271 * (cos(deg2rad(2*($l4 $pi4)))))
+ (
0.0000182 * (cos(deg2rad($l4 $PI))))
+ (
0.0000177 * (cos(deg2rad(2*($l3 $l4)))))
- (
0.0000167 * (cos(deg2rad(-$w4-$psi +(2*$l4)))))
+ (
0.0000167 * (cos(deg2rad($psi $w4))))
- (
0.0000155 * (cos(deg2rad(2*($l4 $PI -$G)))))
+ (
0.0000142 * (cos(deg2rad(2*($l4 $psi)))));

$a1 5.90569;
$a2 9.39657;
$a3 14.98832;
$a4 26.36273;

$R1 $a1 * ($r1);
$R2 $a2 * ($r2);
$R3 $a3 * ($r3);
$R4 $a4 * ($r4);


/////////
$T0 = ($JDE 2433282.423) /36525;

$P = (1.3966626 $T0) + (0.0003088 $T0$T0);

$L1 $L1 $P;
$L2 $L2 $P;
$L3 $L3 $P;
$L4 $L4 $P;

$psi $psi $P;

$T = ($year 1900)/100;
$I 3.120262 +  (0.0006 $T);

/////////calculate co-ords
$X1 $R1 * (cos(deg2rad($L1 $psi))) * (cos(deg2rad($B1)));
$Y1 $R1 * (sin(deg2rad($L1 $psi))) * (cos(deg2rad($B1)));
$Z1 $R1 * (sin(deg2rad($B1)));
$X2 $R2 * (cos(deg2rad($L2 $psi))) * (cos(deg2rad($B2)));
$Y2 $R2 * (sin(deg2rad($L2 $psi))) * (cos(deg2rad($B2)));
$Z2 $R2 * (sin(deg2rad($B2)));
$X3 $R3 * (cos(deg2rad($L3 $psi))) * (cos(deg2rad($B3)));
$Y3 $R3 * (sin(deg2rad($L3 $psi))) * (cos(deg2rad($B3)));
$Z3 $R3 * (sin(deg2rad($B3)));
$X4 $R4 * (cos(deg2rad($L4 $psi))) * (cos(deg2rad($B4)));
$Y4 $R4 * (sin(deg2rad($L4 $psi))) * (cos(deg2rad($B4)));
$Z4 $R4 * (sin(deg2rad($B4)));
$X5 0;
$Y5 0;
$Z5 1;


$T = ($JDE 2451545.0) /36525;
$omega 100.464407 + (1.0209774 $T) + (0.00040315$T$T)+(0.000000404$T$T$T);
$i 1.303267 + (-0.00054965 $T) + (0.00000466$T$T)+(-0.000000002$T$T$T);
$phi $psi $omega;


/////////Rotation calculations
$A11 $X1;
$B11 = ($Y1 * (cos(deg2rad($I))))-($Z1 * (sin(deg2rad($I))));
$C11 = ($Y1 * (sin(deg2rad($I))))+($Z1 * (cos(deg2rad($I))));
$A12 = ($A11 * (cos(deg2rad($phi))))-($B11 * (sin(deg2rad($phi))));
$B12 = ($A11 * (sin(deg2rad($phi))))+($B11 * (cos(deg2rad($phi))));
$C12 $C11;
$A13 $A12;
$B13 = ($B12 * (cos(deg2rad($i))))-($C12 * (sin(deg2rad($i))));
$C13 = ($B12 * (sin(deg2rad($i))))+($C12 * (cos(deg2rad($i))));
$A14 = ($A13 * (cos(deg2rad($omega))))-($B13 * (sin(deg2rad($omega))));
$B14 = ($A13 * (sin(deg2rad($omega))))+($B13 * (cos(deg2rad($omega))));
$C14 $C13;
$A15 = ($A14 * (sin(deg2rad($lambda0))))-($B14 * (cos(deg2rad($lambda0))));
$B15 = ($A14 * (cos(deg2rad($lambda0))))+($B14 * (sin(deg2rad($lambda0))));
$C15 $C14;
$A16 $A15;
$B16 = ($C15 * (sin(deg2rad($beta0))))+($B15 * (cos(deg2rad($beta0))));
$C16 = ($C15 * (cos(deg2rad($beta0))))-($B15 * (sin(deg2rad($beta0))));

$A21 $X2;
$B21 = ($Y2 * (cos(deg2rad($I))))-($Z2 * (sin(deg2rad($I))));
$C21 = ($Y2 * (sin(deg2rad($I))))+($Z2 * (cos(deg2rad($I))));
$A22 = ($A21 * (cos(deg2rad($phi))))-($B21 * (sin(deg2rad($phi))));
$B22 = ($A21 * (sin(deg2rad($phi))))+($B21 * (cos(deg2rad($phi))));
$C22 $C21;
$A23 $A22;
$B23 = ($B22 * (cos(deg2rad($i))))-($C22 * (sin(deg2rad($i))));
$C23 = ($B22 * (sin(deg2rad($i))))+($C22 * (cos(deg2rad($i))));
$A24 = ($A23 * (cos(deg2rad($omega))))-($B23 * (sin(deg2rad($omega))));
$B24 = ($A23 * (sin(deg2rad($omega))))+($B23 * (cos(deg2rad($omega))));
$C24 $C23;
$A25 = ($A24 * (sin(deg2rad($lambda0))))-($B24 * (cos(deg2rad($lambda0))));
$B25 = ($A24 * (cos(deg2rad($lambda0))))+($B24 * (sin(deg2rad($lambda0))));
$C25 $C24;
$A26 $A25;
$B26 = ($C25 * (sin(deg2rad($beta0))))+($B25 * (cos(deg2rad($beta0))));
$C26 = ($C25 * (cos(deg2rad($beta0))))-($B25 * (sin(deg2rad($beta0))));

$A31 $X3;
$B31 = ($Y3 * (cos(deg2rad($I))))-($Z3 * (sin(deg2rad($I))));
$C31 = ($Y3 * (sin(deg2rad($I))))+($Z3 * (cos(deg2rad($I))));
$A32 = ($A31 * (cos(deg2rad($phi))))-($B31 * (sin(deg2rad($phi))));
$B32 = ($A31 * (sin(deg2rad($phi))))+($B31 * (cos(deg2rad($phi))));
$C32 $C31;
$A33 $A32;
$B33 = ($B32 * (cos(deg2rad($i))))-($C32 * (sin(deg2rad($i))));
$C33 = ($B32 * (sin(deg2rad($i))))+($C32 * (cos(deg2rad($i))));
$A34 = ($A33 * (cos(deg2rad($omega))))-($B33 * (sin(deg2rad($omega))));
$B34 = ($A33 * (sin(deg2rad($omega))))+($B33 * (cos(deg2rad($omega))));
$C34 $C33;
$A35 = ($A34 * (sin(deg2rad($lambda0))))-($B34 * (cos(deg2rad($lambda0))));
$B35 = ($A34 * (cos(deg2rad($lambda0))))+($B34 * (sin(deg2rad($lambda0))));
$C35 $C34;
$A36 $A35;
$B36 = ($C35 * (sin(deg2rad($beta0))))+($B35 * (cos(deg2rad($beta0))));
$C36 = ($C35 * (cos(deg2rad($beta0))))-($B35 * (sin(deg2rad($beta0))));

$A41 $X4;
$B41 = ($Y4 * (cos(deg2rad($I))))-($Z4 * (sin(deg2rad($I))));
$C41 = ($Y4 * (sin(deg2rad($I))))+($Z4 * (cos(deg2rad($I))));
$A42 = ($A41 * (cos(deg2rad($phi))))-($B41 * (sin(deg2rad($phi))));
$B42 = ($A41 * (sin(deg2rad($phi))))+($B41 * (cos(deg2rad($phi))));
$C42 $C41;
$A43 $A42;
$B43 = ($B42 * (cos(deg2rad($i))))-($C42 * (sin(deg2rad($i))));
$C43 = ($B42 * (sin(deg2rad($i))))+($C42 * (cos(deg2rad($i))));
$A44 = ($A43 * (cos(deg2rad($omega))))-($B43 * (sin(deg2rad($omega))));
$B44 = ($A43 * (sin(deg2rad($omega))))+($B43 * (cos(deg2rad($omega))));
$C44 $C43;
$A45 = ($A44 * (sin(deg2rad($lambda0))))-($B44 * (cos(deg2rad($lambda0))));
$B45 = ($A44 * (cos(deg2rad($lambda0))))+($B44 * (sin(deg2rad($lambda0))));
$C45 $C44;
$A46 $A45;
$B46 = ($C45 * (sin(deg2rad($beta0))))+($B45 * (cos(deg2rad($beta0))));
$C46 = ($C45 * (cos(deg2rad($beta0))))-($B45 * (sin(deg2rad($beta0))));

$A51 $X5;
$B51 = ($Y5 * (cos(deg2rad($I))))-($Z5 * (sin(deg2rad($I))));
$C51 = ($Y5 * (sin(deg2rad($I))))+($Z5 * (cos(deg2rad($I))));
$A52 = ($A51 * (cos(deg2rad($phi))))-($B51 * (sin(deg2rad($phi))));
$B52 = ($A51 * (sin(deg2rad($phi))))+($B51 * (cos(deg2rad($phi))));
$C52 $C51;
$A53 $A52;
$B53 = ($B52 * (cos(deg2rad($i))))-($C52 * (sin(deg2rad($i))));
$C53 = ($B52 * (sin(deg2rad($i))))+($C52 * (cos(deg2rad($i))));
$A54 = ($A53 * (cos(deg2rad($omega))))-($B53 * (sin(deg2rad($omega))));
$B54 = ($A53 * (sin(deg2rad($omega))))+($B53 * (cos(deg2rad($omega))));
$C54 $C53;
$A55 = ($A54 * (sin(deg2rad($lambda0))))-($B54 * (cos(deg2rad($lambda0))));
$B55 = ($A54 * (cos(deg2rad($lambda0))))+($B54 * (sin(deg2rad($lambda0))));
$C55 $C54;

$zeta deg2rad($A55);
$B56 = ($C55 * (sin(deg2rad($beta0))))+($B55 * (cos(deg2rad($beta0))));
$eta deg2rad(($C55 * (cos(deg2rad($beta0))))-($B55 * (sin(deg2rad($beta0)))));
$D rad2deg(atan2($zeta,$eta));

/////////Final adjustments and calculations
$x1 = ($A16 * (cos(deg2rad($D))))-($C16 * (sin(deg2rad($D))));
$y1 = ($A16 * (sin(deg2rad($D))))+($C16 * (cos(deg2rad($D))));
$z1 $B16;
$x1 $x1+((abs($z1)/17295)*(sqrt(1-(($x1/$R1)*($x1/$R1)))));
$x1 $x1 * ($delta/($delta +($z1/2095)));
$y1 $y1 * ($delta/($delta +($z1/2095)));

$x2 = ($A26 * (cos(deg2rad($D))))-($C26 * (sin(deg2rad($D))));
$y2 = ($A26 * (sin(deg2rad($D))))+($C26 * (cos(deg2rad($D))));
$z2 $B26;
$x2 $x2+((abs($z2)/17295)*(sqrt(1-(($x2/$R2)*($x2/$R2)))));
$x2 $x2 * ($delta/($delta +($z2/2095)));
$y2 $y2 * ($delta/($delta +($z2/2095)));

$x3 = ($A36 * (cos(deg2rad($D))))-($C36 * (sin(deg2rad($D))));
$y3 = ($A36 * (sin(deg2rad($D))))+($C36 * (cos(deg2rad($D))));
$z3 $B36;
$x3 $x3+((abs($z3)/17295)*(sqrt(1-(($x3/$R3)*($x3/$R3)))));
$x3 $x3 * ($delta/($delta +($z3/2095)));
$y3 $y3 * ($delta/($delta +($z3/2095)));

$x4 = ($A46 * (cos(deg2rad($D))))-($C46 * (sin(deg2rad($D))));
$y4 = ($A46 * (sin(deg2rad($D))))+($C46 * (cos(deg2rad($D))));
$z4 $B46;
$x4 $x4+((abs($z4)/17295)*(sqrt(1-(($x4/$R4)*($x4/$R4)))));
$x4 $x4 * ($delta/($delta +($z4/2095)));
$y4 $y4 * ($delta/($delta +($z4/2095)));

if (
$invert == "yes"){
$nx1 380-($x1*14);;
}else{
$nx1 = ($x1*14)+380;}
if (
$invert == "yes"){
$nx2 380-($x2*14);
}else{
$nx2 = ($x2*14)+380;}
if (
$invert == "yes"){
$nx3 380-($x3*14);
}else{
$nx3 = ($x3*14)+380;}
if (
$invert == "yes"){
$nx4 380-($x4*14);
}else{
$nx4 = ($x4*14)+380;}


if (
$invert == "yes"){
$ny1 62 + ($y1*14);
}else{
$ny1 62 - ($y1*14);}
if (
$invert == "yes"){
$ny2 62 + ($y2*14);
}else{
$ny2 62 - ($y2*14);}
if (
$invert == "yes"){
$ny3 62 + ($y3*14);
}else{
$ny3 62 - ($y3*14);}
if (
$invert == "yes"){
$ny4 62 + ($y4*14);
}else{
$ny4 62 - ($y4*14);}

echo
"<div style=\"position: absolute; left: 1px; top: 1px; width: 760px; height: 122px; border-width:thin; border-color:#333333; border-style:solid\"></div>
<div style=\"position: absolute; left: 368px; top: 50px; width: 28px; height: 28px; z-index: 3;\"><img src=\"images/jupiter.png\" alt=\"jupiter\"></div>
<div style=\"position: absolute; left: $nx1"
;
echo 
"px; top: $ny1";
echo 
"px; width: 8px; height: 8px; z-index: ";
if (
$z1 0){
echo 
"5";
}else{
if (
$z1 0){
echo 
"5";
}else{
echo 
"1";
}}
echo 
"\"><img src=\"images/io.png\"  alt=\"Io\"><br><font size=\"1\" color=\"#067894\">Io</font></div>
<div style=\"position: absolute; left: $nx2"
;
echo 
"px; top: $ny2";
echo 
"px; width: 8px; height: 8px; z-index: ";
if (
$z2 0){
echo 
"5";
}else{
if (
$z2 0){
echo 
"5";
}else{
echo 
"1";
}}
echo 
"\"><img src=\"images/europa.png\"  alt=\"Europa\"><br><font size=\"1\" color=\"#067894\">Europa</font></div>
<div style=\"position: absolute; left: $nx3"
;
echo 
"px; top: $ny3";
echo 
"px; width: 8px; height: 8px; z-index: ";
if (
$z3 0){
echo 
"5";
}else{
if (
$z3 0){
echo 
"5";
}else{
echo 
"1";
}}
echo 
"\"><img src=\"images/ganymede.png\"  alt=\"Ganymede\"><br><font size=\"1\" color=\"#067894\">Ganymede</font></div>
<div style=\"position: absolute; left: $nx4"
;
echo 
"px; top: $ny4";
echo 
"px; width: 8px; height: 8px; z-index: ";
if (
$z4 0){
echo 
"5";
}else{
if (
$z4 0){
echo 
"5";
}else{
echo 
"1";
}}
echo 
"\"><img src=\"images/callisto.png\"  alt=\"Callisto\"><br><font size=\"1\" color=\"#067894\">Callisto</font></div>";


$jedistance number_format($delta 149597870.691);
$jdistance round($delta,5);
$iodistance number_format($R1 71492);
$eurdistance number_format($R2 71492);
$gandistance number_format($R3 71492);
$caldistance number_format($R4 71492);
echo 
"<br><br><br><br><br><br><br><br><br><br>";

include(
"tabletime.php");
echo 
"
<form action='jovianmoons.php' method='get'><table style=\"border-width:thin; border-color:#333333; border-style:solid\" width=\"760\">

<td align=\"right\"><a href=\"" 
$_SERVER["PHP_SELF"] . "?day=$dayp\">-1 day</a>|<a href=\"" $_SERVER["PHP_SELF"] . "?day=$dayn\">+1 day</a></td>

<td align=\"right\"><a href=\"" 
$_SERVER["PHP_SELF"] . "?month=$monthp\">-1 month</a>|<a href=\"" $_SERVER["PHP_SELF"] . "?month=$monthn\">+1 month</a></td>

<td align=\"right\"><a href=\"" 
$_SERVER["PHP_SELF"] . "?year=$yearp\">-1 year</a>|<a href=\"" $_SERVER["PHP_SELF"] . "?year=$yearn\">+1 year</a></td>

<td align=\"right\"><a href=\"" 
$_SERVER["PHP_SELF"] . "?time=$timep\">-1 hour</a>|<a href=\"" $_SERVER["PHP_SELF"] . "?time=$timen\">+1 hour</a></td>
<t ></td><tr><td align=\"right\">Day (1-31):<input type=\"text\" name=\"day\" size=\"2\" value=\"$day\">&nbsp;&nbsp;</td>
<td width=\"170\" align=\"right\">Month (1-12):<input type=\"text\" name=\"month\" size=\"2\" value=\"$month\">&nbsp;&nbsp;</td>
<td width=\"170\" align=\"right\">Year (4-digit):<input type=\"text\" name=\"year\" size=\"4\" value=\"$year\">&nbsp;&nbsp;</td>
<td width=\"168\" align=\"right\">Time (24 hrs):<input type=\"text\" name=\"time\" size=\"4\" value=\"$time\">&nbsp;&nbsp;</td>
<td  align=\"right\"><input type=\"submit\" value=\"Submit\"></td></tr></table><br>"
;
if (
$invert == "yes"){
echo 
"<a href=\"" $_SERVER["PHP_SELF"] . "?invert=no\">Uninvert view</a>";
}else{
echo 
"<a href=\"" $_SERVER["PHP_SELF"] . "?invert=yes\">Invert view</a>";
}



echo 
"
<br><br><br><table style=\"border-width:thin; border-color:#333333; border-style:solid\"><tr><td align=\"right\"><b> Earth to Jupiter:</b> </td><td>$jedistance km<br>
$jdistance AU</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td align=\"right\"><b> Io to Jupiter:</b> </td><td>$iodistance km</td></tr>
<tr><td align=\"right\"><b> Europa to Jupiter:</b> </td><td>$eurdistance km</td></tr>
<tr><td align=\"right\"><b> Ganymede to Jupiter:</b> </td><td>$gandistance km</td></tr>
<tr><td align=\"right\"><b> Callisto to Jupiter:</b> </td><td>$caldistance km </td></tr></table>"
;
echo 
"<font color=\"black\">X1 =$x1<br>";
echo 
"Y1 =$y1<br>";
echo 
"X2 =$x2<br>";
echo 
"Y2 =$y2<br>";
echo 
"X3 =$x3<br>";
echo 
"Y3 =$y3<br>";
echo 
"X4 =$x4<br>";
echo 
"Y4 =$y4</font><br>";


?><br><br><br><font size="1">Equations derived from 'Astronomical Algorithms' by Jean Meeus. <a href="jovianmoons.phps" target="_blank">View page source</a> </font>
<br>

    </div>
</div> 




</div>
</body>
</html>