<?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="highslidehtml.css" media="screen" />
  <link rel="stylesheet" type="text/css" href="printstyle.css" media="print" />  
  <link rel="stylesheet" type="text/css" href="astrowindow.css" media="screen" />
    
<title>12 Dimensional String</title>
<script type="text/javascript" src="highslide/highslide2.js"></script>
<script type="text/javascript" src="highslide/highslide-html.js"></script>
</head>
<body>

<div class="wholepage">

<div id="content">


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

$epsilon epsilon($T);

//////////////earth Data
$planet 'earth';
$Rs=r($planet,$t);
$l=l($planet,$t);
$B=b($planet,$t);


$Slon$l pi();
$Slat $B;
$cose cos(deg2rad($epsilon));
$sine sin(deg2rad($epsilon));





include(
"database.php");

mysql_connect(localhost,$username,$password);

@
mysql_select_db($database) or die( "Unable to select database");



$query="SELECT * FROM comets ORDER BY comet asc";
$result mysql_query($query) or die(mysql_error()); 

echo 
"<div style=\" position: absolute; left: 50px; top: 100px; \"><table  width=\"680\" border=1>
<tr><th valign='top'>Name</th>
<th valign='top'>Distance</th>
<th valign='top'>Right Ascension</th>
<th valign='top'>Declination</th>
<th valign='top'>Magnitude</th>
</tr>


"
;

while(
$row mysql_fetch_array($result)){
echo
"<tr><td>";
///////////////////
$Ty $row['Ty'] ;
$Tm $row['Tm'] ;
$Td $row['Td'] ;

$comet $row['comet'] ;
$name $row['name'] ;
if (
$Tm 2){
$M2 $Tm;
$Y $Ty;
}else{
$M2 = ($Tm +12);
$Y = ($Ty 1);
}
$A floor($Y/100);
$B $A floor($A/4);
$T = (floor(365.25 * ($Y 4716))) + (floor(30.6001*($M2+1))) + $Td $B 1524.5 0.00081;
$deltaT $JDE-$T;            
$q =  $row['q'] ;       
$e =  $row['e'] ;    
$peri =  $row['peri'] ;
$node =  $row['node'] ;
$i =  $row['i'] ;
$semi $q/(1-$e);
$n 0.9856076686/($semi*sqrt($semi));

$M $n*$deltaT;


$cosO cos(deg2rad($node));
$sinO sin(deg2rad($node));
$cosi cos(deg2rad($i));
$sini sin(deg2rad($i));


$F $cosO;
$G $sinO*$cose;
$H $sinO*$sine;
$P = -$sinO*$cosi;
$Q $cosO*$cosi*$cose-$sini*$sine;
$R $cosO*$cosi*$sine+$sini*$cose;
$A atan2($F,$P);
$B atan2($G,$Q);
$C atan2($H,$R);
$a sqrt(($F*$F)+($P*$P));
$b sqrt(($G*$G)+($Q*$Q));
$c sqrt(($H*$H)+($R*$R));


  
$M deg2rad($M);
 
$E $M;  
$n=1;
while(
$n<=1000)
  {
 
$E $E + (($M $e*sin($E)-$E)/(1-$e*cos($E)));

  
$n++;
  }
  
$M rad2deg($M);
  
$E rad2deg($E);
  
$v = (atan((sqrt((1+$e)/(1-$e)))*tan(deg2rad($E/2))))*2;
$r $semi*(1-$e*cos(deg2rad($E)));

$x $r*$a*sin($A+(deg2rad($peri))+$v);
$y $r*$b*sin($B+(deg2rad($peri))+$v);
$z $r*$c*sin($C+(deg2rad($peri))+$v);

$X $Rs*cos($Slat)*cos($Slon);
$Y $Rs*(cos($Slat)*sin($Slon)*$cose-sin($Slat)*$sine);
$Z $Rs*(cos($Slat)*sin($Slon)*$sine+sin($Slat)*$cose);
$j =$X+$x;
$n =$Y+$y;
$k =$Z+$z;

$delta sqrt(($j*$j)+($n*$n)+($k*$k));
$ra = (rad2deg(atan2($n,$j)))/15;
$dec rad2deg(asin($k/$delta));

if(
$ra 0){
$ra $ra+24;}


$dra d($ra);
$mra m($ra);
$sra s($ra);
$ddec d($dec);
$mdec m($dec);
$sdec s($dec);



$v rad2deg($v);
$A rad2deg($A);
$B rad2deg($B);
$C rad2deg($C);

$g $row['g'] ;
$k $row['k'] ;

$mag round(($g + (5*log10($delta))+($k*log10($r))),1);
$delta round($delta,3);

echo 
"<div align='center'>
        <a href='cometwindow.php?comet=" 
        
.$row['comet']. 
        
"' onclick=\"return hs.htmlExpand(this, { contentId: 'highslide-html', objectType: 'iframe',        objectWidth: 330, objectHeight: 207} )\" class='highslide' style=\"color:#666666; text-decoration:none;\">{$comet}P/$name</a>
    <div class='highslide-html-content' id='highslide-html' style='width: 330px'>
    <div class='highslide-move' style='border: 0; height: 11px; padding: 2px; cursor: default'>
    <a href='#' onclick='return hs.close(this)' class='control' style=\"font-size:80%; position: relative; top: -2px; left: 5px;\">[X]</a>
    </div>
    <div class='highslide-body'></div>
    </div>
    </div>




</td>

<td>$delta AU</td>
<td>{$dra}h {$mra}m {$sra}s</td>
<td>"
;

if (
$dec >= 0){
echo
"+";}
echo
"{$ddec}&deg; {$mdec}' {$sdec}\"</td>
<td>+{$mag}</td>


"
;






}
echo 
"</table>

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









include(
"tabletime.php");
echo 
"


<form action='comets.php' method='get'>
<table style=\"border-width:thin; border-color:#333333; border-style:solid; position: absolute; left: 10px; top: 10px; \" width=\"750\">

<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>"
;











echo
"

<br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br>
<br>"
;





?>
<br><br><br>
<br><br><br>
    </div>
</div> 




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