-
Notifications
You must be signed in to change notification settings - Fork 0
/
QaffasissusaaDA.html
745 lines (642 loc) · 37.9 KB
/
QaffasissusaaDA.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
<!DOCTYPE HTML>
<html>
<head>
<!--<meta charset="utf-8" /> --->
<title>Kan du se dit objekt?</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/Form.css" />
</head>
<body>
<body class="homepage is-preload">
<div id="page-wrapper">
<!-- Header -->
<section id="header">
<!-- Logo -->
<h1><a href="QaffasissusaaDA.html">Kan du se dit objekt?</a></h1>
<a href="Qaffasissusaa.html"><img src="images/greenland.png" alt="" width="15px"></a> |
<a href="QaffasissusaaDA.html"><img src="images/denmark.png" alt="" width="15px"></a>
<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="indexDA.html">Forside</a></li>
<li class="current"><a href="QaffasissusaaDA.html">Forberedelse til observering</a></li>
<li><a href="CfATelescopeDA.html">Observer med teleskopet</a></li>
<li><a href="AssilissatDA.html">Behandl dit billede</a></li>
</ul>
</nav>
<div id="main">
<div class="inner">
<p>
En del af forberedelsen er at undersøge om dit objekt kan ses på nattehimlen.
Dit objekt skal helt være højt på himlen.
Nedenunder kan du se om dit objekt kan ses fra Nuuk (Grønland), Tårup (Danmark) eller Boston (USA).</p>
</b>
<p>
Tidsrummet vil være efter Solen er gået ned (ca. 21:00 til 05:00).
</p>
<form class="radiobttn" name="Location_form" id="Location_form">
<h4> Hvor er du? </h4>
<input type="radio" id="Nuuk" name="Location" value="Nuuk">
<label for="Nuuk">Nuuk</label>
<input type="radio" id="Tårup" name="Location" value="Tårup">
<label for="Tårup">Tårup</label>
<input type="radio" id="Boston" name="Location" value="Boston">
<label for="Boston">Boston</label>
</form>
</b>
<p> Hvad vil du se? Du kan vælge flere.</p>
<form class="checklist" name = "Object" id="Object">
<h4>I Solsystemet:</h4>
<input type="checkbox" id="Mars" name="Object" value="Mars">
<label for="Mars">Mars</label>
<input type="checkbox" id="Jupiter" name="Object" value="Jupiter">
<label for="Jupiter">Jupiter</label>
<input type="checkbox" id="Saturn" name="Object" value="Saturn">
<label for="Saturn">Saturn</label>
<input type="checkbox" id="Pluto" name="Object" value="Pluto">
<label for="Pluto">Pluto</label>
<h4>I Mælkevejen:</h4>
<input type="checkbox" id="Helixtågen" name="Object" value="Helixtågen">
<label for="Helixtågen">Helixtågen</label>
<input type="checkbox" id="Herkulestågen" name="Object" value="Herkulestågen">
<label for="Herkulestågen">Herkulestågen</label>
<input type="checkbox" id="Håndvægtstågen" name="Object" value="Håndvægtstågen">
<label for="Håndvægtstågen">Håndvægtstågen</label>
<input type="checkbox" id="Lagunetågen" name="Object" value="Lagunetågen">
<label for="Lagunetågen">Lagunetågen</label>
<input type="checkbox" id="Messier 15" name="Object" value="Messier 15">
<label for="Messier 15"> Messier 15</label>
<input type="checkbox" id="Ringtågen" name="Object" value="Ringtågen">
<label for="Ringtågen"> Ringtågen</label>
<input type="checkbox" id="Sagittarius A" name="Object" value="Sagittarius A">
<label for="Sagittarius A"> Sagittarius A</label>
<input type="checkbox" id="Trifidtågen" name="Object" value="Trifidtågen">
<label for="Trifidtågen"> Trifidtågen </label>
<input type="checkbox" id="Ørnetågen" name="Object" value="Ørnetågen">
<label for="Ørnetågen"> Ørnetågen</label>
<h4>Udenfor Mælkevejen:</h4>
<input type="checkbox" id="Andromedagalaksen" name="Object" value="Andromedagalaksen">
<label for="Andromedagalaksen"> Andromedagalaksen</label>
<input type="checkbox" id="Malstrømsgalaksen" name="Object" value="Malstrømsgalaksen">
<label for="Malstrømsgalaksen"> Malstrømsgalaksen</label>
<input type="checkbox" id="Messier 58" name="Object" value="Messier 58">
<label for="Messier 58"> Messier 58 </label>
<input type="checkbox" id="Messier 81" name="Object" value="Messier 81">
<label for="Messier 81"> Messier 81</label>
<input type="checkbox" id="Messier 82" name="Object" value="Messier 82">
<label for="Messier 82"> Messier 82</label>
<input type="checkbox" id="Messier 87" name="Object" value="Messier 87">
<label for="Messier 87"> Messier 87</label>
<input type="checkbox" id="Messier 95" name="Object" value="Messier 95">
<label for="Messier 95"> Messier 95</label>
<input type="checkbox" id="Messier 101" name="Object" value="Messier 101">
<label for="Messier 101"> Messier 101</label>
<input type="checkbox" id="NGC 4013" name="Object" value="NGC 4013">
<label for="NGC 4013"> NGC 4013</label>
<input type="checkbox" id="Spiralgalaksen" name="Object" value="Spiralgalaksen">
<label for="Spiralgalaksen"> Spiralgalaksen Messier 83</label>
<input type="checkbox" id="Trekantsgalaksen" name="Object" value="Trekantsgalaksen">
<label for="Trekantsgalaksen"> Trekantsgalaksen </label>
<p> Tilføj selv Right ascension og declination: </br>
<input type="text" name="Navn" id="Navn" onfocus="this.value=''" value="Navn">
<input type="text" name="RA" id="RA" onfocus="this.value=''" value="R.A.">
<input type="text" name="DEC" id="DEC" onfocus="this.value=''" value="Dec">
</br>F.eks.: R.A. 10h50m13.3s Dec: +1d49m29.1s </p>
</form>
<form class="checklist" name = "Object" id="Object">
<h4>Dag, du vil observere:</h4>
<label for="dob" class="formbold-form-label"> </label>
<input type="date" name="dob" id="dob" class="formbold-form-input" />
</form>
<div>
<input type="button" value="Se" onclick="getValue()"/>
</div>
<div>
<p id="total_text"></p>
</div>
</div>
</div>
</section>
</body>
<!-- Footer -->
<section id="footer">
<div id="copyright" class="container">
<ul class="links">
<li>© Ivalu Barlach Christensen | Design: <a href="http://html5up.net">HTML5 UP</a> | Icons made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik" target="_blank">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon" target="_blank">www.flaticon.com</a> </br></li>
</ul>
</div>
</section>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.dropotron.min.js"></script>
<script src="assets/js/browser.min.js"></script>
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
<script>
function getValue() {
var Location = document.querySelector('input[name="Location"]:checked').value;
//!!!!Location!!!!//
//Longitude of Birmingham UK
var long = 0;
//latitude in degrees, Birmingham UK
var lat = 0;
if(Location === 'Nuuk'){long=-51.7373};
if(Location === 'Nuuk'){lat=64.1743};
if(Location === 'Tårup'){long=10.3402};
if(Location === 'Tårup'){lat =55.4071};
if(Location === 'Boston'){long =-71.0589};
if(Location === 'Boston'){lat =42.3601};
//Time stuff
var date = document.getElementById("dob").value;
var utcoffset = 0
if(Location==='Nuuk'){var utcoffset= -2};
if(Location==='Tårup'){var utcoffset= +1};
if(Location==='Boston'){var utcoffset= -4};
//var UT = 0.0 - utcoffset;
var UTC_string = ["21:00","21:30","22:00","22:30","23:00","23:30","00:00","00:30","01:00","01:30","02:00","02:30","03:00","03:30","04:00","04:30","05:00"]
var UTC = [21.0,21.5,22.0,22.5,23.0,23.5,0.0,0.5,1.0,1.5,2.0,2.5,3.0,4.0,4.5,5.0]
var UT = []
for (var i = 0; i < UTC.length; i++) {
var t = UTC[i]-utcoffset
if(t<0){t +=24}
UT.push(t)
}
let total_text ="<h2>"+ Location + " </br>" + date + "</h2>"+"<ul>";
//!!!!Date!!!!//
var J2000 = new Date("01/01/2000 00:00");
var year = date.split('-')[0];
var Difference_In_Days = []
for (var i = 0; i < UTC_string.length; i++) {
var date2 = new Date(date+" "+UTC_string[i]);
var Difference_In_Time = date2.getTime() - J2000.getTime();
var diff_days = Difference_In_Time / (1000 * 3600 * 24);
Difference_In_Days.push(diff_days);
}
//!!!!Object!!!!//
var checkboxes = document.getElementsByName('Object');
var all_objects =[];
var all_radecs = [];
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
all_objects.push(checkboxes[i].value);
if(checkboxes[i].value==="Mars"){
var obj = new coord();
get_coord(obj, 3, Difference_In_Days[0]);
all_radecs.push(ha2str(obj.ra)+" " + obj.dec)
}
if(checkboxes[i].value==="Jupiter"){
var obj = new coord();
get_coord(obj, 4, Difference_In_Days[0]);
all_radecs.push(ha2str(obj.ra)+" " + obj.dec)
}
if(checkboxes[i].value==="Saturn"){
var obj = new coord();
get_coord(obj, 5, Difference_In_Days[0]);
all_radecs.push(ha2str(obj.ra)+" " + obj.dec)
}
if(checkboxes[i].value==="Pluto"){
var obj = new coord();
get_coord(obj, 8, Difference_In_Days[0]);
all_radecs.push(ha2str(obj.ra)+" " + obj.dec)
}
if(checkboxes[i].value==="Andromedagalaksen"){
ra = "0h42m44s"
dec = Dectodegree("+41d16m9s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Håndvægtstågen"){
ra = "19h59m35s"
dec = Dectodegree("+22d43m16s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Helixtågen"){
ra = "22h29m39s"
dec = Dectodegree("-20d50m14s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Herkulestågen"){
ra = "16h44m29.5s"
dec = Dectodegree("+23d47m59s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Lagunetågen"){
ra = "18h3m37s"
dec = Dectodegree("-24d23m12s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Messier 15"){
ra = "21h29m58s"
dec = Dectodegree("+12d10m1s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Messier 58"){
ra = "12h37m43.5s"
dec = Dectodegree("+11d49m05s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Messier 81"){
ra = "9h55m33s"
dec = Dectodegree("+69d3m55s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Messier 82"){
ra= "9h55m52s"
dec = Dectodegree("+69d40m47s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Messier 87"){
ra = "12h30m49s"
dec = Dectodegree("+12d23m28s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Messier 95"){
ra = "10h43m57.7s"
dec = Dectodegree("+11d42m14s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Messier 101"){
ra = "14h3m13s"
dec = Dectodegree("+54d20m57s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Malstrømsgalaksen"){
ra = "13h29m53s"
dec = Dectodegree("+47d11m43s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="NGC 4013"){
ra = "11h58m31.13s"
dec = Dectodegree("+43d56m50.1s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Ørnetågen"){
ra = "18h18m48s"
dec = Dectodegree("-13d49m0s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Ringtågen"){
ra = "18h53m35s"
dec = Dectodegree("+33d1m45s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Sagittarius A"){
ra = "17h45m40s"
dec = Dectodegree("-29d0m28s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Spiralgalaksen"){
ra = "13h37m00.919s"
dec = Dectodegree("−29d51m56.74s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Trekantsgalaksen"){
ra = "1h33m50s"
dec = Dectodegree("+30d39m37s")
all_radecs.push(ra+" "+dec)
}
if(checkboxes[i].value==="Trifidtågen"){
ra = "18h2m23s";
dec = Dectodegree("-23d1m48s");
all_radecs.push(ra+" "+dec)
}
}
}
var selfinputName = document.getElementById("Navn").value
var selfinputRA = document.getElementById("RA").value
var selfinputDEC = document.getElementById("DEC").value
if(selfinputName!="Navn"){
all_objects.push(selfinputName)
ra = selfinputRA;
dec = Dectodegree(selfinputDEC);
all_radecs.push(ra+" "+dec)
}
//Calculating the elevation of all sources at 21:00 UTC
var Alt_maximum = [];
var Alt_maximum_time = [];
for (var i = 0; i < all_radecs.length; i++) {
var Alt_source = [];
Obj = all_objects[i]
RA = RAtodegree(all_radecs[i].split(' ')[0]);
dec = all_radecs[i].split(' ')[1];
//In radians
var LAT=toRadians(lat);
var DEC=toRadians(dec);
for (var j = 0; j < Difference_In_Days.length; j++) {
var LST = 100.46 + 0.985647 * Difference_In_Days[j] + long + 15*UT[j];
if (LST<0){LST+=360};
var ha= LST-RA;
if (ha<0){ha+=360};
var HA = toRadians(ha)
var firstpart = Math.sin(DEC)*Math.sin(LAT);
var secondpart = Math.cos(DEC)*Math.cos(LAT)*Math.cos(HA);
var sinAlt = firstpart +secondpart;
var Alt = Math.asin(sinAlt);
Alt_source.push(toDegrees(Alt).toFixed(1));
};
var observable = timesabovehorizon(UTC_string, Alt_source);
var max_degree = Alt_source.filter(abovehorizon);
if(max_degree.length>=1){
total_text += "</br><h7 class=\"approved\">" + Obj + ": "+ observable + "</h7>";
};
if(max_degree.length==0){
total_text += "</br><h7 class=\"not_approved\">" + Obj + "</h7>";
};
}
total_text += "</ul>";
document.getElementById("total_text").innerHTML = total_text;
}
function toRadians(angle) {
return angle * (Math.PI / 180);
}
function abovehorizon(array) {
return array >= 30;
}
function timesabovehorizon(UTC, array){
var hours = []
var index = []
for (var i = 0; i < array.length; i++) {
if(array[i]>=30){
hours.push(UTC[i])
index.push(i)
}
}
var time_range = ""
if(index.length==1){
time_range += hours + "-" + UTC[index[0]+1]
}
if(index.length>1){
time_range += hours[0] + "-" + UTC[index[index.length-1]]
}
return time_range
}
function toDegrees(angle) {
return angle * (180 / Math.PI);
}
function RAtodegree(RA) {
hours = parseInt(RA.split("h")[0]); //multiply by 15
mins = parseInt(RA.split("h")[1].split("m")[0]);
secs = parseInt(RA.split("h")[1].split("m")[1].split("s")[0]);
todegree = (hours + (mins / 60) + (secs / 3600))*15
return todegree
}
function Dectodegree(RA) {
hours = parseInt(RA.split("d")[0]);
mins = parseInt(RA.split("d")[1].split("m")[0]);
secs = parseInt(RA.split("d")[1].split("m")[1].split("s")[0]);
todegree = hours + (mins / 60) + (secs / 3600)
return todegree
}
var EPS = 1.0e-12; // machine error constant
// right ascension, declination coordinate structure
function coord()
{
ra = parseFloat("0"); // right ascension [deg]
dec = parseFloat("0"); // declination [deg]
rvec = parseFloat("0"); // distance [AU]
}
// altitude, azimuth coordinate structure
function horizon()
{
alt = parseFloat("0"); // altitude [deg]
az = parseFloat("0"); // azimuth [deg]
}
// orbital element structure
function elem()
{
a = parseFloat("0"); // semi-major axis [AU]
e = parseFloat("0"); // eccentricity of orbit
i = parseFloat("0"); // inclination of orbit [deg]
O = parseFloat("0"); // longitude of the ascending node [deg]
w = parseFloat("0"); // longitude of perihelion [deg]
L = parseFloat("0"); // mean longitude [deg]
}
var pname = new Array("Mercury", "Venus ", "Sun ",
"Mars ", "Jupiter", "Saturn ",
"Uranus ", "Neptune", "Pluto ");
function get_coord( obj, p, d )
{
var planet = new elem();
mean_elements(planet, p, d);
var ap = planet.a;
var ep = planet.e;
var ip = planet.i;
var op = planet.O;
var pp = planet.w;
var lp = planet.L;
var earth = new elem();
mean_elements(earth, 2, d);
var ae = earth.a;
var ee = earth.e;
var ie = earth.i;
var oe = earth.O;
var pe = earth.w;
var le = earth.L;
// position of Earth in its orbit
var me = mod2pi(le - pe);
var ve = true_anomaly(me, ee);
var re = ae*(1 - ee*ee)/(1 + ee*Math.cos(ve));
// heliocentric rectangular coordinates of Earth
var xe = re*Math.cos(ve + pe);
var ye = re*Math.sin(ve + pe);
var ze = 0.0;
// position of planet in its orbit
var mp = mod2pi(lp - pp);
var vp = true_anomaly(mp, planet.e);
var rp = ap*(1 - ep*ep)/(1 + ep*Math.cos(vp));
// heliocentric rectangular coordinates of planet
var xh = rp*(Math.cos(op)*Math.cos(vp + pp - op) - Math.sin(op)*Math.sin(vp + pp - op)*Math.cos(ip));
var yh = rp*(Math.sin(op)*Math.cos(vp + pp - op) + Math.cos(op)*Math.sin(vp + pp - op)*Math.cos(ip));
var zh = rp*(Math.sin(vp + pp - op)*Math.sin(ip));
if (p == 2) // earth --> compute sun
{
xh = 0;
yh = 0;
zh = 0;
}
// convert to geocentric rectangular coordinates
var xg = xh - xe;
var yg = yh - ye;
var zg = zh - ze;
// rotate around x axis from ecliptic to equatorial coords
var ecl = toRadians(23.439281); //value for J2000.0 frame
var xeq = xg;
var yeq = yg*Math.cos(ecl) - zg*Math.sin(ecl);
var zeq = yg*Math.sin(ecl) + zg*Math.cos(ecl);
// find the RA and DEC from the rectangular equatorial coords
obj.ra = toDegrees(mod2pi(Math.atan2(yeq, xeq)));
obj.dec = toDegrees(Math.atan(zeq/Math.sqrt(xeq*xeq + yeq*yeq)));
}
// Compute the elements of the orbit for planet-i at day number-d
// result is returned in structure p
function mean_elements( p, i, d )
{
var cy = d/36525; // centuries since J2000
switch (i)
{
case 0: // Mercury
p.a = 0.38709893 + 0.00000066*cy;
p.e = 0.20563069 + 0.00002527*cy;
p.i = toRadians(( 7.00487 - 23.51*cy/3600));
p.O = toRadians(48.33167 - 446.30*cy/3600);
p.w = toRadians(77.45645 + 573.57*cy/3600);
p.L = mod2pi(toRadians((252.25084 + 538101628.29*cy/3600)));
break;
case 1: // Venus
p.a = 0.72333199 + 0.00000092*cy;
p.e = 0.00677323 - 0.00004938*cy;
p.i = toRadians(3.39471 - 2.86*cy/3600);
p.O = toRadians( 76.68069 - 996.89*cy/3600);
p.w = toRadians(131.53298 - 108.80*cy/3600);
p.L = mod2pi(toRadians((181.97973 + 210664136.06*cy/3600)));
break;
case 2: // Earth/Sun
p.a = 1.00000011 - 0.00000005*cy;
p.e = 0.01671022 - 0.00003804*cy;
p.i = toRadians( 0.00005 - 46.94*cy/3600);
p.O = toRadians(-11.26064 - 18228.25*cy/3600);
p.w = toRadians(102.94719 + 1198.28*cy/3600);
p.L = mod2pi(toRadians(100.46435 + 129597740.63*cy/3600));
break;
case 3: // Mars
p.a = 1.52366231 - 0.00007221*cy;
p.e = 0.09341233 + 0.00011902*cy;
p.i = toRadians( 1.85061 - 25.47*cy/3600);
p.O = toRadians( 49.57854 - 1020.19*cy/3600);
p.w = toRadians(336.04084 + 1560.78*cy/3600);
p.L = mod2pi(toRadians(355.45332 + 68905103.78*cy/3600));
break;
case 4: // Jupiter
p.a = 5.20336301 + 0.00060737*cy;
p.e = 0.04839266 - 0.00012880*cy;
p.i = toRadians( 1.30530 - 4.15*cy/3600);
p.O = toRadians(100.55615 + 1217.17*cy/3600);
p.w = toRadians( 14.75385 + 839.93*cy/3600);
p.L = mod2pi(toRadians(34.40438 + 10925078.35*cy/3600));
break;
case 5: // Saturn
p.a = 9.53707032 - 0.00301530*cy;
p.e = 0.05415060 - 0.00036762*cy;
p.i = toRadians( 2.48446 + 6.11*cy/3600);
p.O = toRadians(113.71504 - 1591.05*cy/3600);
p.w = toRadians( 92.43194 - 1948.89*cy/3600);
p.L = mod2pi(toRadians(49.94432 + 4401052.95*cy/3600));
break;
case 6: // Uranus
p.a = 19.19126393 + 0.00152025*cy;
p.e = 0.04716771 - 0.00019150*cy;
p.i = toRadians( 0.76986 - 2.09*cy/3600);
p.O = toRadians( 74.22988 - 1681.40*cy/3600);
p.w = toRadians(170.96424 + 1312.56*cy/3600);
p.L = mod2pi(toRadians(313.23218 + 1542547.79*cy/3600));
break;
case 7: // Neptune
p.a = 30.06896348 - 0.00125196*cy;
p.e = 0.00858587 + 0.00002510*cy;
p.i = toRadians( 1.76917 - 3.64*cy/3600);
p.O = toRadians(131.72169 - 151.25*cy/3600);
p.w = toRadians( 44.97135 - 844.43*cy/3600);
p.L = mod2pi(toRadians(304.88003 + 786449.21*cy/3600));
break;
case 8: // Pluto
p.a = 39.48168677 - 0.00076912*cy;
p.e = 0.24880766 + 0.00006465*cy;
p.i = toRadians( 17.14175 + 11.07*cy/3600);
p.O = toRadians(110.30347 - 37.33*cy/3600);
p.w = toRadians(224.06676 - 132.25*cy/3600);
p.L = mod2pi(toRadians(238.92881 + 522747.90*cy/3600));
break;
default:
window.alert("function mean_elements() failed!");
}
}
function true_anomaly( M, e )
{
var V, E1;
// initial approximation of eccentric anomaly
var E = M + e*Math.sin(M)*(1.0 + e*Math.cos(M));
do // iterate to improve accuracy
{
E1 = E;
E = E1 - (E1 - e*Math.sin(E1) - M)/(1 - e*Math.cos(E1));
}
while (Math.abs( E - E1 ) > EPS);
// convert eccentric anomaly to true anomaly
V = 2*Math.atan(Math.sqrt((1 + e)/(1 - e))*Math.tan(0.5*E));
if (V < 0) V = V + (2*Math.PI); // modulo 2pi
return V;
}
// converts hour angle in degrees into hour angle string
function ha2str( x )
{
var ra = x/15; // degrees to hours
var h = Math.floor(ra);
var m = Math.floor(60*(ra - h));
var s = (3600*(ra - h - m)).toFixed(2);
if(s<0){s=0.00};
return h + "h" + m + "m"+s+"s";
}
// return the integer part of a number
function abs_floor( x )
{
var r;
if (x >= 0.0) r = Math.floor(x);
else r = Math.ceil(x);
return r;
}
// return an angle in the range 0 to 2pi radians
function mod2pi(x)
{
var b = x/(2*Math.PI);
var a = (2*Math.PI)*(b - abs_floor(b));
if (a < 0) a = (2*Math.PI) + a;
return a;
}
function mean_sidereal_time( d, lon )
{
var year = d.getUTCFullYear();
var month = d.getUTCMonth() + 1;
var day = d.getUTCDate();
var hour = d.getUTCHours();
var minute = d.getUTCMinutes();
var second = d.getUTCSeconds();
if ((month == 1)||(month == 2))
{
year = year - 1;
month = month + 12;
}
var a = Math.floor(year/100);
var b = 2 - a + Math.floor(a/4);
var c = Math.floor(365.25*year);
var d = Math.floor(30.6001*(month + 1));
// days since J2000.0
var jd = b + c + d - 730550.5 + day
+ (hour + minute/60.0 + second/3600.0)/24.0;
// julian centuries since J2000.0
var jt = jd/36525.0;
// mean sidereal time
var mst = 280.46061837 + 360.98564736629*jd
+ 0.000387933*jt*jt - jt*jt*jt/38710000 + lon;
if (mst > 0.0)
{
while (mst > 360.0)
mst = mst - 360.0;
}
else
{
while (mst < 0.0)
mst = mst + 360.0;
}
return mst;
}
// format two digits with leading zero if needed
function d2( n )
{
if ((n < 0)||(99 < n)) return "xx";
return (n < 10) ? ("0" + n) : n;
}
</script>
</body>
</html>