Files
resonant-orbits-calculator/resonant-orbits.html
2021-06-29 13:55:42 -04:00

1657 lines
43 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, initial-scale=1">
<!--
MIT License
Copyright (c) 2018 Eric A. Meyer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software, and a link to the original URL
(https://meyerweb.com/eric/ksp/resonant-orbits/) will be provided in the
user interface.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<head>
<title>Resonant Orbit Calculator (Kerbal Space Program)</title>
<style type="text/css">
body {font: 1em Lucida Grande, Helvetica, Arial, sans-serif;}
body > * {box-sizing: border-box;}
#debug {background-color: rgba(255,255,0,0.2); white-space: pre-wrap;}
#text {margin: 0 15% 3em;}
#text h1 {font-size: 1.9em; letter-spacing: -0.05ch; margin-bottom: 0;}
#text h2 {font-size: smaller; text-transform: uppercase; opacity: 0.5; font-weight: 100; margin: 0.1em 0 1em;}
section {display: flex; justify-content: center;}
form h3 {font-size: 1em; border-left: 11em solid silver;
padding: 0.25em 0.5em 0; margin: 0 0 0.75em;}
form {font-size: 0.85em;}
form ul {margin: 0 0 2em; padding: 0;}
form ul li {display: flex; align-items: baseline; margin: 0.2em 0; justify-content: flex-start;}
form ul li > label {width: 11em; padding-right: 0.5em; text-align: right; color: rgba(0,0,0,0.67);}
form ul li input[type="checkbox"]:checked ~ label {display: block;}
form ul li span > label {display: none;}
form ul li span > label span {display: inline-block; width: 2.5em; color: rgba(0,0,0,0.6);}
form ul li input {margin-right: 0.25em; border-width: 0 0 1px; border-color: #999; border-style: solid; font-size: inherit;}
form ul li input[size="1"] {width: 3.5em;}
form ul li input[size="12"] {width: 8em;}
form ul li input[disabled] {color: inherit; background: inherit; border-width: 0 0 0;}
form ul li b[id*="set"] {font-size: 115%; line-height: 0.9; cursor: pointer;}
form ul li.button:hover {background: url(arrow-right.svg) 95% 50% / auto 0.8em no-repeat;
animation: remind 5s 0s linear alternate infinite;}
form ul li.button:hover b[id*="set"] {color: green;}
form ul li.button b[id*="set"]:hover {background-color: #EE0; border-radius: 50%;}
#parameters .warning {color: rgb(216,0,0);}
#parameters .urgent {font-weight: bold; background: yellow;}
#chart .warning {stroke: rgb(216,0,0);}
#constellation.warning {animation: flicker 2s linear alternate infinite;}
#parameters {flex-shrink: 0;}
#schematic {margin: 0 2em 0 1em; position: relative;}
#schematic > header:not(:empty) {position: absolute; top: 0; left: 0;
width: 100%; padding: 0.25em;
box-sizing: border-box;
font-size: smaller; text-align: center; white-space: pre-wrap; line-height: 1.3;
color: rgba(0,0,0,0.5); background: hsla(120,20%,80%,0.75);
}
#chart {border: 1px solid rgba(0,0,0,0.1); height: 500px; width: 500px; background: #EEE;}
#chart {display: block; margin: 0 auto;}
#chart textPath tspan {fill: #555;}
#chart textPath:hover tspan {fill: #333;}
#setGeo, #setLOS {cursor: pointer;}
footer {padding: 0.5em 0.25em; border-top: 1px solid silver; margin-top: 5em;
font-size: smaller; color: rgba(0,0,0,0.5);}
footer p {margin: 0; line-height: 1.5; text-align: center;}
@supports (display: grid) {
body {display: grid;
grid-template-columns: min-content;
justify-content: center;}
#text {margin: 0 0 1em;}
}
@media (max-width: 850px) {
body {display: block;}
#schematic {width: 50vw;}
#chart {width: 100%; height: auto;}
}
@media (max-width: 650px) {
body {display: flex; flex-direction: column; align-items: center;}
#text {order: 10; padding: 1em; margin: 0;}
#text h1 {font-size: 1.5em;}
section {display: block;}
form ul li input {border-width: 1px; border-color: black; background: #FFE;}
#schematic {width: 100vw; margin: 0;}
#chart {border-width: 1px 0;}
footer {order: 20; margin-top: 1em;}
}
@keyframes remind {
95% {background-position: 95% 50%;}
98% {background-position: 94% 50%;}
100% {background-position: 95% 50%;}
}
@keyframes flicker {
0% {opacity: 1;}
20% {opacity: 1;}
33% {opacity: 0;}
46% {opacity: 0.5;}
69% {opacity: 0.25;}
62% {opacity: 0.67;}
78% {opacity: 0.67;}
80% {opacity: 1;}
100% {opacity: 1;}
}
</style>
</head>
<body>
<div id="text">
<h1>Resonant Orbit Calculator</h1>
<h2>For Kerbal Space Program <span></span></h2>
<p>
Calculate the resonant orbit needed for a carrier craft to inject craft it carries, like satellites, into equidistant positions of a shared circular orbit. This is useful for setting up things like <a href="https://wiki.kerbalspaceprogram.com/wiki/CommNet">CommNet</a> constellations. The “Injection Δv” value is the delta-v required to move from the resonant orbit to the final (circular) orbit.
</p>
</div>
<section>
<form id="parameters">
<h3>Parameters</h3>
<ul id="inputs">
<li>
<label for="systlist">System</label> <span>
<select id="systlist"></select>
</span></li>
<li><label for="bodylist">Celestial body</label> <span>
<select id="bodylist" autofocus></select>
</span></li>
<li><label for="satellites">Number of satellites</label> <span><input type="number" id="satellites" size="1" step="1" min="1" value="3"></span></li>
<li><label for="altitude">Orbital altitude</label> <span><input type="text" id="altitude" size="12">m</span></li>
<li><label>Orbital period</label> <span><input type="text" id="period" size="12" disabled></span></li>
<li class="button"><label>Synchronous orbit</label> <span><input type="text" id="synchrorbit" size="12" disabled></span><b id="setsync"></b></li>
<li class="button"><label>Minimum <acronym title="Line-of-Sight">LOS</acronym> orbit</label> <span><input type="text" id="losorbit" size="12" disabled></span><b id="setmin"></b></li>
<li><label for="flipLOS">Show <acronym title="Line-of-Sight">LOS</acronym> lines</label> <span><input type="checkbox" id="flipLOS"></span></li>
<li><label for="flipOcc">Occlusion modifiers</label> <span><input type="checkbox" id="flipOcc">
<label for="atmOcclusion"><span>Atm.</span><input type="number" id="atmOcclusion" size="1" min="0" max="1.1" step="0.01" value="0.75"></label>
<label for="vacOcclusion"><span>Vac.</span><input type="number" id="vacOcclusion" size="1" min="0" max="1.1" step="0.01" value="0.9"></label>
</span></li>
</ul>
<h3>Resonant orbit</h3>
<ul id="outputs">
<li><label for="fliporbit">Dive orbit</label> <span><input type="checkbox" id="fliporbit"></span></li>
<li><label>Orbital Period</label> <span><input type="text" id="carrierT" size="12" disabled></span></span></li>
<li><label>Apoapsis</label> <span><input type="text" id="carrierAp" size="12" disabled></span></span></li>
<li><label>Periapsis</label> <span><input type="text" id="carrierPe" size="12" disabled></span></span></li>
<li><label>Injection Δv</label> <span><input type="text" id="burnDV" size="10" disabled></span></span></li>
</ul>
<div id="debug"></div>
</form>
<div id="schematic">
<header></header>
<svg viewBox="0 0 1000 1000" xmlns="http://www.w3.org/2000/svg" id="chart">
<circle cx="50%" cy="50%" r="0" fill="#FFF" stroke="#CCC" stroke-dasharray="15,15" stroke-width="2" id="bodySOI" />
<path d="" fill="none" stroke-width="0" stroke="red" id="bodySOIlabel" />
<text text-anchor="middle" font-size="24" fill="#888">
<textpath xlink:href="#lineofsightlabel" startOffset="50%" id="setLOS">Minimum LOS orbit <tspan id="msa"></tspan>m</textpath>
</text>
<text text-anchor="middle" font-size="24" fill="#888">
<textpath xlink:href="#geosynclabel" startOffset="50%" id="setGeo">Synchronous orbit <tspan id="syncm"></tspan>m</textpath>
</text>
<text text-anchor="middle" font-size="24" fill="#888">
<textpath xlink:href="#bodySOIlabel" startOffset="50%">Sphere of Influence <tspan id="SOId"></tspan>m</textpath>
</text>
<circle cx="50%" cy="50%" r="0" fill="#0001" id="atmosphere" />
<circle cx="50%" cy="50%" r="0" fill="none" stroke="#999" stroke-width="2" stroke-dasharray="10,10" id="lineofsight" />
<path d="" fill="none" stroke-width="0" stroke="red" id="lineofsightlabel" />
<circle cx="50%" cy="50%" r="0" fill="none" stroke="#999" stroke-width="2" stroke-dasharray="10,10" id="geosync" />
<path d="" fill="none" stroke-width="0" stroke="red" id="geosynclabel" />
<circle cx="50%" cy="50%" r="0" fill="none" stroke="goldenrod" stroke-width="1.5" id="satelliteorbit" />
<path d="" fill="none" stroke-width="2" stroke="green" id="carrierorbit" />
<circle cx="50%" cy="-100" r="10" fill="tan" id="launchpoint" />
<circle cx="50%" cy="50%" r="0" fill="#666" id="body" />
<path d="" fill="none" stroke-width="3" stroke="#0C0" opacity="0.5" id="constellation" />
</svg>
</div>
</section>
<footer>
<p>Provided by <a href="https://meyerweb.com/">Eric Meyer</a> under the <a href="https://choosealicense.com/licenses/mit/">MIT License</a>. See source for terms and details.</p>
<p>Originally released 2017-02-04 • v1.4 released 2018-01-10</p>
<p><a href="https://forum.kerbalspaceprogram.com/index.php?/topic/156018-resonant-orbit-calculator/">KSP Forum thread</a></p>
</footer>
</body>
<script type="text/javascript">
/*
Configuration data for the Resonant Orbit Calculator v1.3 (https://meyerweb.com/eric/ksp/resonant-orbits/).
The following are REQUIRED for each body:
"color": "six-digit hexadecimal RGB value" (e.g. white = #FFFFFF), MUST be quoted
"mass": mass, in kilograms (E+ notation preferred but not required)
"eqr": equatorial radius, in meters
"day": rotational period (i.e., length of a day), in seconds; use negative for retrograde spin (e.g., Venus)
"atm": outer edge of the atmosphere, in meters; use 0 if there is no atmosphere
"SOI": the sphere of influence radius, in meters; use 1E+15 or higher for the system's central sun
The color values were chosen based on the in-game appearance of each planet, NOT the orbit color in Map view.
The following is OPTIONAL:
"default": true|false
this is the body that should be the default for the system; if no body chosen, the first listed will be used
only ONE body should be marked default
You can add other properties if you feel like it, but they’ll be ignored.
*/
var systems = {
"KSP Stock" : {
"Kerbol": {
"color": "#FE9",
"mass": 1.7565459E+28,
"eqr": 261600000,
"day": 432000,
"atm": 600000,
"SOI": 1E+15
},
"Moho": {
"color": "#80736B",
"mass": 2.52633139930162E+21,
"eqr": 250000,
"day": 1210000,
"atm": 0,
"SOI": 9646663.02332811
},
"Eve": {
"color": "#897695",
"mass": 1.2243980038014E+23,
"eqr": 700000,
"day": 80500,
"atm": 90000,
"SOI": 85109364.7382441
},
"Gilly": {
"color": "#867D78",
"mass": 1.24203632781093E+17,
"eqr": 13000,
"day": 28255,
"atm": 0,
"SOI": 126123.271704568
},
"Kerbin": {
"default": true,
"color": "#495B66",
"mass": 5.29151583439215E+22,
"eqr": 600000,
"day": 21549.4251830898,
"atm": 70000,
"SOI": 84159286.4796305
},
"Mun": {
"color": "#888",
"mass": 9.7599066119646E+20,
"eqr": 200000,
"day": 138984.376574476,
"atm": 0,
"SOI": 2429559.11656475
},
"Minmus": {
"color": "#9BB4A5",
"mass": 2.64575795662095E+19,
"eqr": 60000,
"day": 40400,
"atm": 0,
"SOI": 2247428.3879023
},
"Duna": {
"color": "#905646",
"mass": 4.51542702477492E+21,
"eqr": 320000,
"day": 65517.859375,
"atm": 50000,
"SOI": 47921949.369738
},
"Ike": {
"color": "#888",
"mass": 2.78216152235874E+20,
"eqr": 130000,
"day": 65517.8621348081,
"atm": 0,
"SOI": 1049598.93931162
},
"Dres": {
"color": "#878482",
"mass": 3.21909365785247E+20,
"eqr": 138000,
"day": 34800,
"atm": 0,
"SOI": 32832839.5767762
},
"Jool": {
"color": "#708D4B",
"mass": 4.23321273059351E+24,
"eqr": 6000000,
"day": 36000,
"atm": 200000,
"SOI": 2455985185.42347
},
"Laythe": {
"color": "#5C6068",
"mass": 2.93973106291216E+22,
"eqr": 500000,
"day": 52980.8790593796,
"atm": 50000,
"SOI": 3723645.81113302
},
"Vall": {
"color": "#879192",
"mass": 3.10876554482042E+21,
"eqr": 300000,
"day": 105962.088893924,
"atm": 0,
"SOI": 2406401.44479404
},
"Tylo": {
"color": "#9B9894",
"mass": 4.23321273059351E+22,
"eqr": 600000,
"day": 211926.35802123,
"atm": 0,
"SOI": 10856518.3683586
},
"Bop": {
"color": "#655D57",
"mass": 3.72610898343278E+19,
"eqr": 65000,
"day": 544507.428516654,
"atm": 0,
"SOI": 1221060.86284253
},
"Pol": {
"color": "#938C7E",
"mass": 1.08135065806823E+19,
"eqr": 44000,
"day": 901902.623531173,
"atm": 0,
"SOI": 1042138.89230178
},
"Eeloo": {
"color": "#959B9B",
"mass": 1.1149224E+21,
"eqr": 210000,
"day": 19460,
"atm": 0,
"SOI": 119082941.6
}
},
"Outer Planets Mod" : {
"Kerbol": {
"color": "#FE9",
"mass": 1.7565459E+28,
"eqr": 261600000,
"day": 432000,
"atm": 600000,
"SOI": 1E+15
},
"Moho": {
"color": "#80736B",
"mass": 2.52633139930162E+21,
"eqr": 250000,
"day": 1210000,
"atm": 0,
"SOI": 9646663.02332811
},
"Eve": {
"color": "#897695",
"mass": 1.2243980038014E+23,
"eqr": 700000,
"day": 80500,
"atm": 90000,
"SOI": 85109364.7382441
},
"Gilly": {
"color": "#867D78",
"mass": 1.24203632781093E+17,
"eqr": 13000,
"day": 28255,
"atm": 0,
"SOI": 126123.271704568
},
"Kerbin": {
"default": true,
"color": "#495B66",
"mass": 5.29151583439215E+22,
"eqr": 600000,
"day": 21549.4251830898,
"atm": 70000,
"SOI": 84159286.4796305
},
"Mun": {
"color": "#888",
"mass": 9.7599066119646E+20,
"eqr": 200000,
"day": 138984.376574476,
"atm": 0,
"SOI": 2429559.11656475
},
"Minmus": {
"color": "#9BB4A5",
"mass": 2.64575795662095E+19,
"eqr": 60000,
"day": 40400,
"atm": 0,
"SOI": 2247428.3879023
},
"Duna": {
"color": "#905646",
"mass": 4.51542702477492E+21,
"eqr": 320000,
"day": 65517.859375,
"atm": 50000,
"SOI": 47921949.369738
},
"Ike": {
"color": "#888",
"mass": 2.78216152235874E+20,
"eqr": 130000,
"day": 65517.8621348081,
"atm": 0,
"SOI": 1049598.93931162
},
"Dres": {
"color": "#878482",
"mass": 3.21909365785247E+20,
"eqr": 138000,
"day": 34800,
"atm": 0,
"SOI": 32832839.5767762
},
"Jool": {
"color": "#708D4B",
"mass": 4.23321273059351E+24,
"eqr": 6000000,
"day": 36000,
"atm": 200000,
"SOI": 2455985185.42347
},
"Laythe": {
"color": "#5C6068",
"mass": 2.93973106291216E+22,
"eqr": 500000,
"day": 52980.8790593796,
"atm": 50000,
"SOI": 3723645.81113302
},
"Vall": {
"color": "#879192",
"mass": 3.10876554482042E+21,
"eqr": 300000,
"day": 105962.088893924,
"atm": 0,
"SOI": 2406401.44479404
},
"Tylo": {
"color": "#9B9894",
"mass": 4.23321273059351E+22,
"eqr": 600000,
"day": 211926.35802123,
"atm": 0,
"SOI": 10856518.3683586
},
"Bop": {
"color": "#655D57",
"mass": 3.72610898343278E+19,
"eqr": 65000,
"day": 544507.428516654,
"atm": 0,
"SOI": 1221060.86284253
},
"Pol": {
"color": "#938C7E",
"mass": 1.08135065806823E+19,
"eqr": 44000,
"day": 901902.623531173,
"atm": 0,
"SOI": 1042138.89230178
},
"Sarnus": {
"color": "#888",
"mass": 1.22997779398809E+24,
"eqr": 5300000,
"day": 28500,
"atm": 580000,
"SOI": 2740126708.15753
},
"Hale": {
"color": "#888",
"mass": 1.21663303406612E+16,
"eqr": 6000,
"day": 23555.3138379232,
"atm": 0,
"SOI": 41000
},
"Ovok": {
"color": "#888",
"mass": 1.98657954354758E+17,
"eqr": 26000,
"day": 29440.1470076036,
"atm": 0,
"SOI": 94000
},
"Eeloo": {
"color": "#888",
"mass": 1.11492242417007E+21,
"eqr": 210000,
"day": 57914.7837330607,
"atm": 0,
"SOI": 1159066.15680512
},
"Slate": {
"color": "#D1B7A1",
"mass": 2.96498760110757E+22,
"eqr": 540000,
"day": 192771.154552164,
"atm": 0,
"SOI": 9598158.64601184
},
"Tekto": {
"color": "#888",
"mass": 2.88340853582816E+21,
"eqr": 280000,
"day": 666154.482822571,
"atm": 95000,
"SOI": 8637005.19544461
},
"Urlum": {
"color": "#CBDFE6",
"mass": 1.7896959235771E+23,
"eqr": 2177000,
"day": 41000,
"atm": 325000,
"SOI": 2562260673.07757
},
"Polta": {
"color": "#8DAB9E",
"mass": 1.3512267368686E+21,
"eqr": 220000,
"day": 73017.1106367597,
"atm": 0,
"SOI": 1661114.85305207
},
"Priax": {
"color": "#6D6A64",
"mass": 5.0691279849807E+19,
"eqr": 74000,
"day": 73017.1106367597,
"atm": 0,
"SOI": 446767.601978615
},
"Wal": {
"color": "#84724C",
"mass": 7.44276727953516E+21,
"eqr": 370000,
"day": 1009410.78951369,
"atm": 0,
"SOI": 18933504.6847765
},
"Tal": {
"color": "#7D7361",
"mass": 3.20027385047827E+18,
"eqr": 22000,
"day": 48874.4834835978,
"atm": 0,
"SOI": 139966.651259813
},
"Neidon": {
"color": "#B697FD",
"mass": 2.1228216518685E+23,
"eqr": 2145000,
"day": 40250,
"atm": 260000,
"SOI": 4415723830.49107
},
"Thatmo": {
"color": "#D5D6DA",
"mass": 2.78836304732338E+21,
"eqr": 286000,
"day": 306442.674516556,
"atm": 35000,
"SOI": 5709379.08853188
},
"Nissee": {
"color": "#D7CDBE",
"mass": 5.95092244923645E+18,
"eqr": 30000,
"day": 27924.8723,
"atm": 0,
"SOI": 7366476.63525513
},
"Plock": {
"color": "#B59676",
"mass": 7.76809612833529E+20,
"eqr": 189000,
"day": 106309.606989054,
"atm": 0,
"SOI": 612762335.918708
},
"Karen": {
"color": "#8F7D74",
"mass": 7.01490572670278E+19,
"eqr": 85050,
"day": 106327.763381606,
"atm": 0,
"SOI": 939354.324277521
}
},
"Real Solar System" : {
"Sun": {
"color": "#FCD440",
"mass": 1.988E+30,
"eqr": 696392000,
"day": 432000,
"atm": 600000,
"SOI": 1E+18
},
"Mercury": {
"color": "#52515A",
"mass": 3.3022E+23,
"eqr": 2439700,
"day": 5067031.68,
"atm": 0,
"SOI": 112424173.3
},
"Venus": {
"color": "#B36229",
"mass": 4.86747E+24,
"eqr": 6049000,
"day": -20996797.02,
"atm": 145000,
"SOI": 616281980.7
},
"Earth": {
"default": true,
"color": "#004763",
"mass": 5.97237E+24,
"eqr": 6371000,
"day": 86164.0989,
"atm": 140000,
"SOI": 924650434.7
},
"Moon": {
"color": "#E1E1E1",
"mass": 7.34767E+22,
"eqr": 1737100,
"day": 2356558.618,
"atm": 0,
"SOI": 66173072.96
},
"Mars": {
"color": "#A16331",
"mass": 6.41711E+23,
"eqr": 3375800,
"day": 88642.6848,
"atm": 125000,
"SOI": 577254493.5
},
"Phobos": {
"color": "#8F7463",
"mass": 1.072E+16,
"eqr": 7250,
"day": 27575.06417,
"atm": 0,
"SOI": 47250
},
"Deimos": {
"color": "#765F50",
"mass": 1.48E+15,
"eqr": 5456,
"day": 109082.8775,
"atm": 0,
"SOI": 45456
},
"Jupiter": {
"color": "#BF9766",
"mass": 1.89819E+27,
"eqr": 70941833.42,
"day": 35730,
"atm": 1550000,
"SOI": 48196239907
},
"Io": {
"color": "#958065",
"mass": 8.9319E+22,
"eqr": 1811300,
"day": 153039.6428,
"atm": 0,
"SOI": 7841031.532
},
"Europa": {
"color": "#685743",
"mass": 4.7998E+22,
"eqr": 1550800,
"day": 307002.3723,
"atm": 0,
"SOI": 9728374.712
},
"Ganymede": {
"color": "#A5A15D",
"mass": 1.4819E+23,
"eqr": 2624100,
"day": 618553.2791,
"atm": 0,
"SOI": 24361825.13
},
"Callisto": {
"color": "#C6C7AD",
"mass": 1.07594E+23,
"eqr": 2409300,
"day": 1443315.918,
"atm": 0,
"SOI": 37706560.89
},
"Saturn": {
"color": "#EAD8B5",
"mass": 5.68336E+26,
"eqr": 59216476.99,
"day": 38052,
"atm": 2000000,
"SOI": 54475373438
},
"Mimas": {
"color": "#E1E1E1",
"mass": 3.7493E+19,
"eqr": 198200,
"day": 81843.87407,
"atm": 0,
"SOI": 396400
},
"Enceladus": {
"color": "#E1E1E1",
"mass": 1.08022E+20,
"eqr": 252100,
"day": 118762.9628,
"atm": 0,
"SOI": 504200
},
"Tethys": {
"color": "#E1E1E1",
"mass": 6.17449E+20,
"eqr": 531100,
"day": 163440.0316,
"atm": 0,
"SOI": 1213895.698
},
"Dione": {
"color": "#E1E1E1",
"mass": 1.09545E+21,
"eqr": 561400,
"day": 236765.9216,
"atm": 0,
"SOI": 1954724.558
},
"Rhea": {
"color": "#E1E1E1",
"mass": 2.30652E+21,
"eqr": 763800,
"day": 390536.924,
"atm": 0,
"SOI": 3675585.654
},
"Titan": {
"color": "#B38040",
"mass": 1.34522E+23,
"eqr": 2573300,
"day": 1377912.606,
"atm": 600000,
"SOI": 43324648.46
},
"Iapetus": {
"color": "#E1E1E1",
"mass": 1.805E+21,
"eqr": 734500,
"day": 6853119.643,
"atm": 0,
"SOI": 22501874.86
},
"Uranus": {
"color": "#6194C7",
"mass": 8.68125E+25,
"eqr": 24893873.43,
"day": 62063.712,
"atm": 1400000,
"SOI": 51692538810
},
"Neptune": {
"color": "#315591",
"mass": 1.02434E+26,
"eqr": 24223903.01,
"day": 58000.32,
"atm": 1250000,
"SOI": 86643720667
},
"Triton": {
"color": "#E1E1E1",
"mass": 2.13947E+22,
"eqr": 1353400,
"day": -507728.9877,
"atm": 110000,
"SOI": 11964329.55
},
"Pluto": {
"color": "#AD9179",
"mass": 1.305E+22,
"eqr": 1187000,
"day": 552731.9654,
"atm": 110000,
"SOI": 3116527989
},
"Charon": {
"color": "#E1E1E1",
"mass": 1.52E+21,
"eqr": 603500,
"day": 552731.9654,
"atm": 0,
"SOI": 8292108.138
}
},
"Galileo’s Planet Pack" : {
"Ciro": {
"color": "#FF9",
"mass": 1.9023392400E+28,
"eqr": 70980000,
"day": 540000,
"atm": 1600000,
"SOI": 1E+15
},
"Icarus": {
"color": "#696559",
"mass": 6.0185131734E+20,
"eqr": 160000,
"day": 766931.0655,
"atm": 0,
"SOI": 3491161.222
},
"Thalia": {
"color": "#5E2E1B",
"mass": 3.2134981226E+21,
"eqr": 270000,
"day": 72000,
"atm": 0,
"SOI": 13645687.92
},
"Eta": {
"color": "#807B73",
"mass": 2.6448544219E+19,
"eqr": 60000,
"day": 515362.4882,
"atm": 0,
"SOI": 1656715.488
},
"Niven": {
"color": "#7E6247",
"mass": 1.1754908542E+22,
"eqr": 400000,
"day": 43200,
"atm": 65000,
"SOI": 34386218.42
},
"Gael": {
"default": true,
"color": "#527D7D",
"mass": 5.2897088438E+22,
"eqr": 600000,
"day": 21549.41452,
"atm": 70000,
"SOI": 83667623.55
},
"Iota": {
"color": "#9EA09E",
"mass": 1.2489590326E+20,
"eqr": 100000,
"day": 495456.2682,
"atm": 0,
"SOI": 2491177.09
},
"Ceti": {
"color": "#5D5655",
"mass": 4.4631918369E+20,
"eqr": 150000,
"day": 1363993.543,
"atm": 0,
"SOI": 8144195.754
},
"Tellumo": {
"color": "#4D6D88",
"mass": 2.7917907787E+23,
"eqr": 1000000,
"day": 57600,
"atm": 45000,
"SOI": 260440071.5
},
"Lili": {
"color": "#48443E",
"mass": 4.3199288891E+16,
"eqr": 7000,
"day": 2554.684189,
"atm": 0,
"SOI": 40000
},
"Gratian": {
"color": "#906042",
"mass": 3.3336185942E+22,
"eqr": 550000,
"day": 139245.7813,
"atm": 50000,
"SOI": 194786348.7
},
"Geminus": {
"color": "#46413C",
"mass": 1.7100453201E+21,
"eqr": 230000,
"day": 139245.7813,
"atm": 0,
"SOI": 3139597.025
},
"Otho": {
"color": "#AD8151",
"mass": 1.6559727408E+24,
"eqr": 3500000,
"day": 50400,
"atm": 600000,
"SOI": 1701552278
},
"Augustus": {
"color": "#CC9770",
"mass": 6.2998962966E+21,
"eqr": 350000,
"day": 53456.75179,
"atm": 60000,
"SOI": 2153486.147
},
"Hephaestus": {
"color": "#5C4E3D",
"mass": 1.8367044596E+20,
"eqr": 125000,
"day": 108188.8589,
"atm": 0,
"SOI": 837807.8343
},
"Jannah": {
"color": "#473C2D",
"mass": 1.0529826667E+20,
"eqr": 105000,
"day": 313204.2218,
"atm": 0,
"SOI": 1362261.78
},
"Gauss": {
"color": "#70807F",
"mass": 9.4590279672E+23,
"eqr": 2500000,
"day": 61200,
"atm": 400000,
"SOI": 2652003276
},
"Loki": {
"color": "#4D4842",
"mass": 4.7607379594E+20,
"eqr": 180000,
"day": 62924.31582,
"atm": 0,
"SOI": 886957.5516
},
"Catullus": {
"color": "#907E7E",
"mass": 1.9042951838E+23,
"eqr": 1200000,
"day": 340308.8105,
"atm": 280000,
"SOI": 30021332.15
},
"Tarsiss": {
"color": "#645A52",
"mass": 2.5578680987E+21,
"eqr": 320000,
"day": 25902.63259,
"atm": 130000,
"SOI": 1070061.653
},
"Nero": {
"color": "#9E715D",
"mass": 3.5632066517E+24,
"eqr": 5000000,
"day": 39600,
"atm": 560000,
"SOI": 8835394858
},
"Hadrian": {
"color": "#595D60",
"mass": 2.3803689797E+21,
"eqr": 300000,
"day": 66949.22302,
"atm": 80000,
"SOI": 1610803.495
},
"Narisse": {
"color": "#4D3F38",
"mass": 4.7607379594E+19,
"eqr": 90000,
"day": 135495.7007,
"atm": 0,
"SOI": 538982.3508
},
"Muse": {
"color": "#737063",
"mass": 1.9865795435E+20,
"eqr": 130000,
"day": 291540.329,
"atm": 0,
"SOI": 1590728.15
},
"Minona": {
"color": "#6C625C",
"mass": 1.2695301225E+20,
"eqr": 120000,
"day": 639093.3695,
"atm": 0,
"SOI": 2244163.881
},
"Agrippina": {
"color": "#4E5047",
"mass": 1.1020226758E+19,
"eqr": 50000,
"day": 28800,
"atm": 0,
"SOI": 5002991.847
},
"Julia": {
"color": "#736D5D",
"mass": 1.9836408164E+18,
"eqr": 30000,
"day": 36000,
"atm": 0,
"SOI": 5118022.32
},
"Hox": {
"color": "#6F6B69",
"mass": 1.2856931217E+21,
"eqr": 250000,
"day": 64800,
"atm": 40000,
"SOI": 567558458
},
"Argo": {
"color": "#606069",
"mass": 3.2913743917E+19,
"eqr": 80000,
"day": 947939.2886,
"atm": 0,
"SOI": 2885399.812
},
"Leto": {
"color": "#67686B",
"mass": 7.7758720003E+20,
"eqr": 210000,
"day": 21600,
"atm": 35000,
"SOI": 600295990.2
},
"Grannus": {
"color": "#FF3300",
"mass": 9.5494442933E+27,
"eqr": 30170000,
"day": 1296000,
"atm": 400000,
"SOI": 5E+11
},
"Sarnus": {
"color": "#E59F88",
"mass": 1.2299777940E+24,
"eqr": 5300000,
"day": 28500,
"atm": 580000,
"SOI": 3496577901
},
"Hale": {
"color": "#C4B3AF",
"mass": 1.2166330341E+16,
"eqr": 6000,
"day": 23555.31384,
"atm": 0,
"SOI": 41000
},
"Ovok": {
"color": "#CECCCA",
"mass": 1.9865795435E+17,
"eqr": 26000,
"day": 29440.14701,
"atm": 0,
"SOI": 94000
},
"Eeloo": {
"color": "#8F9394",
"mass": 1.1149224242E+21,
"eqr": 210000,
"day": 57914.78373,
"atm": 0,
"SOI": 1159066.157
},
"Slate": {
"color": "#D1B7A1",
"mass": 2.9649876011E+22,
"eqr": 540000,
"day": 192771.1546,
"atm": 0,
"SOI": 9598158.646
},
"Tekto": {
"color": "#888",
"mass": 2.8834085358E+21,
"eqr": 280000,
"day": 666154.4828,
"atm": 95000,
"SOI": 8637005.195
},
"Urlum": {
"color": "#CBDFE6",
"mass": 1.7896959236E+23,
"eqr": 2177000,
"day": 41000,
"atm": 325000,
"SOI": 2517599239
},
"Polta": {
"color": "#8DAB9E",
"mass": 1.3512267369E+21,
"eqr": 220000,
"day": 73017.11064,
"atm": 0,
"SOI": 1661114.853
},
"Priax": {
"color": "#6D6A64",
"mass": 5.0691279850E+19,
"eqr": 74000,
"day": 73017.11064,
"atm": 0,
"SOI": 446767.602
},
"Wal": {
"color": "#84724C",
"mass": 7.4427672795E+21,
"eqr": 370000,
"day": 1009410.79,
"atm": 0,
"SOI": 18933504.68
},
"Tal": {
"color": "#7D7361",
"mass": 3.2002738505E+18,
"eqr": 22000,
"day": 48874.48348,
"atm": 0,
"SOI": 139966.6513
},
"Neidon": {
"color": "#B697FD",
"mass": 2.1228216519E+23,
"eqr": 2145000,
"day": 40250,
"atm": 260000,
"SOI": 3944323312
},
"Thatmo": {
"color": "#D5D6DA",
"mass": 2.7883630473E+21,
"eqr": 286000,
"day": 306442.6745,
"atm": 35000,
"SOI": 5709379.089
},
"Nissee": {
"color": "#D7CDBE",
"mass": 5.9509224492E+18,
"eqr": 30000,
"day": 27924.8723,
"atm": 0,
"SOI": 7366476.635
},
"Plock": {
"color": "#B59676",
"mass": 7.7680961283E+20,
"eqr": 189000,
"day": 106309.607,
"atm": 0,
"SOI": 586443111.1
},
"Karen": {
"color": "#8F7D74",
"mass": 7.0149057267E+19,
"eqr": 85050,
"day": 106327.7634,
"atm": 0,
"SOI": 939354.3243
}
}
};
</script>
<script type="text/javascript">
var body = {};
function bodydef(t) {
this.color = t.color;
this.eqr = t.eqr;
this.mass = t.mass;
this.rot = t.day;
this.atm = t.atm;
this.SOI = t.SOI;
}
Object.defineProperties(bodydef.prototype, {
"GM": {get: function() {
return this.mass * 6.67408E-11;
}},
"geoSMA": { get: function() {
if (this.rot) return Math.round(Math.pow( ((this.GM * Math.pow(this.rot,2)) / 39.4784176) , 1/3 ));
else return false;
}},
"geoAlt": { get: function() {
return this.geoSMA - this.eqr;
}},
"SOIAlt": { get: function() {
return this.SOI - this.eqr;
}},
});
function orbitdef(Ap,Pe,body) {
this.Ap = Ap;
this.Pe = Pe;
this.body = body;
}
Object.defineProperties(orbitdef.prototype, {
"GM": { get: function() { return this.body.GM; }},
"eqr": { get: function() { return this.body.eqr; }},
"MA": { get: function() { return this.Ap + this.Pe + 2*this.eqr; }},
"SMA": { get: function() { return this.MA/2; }},
"ma": { get: function() { return this.MA * Math.sqrt(1 - (Math.pow(this.e,2))); }},
"sma": { get: function() { return this.ma/2; }},
"ApR": { get: function() { return this.Ap + this.eqr; }},
"PeR": { get: function() { return this.Pe + this.eqr; }},
"PeV": { get: function() { return Math.sqrt((2 * this.ApR * this.GM) / (this.MA * this.PeR)); }},
"ApV": { get: function() { return Math.sqrt((2 * this.PeR * this.GM) / (this.MA * this.ApR)); }},
"e": { get: function() { return ((this.PeR * Math.pow(this.PeV,2)) / this.GM) - 1; }},
"F": { get: function() { return Math.sqrt(Math.pow(this.SMA,2) - Math.pow(this.sma,2)); }},
"T": { get: function() { return 2 * Math.PI * Math.sqrt(Math.pow(this.SMA,3) / this.GM); }},
"op": { get: function() { return this.T/3600; }},
"oph": { get: function() {
var hours = Math.floor(this.op);
var min = Math.floor((this.op - hours) * 60);
var sec = Math.round(10 * (this.op - hours - min/60) * 3600) / 10;
var time = hours + "h:" + min + "m:" + sec +"s";
return time;
}},
"newMAfromT": {get: function(newT) { return 2 * Math.cbrt( (this.GM * Math.pow(newT,2)) / 39.4784176 ); }},
// 39.4784176 = 4π^2
"setAp": { set: function(alt) { this.Ap = alt; }},
"setPe": { set: function(alt) { this.Pe = alt; }},
"modifyAp": { set: function(newMA) { this.setAp = this.Ap + (newMA - this.MA); }},
"modifyPe": { set: function(newMA) { this.setPe = this.Pe - (this.MA - newMA); }},
});
function newMAfromT(T,body) {
return 2 * Math.cbrt( (body.GM * Math.pow(T,2)) / 39.4784176 ); // 39.4784176 = 4π^2
}
var inputs = {
"systlist": document.getElementById("systlist"),
"bodylist": document.getElementById("bodylist"),
"altitude": document.getElementById("altitude"),
"satellites": document.getElementById("satellites"),
"fliporbit": document.getElementById("fliporbit"),
"flipLOS": document.getElementById("flipLOS"),
"atmOcclusion": document.getElementById("atmOcclusion"),
"vacOcclusion": document.getElementById("vacOcclusion"),
"flipOcc": document.getElementById("flipOcc"),
"setsync": document.getElementById("setsync"),
"setmin": document.getElementById("setmin"),
};
var outputs = {
"period": document.getElementById("period"),
"synchrorbit": document.getElementById("synchrorbit"),
"losorbit": document.getElementById("losorbit"),
"carrierAp": document.getElementById("carrierAp"),
"carrierPe": document.getElementById("carrierPe"),
"carrierT": document.getElementById("carrierT"),
"burnDV": document.getElementById("burnDV"),
"sorbit": document.getElementById("satelliteorbit"),
"corbit": document.getElementById("carrierorbit"),
"chart": document.getElementById("chart"),
};
var chart = {
"body": document.getElementById("body"),
"bodySOI": document.getElementById("bodySOI"),
"bodySOIlabel": document.getElementById("bodySOIlabel"),
"SOId": document.getElementById("SOId"),
"geosync": document.getElementById("geosync"),
"geosynclabel": document.getElementById("geosynclabel"),
"syncm": document.getElementById("syncm"),
"lineofsight": document.getElementById("lineofsight"),
"lineofsightlabel": document.getElementById("lineofsightlabel"),
"msa": document.getElementById("msa"),
"atmosphere": document.getElementById("atmosphere"),
"satellite": document.getElementById("satelliteorbit"),
"carrier": document.getElementById("carrierorbit"),
"launchpoint": document.getElementById("launchpoint"),
"constellation": document.getElementById("constellation"),
}
// ===================== start coding! ==========================
function setup() {
systemlist();
inputs.systlist.addEventListener("change",newsystem,false);
inputs.bodylist.addEventListener("change",update,false);
inputs.altitude.addEventListener("change",update,false);
inputs.satellites.addEventListener("change",update,false);
inputs.fliporbit.addEventListener("change",update,false);
inputs.flipLOS.addEventListener("change",update,false);
inputs.vacOcclusion.addEventListener("change",update,false);
inputs.atmOcclusion.addEventListener("change",update,false);
inputs.flipOcc.addEventListener("change",update,false);
inputs.setsync.addEventListener("click",function(){
setAlt("sync");
},false);
inputs.setmin.addEventListener("click",function(){
setAlt("los");
},false);
document.querySelector("#setGeo").addEventListener("click",function(){
setAlt("sync");
},false);
document.querySelector("#setLOS").addEventListener("click",function(){
setAlt("los");
},false);
}
function setAlt(type) {
if (type == "sync") {
if (outputs.synchrorbit.value != "n/a") {
inputs.altitude.value = Number.parseFloat(body.geoAlt);
}
}
if (type == "los") {
if (outputs.losorbit.value != "n/a") {
inputs.altitude.value = Number.parseFloat(Math.round(minLOSCalc(body)*10)/10);
}
}
update();
}
function systemlist() {
var slist = inputs.systlist;
while (slist.firstChild) {
slist.removeChild(slist.firstChild);
}
for (system in systems) {
var opt = document.createElement('option');
opt.value = system;
opt.textContent = system;
if (decodeURIComponent(window.location.hash) == "#"+system) {
opt.setAttribute("selected",true);
}
slist.appendChild(opt);
}
newsystem();
}
function newsystem() {
var blist = inputs.bodylist;
while (blist.firstChild) {
blist.removeChild(blist.firstChild);
}
var syst = systems[inputs.systlist.value];
for (t in syst) {
var opt = document.createElement('option');
opt.value = t;
opt.textContent = t;
if (syst[t].default == true) {
opt.setAttribute("selected",true);
}
blist.appendChild(opt);
}
update();
}
function update() {
var system = inputs.systlist.value;
if (system == "KSP Stock") {
document.querySelector('h2 span').textContent = "";
history.pushState("", document.title, window.location.pathname + window.location.search);
} else {
document.querySelector('h2 span').textContent = " " + system;
window.location.hash = "#" + encodeURIComponent(system);
}
body = new bodydef(systems[system][inputs.bodylist.value]);
var sataltitude = parseFloat(inputs.altitude.value);
if (sataltitude > body.SOIAlt) {
outputs.period.setAttribute("disabled","true");
}
if (body.geoAlt > 0 && body.geoSMA < body.SOI) {
outputs.synchrorbit.value = body.geoAlt.toLocaleString() + " m";
} else {
outputs.synchrorbit.value = "n/a";
}
var minLOS = minLOSCalc(body);
if (minLOS < body.SOIAlt && minLOS > 0) {
outputs.losorbit.value = (Math.round(minLOS*10)/10).toLocaleString() + " m";
if (minLOS < body.atm) outputs.losorbit.classList.add("warning");
else outputs.losorbit.classList.remove("warning");
if (sataltitude *1.01 < minLOS) {
chart.constellation.classList.add("warning");
chart.constellation.setAttribute("stroke-dasharray","7,12,15,2,5,3,9,11");
} else {
chart.constellation.classList.remove("warning");
chart.constellation.setAttribute("stroke-dasharray","");
}
} else {
outputs.losorbit.value = "n/a";
}
var satcount = parseInt(inputs.satellites.value);
var satratio = ((satcount + 1) / satcount);
var satelliteorbit = new orbitdef(sataltitude,sataltitude,body);
var carrierorbit = new orbitdef(sataltitude,sataltitude,body);
if (satcount && sataltitude) {
carrierorbit.modifyAp = newMAfromT(satelliteorbit.T * satratio,body);
if (carrierorbit.Ap > body.SOIAlt || inputs.fliporbit.checked == true) {
satratio = ((satcount - 1) / satcount);
carrierorbit = new orbitdef(sataltitude,sataltitude,body);
carrierorbit.modifyPe = newMAfromT(satelliteorbit.T * satratio,body);
}
outputs.period.value = satelliteorbit.oph;
if (carrierorbit.Ap) outputs.carrierAp.value = (Math.round(carrierorbit.Ap*10)/10).toLocaleString() + " m";
if (carrierorbit.Ap < body.atm || carrierorbit.Ap < 0) outputs.carrierAp.classList.add("warning");
else outputs.carrierAp.classList.remove("warning");
if (carrierorbit.Pe) outputs.carrierPe.value = (Math.round(carrierorbit.Pe*10)/10).toLocaleString() + " m";
if (carrierorbit.Pe < body.atm) outputs.carrierPe.classList.add("warning");
else outputs.carrierPe.classList.remove("warning");
if (carrierorbit.Pe <= 0) outputs.carrierPe.classList.add("urgent");
else outputs.carrierPe.classList.remove("urgent");
outputs.carrierT.value = carrierorbit.oph;
outputs.burnDV.value = burnCalc(satelliteorbit,carrierorbit,body) + " m/s";
}
if (outputs.period.value == "") {
document.querySelector("#schematic > header").textContent = '';
} else {
var string = inputs.bodylist.value;
string += " (" + inputs.systlist.value + ") ";
string += inputs.satellites.value + "-satellite constellation<br>";
string += "Ap " + outputs.carrierAp.value;
string += " Pe " + outputs.carrierPe.value;
string += " Δv " + outputs.burnDV.value;
document.querySelector("#schematic > header").innerHTML = string;
}
drawchart(satelliteorbit,carrierorbit,body);
}
function burnCalc(s,c,b) {
var sta = 0;
var cta = 0;
if (c.Ap == s.Ap) cta = 180;
var sr = s.SMA * ( 1 - Math.pow(s.e,2) ) / ( 1 + ( s.e * Math.cos(sta)));
var sdv = Math.sqrt( b.GM * (( 2 / sr ) - ( 1 / s.SMA )));
var cr = c.SMA * ( 1 - Math.pow(c.e,2) ) / ( 1 + ( c.e * Math.cos(cta)));
var cdv = Math.sqrt( b.GM * (( 2 / sr ) - ( 1 / c.SMA )));
return Math.round(100 * Math.abs(sdv - cdv)) / 100;
}
function minLOSCalc(body) {
var sat = inputs.satellites.value;
if (sat) return ( body.eqr * occmod() ) / (Math.cos(0.5 * (2 * Math.PI / sat))) - body.eqr;
}
function occmod() {
if (document.querySelector("#flipOcc").checked == false) return 1;
if (body.atm > 0) {
return parseFloat(inputs.atmOcclusion.value);
} else {
return parseFloat(inputs.vacOcclusion.value);
}
}
function drawchart(s,c,b) {
var maxMA = Math.max(s.MA,c.MA);
if (!maxMA) maxMA = 3 * b.eqr;
var coordkm = (1000 / maxMA) / 1.5;
var view = 1000;
var mid = view/2;
chart.body.setAttribute("r",b.eqr * coordkm);
if (b.color != "") {
chart.body.setAttribute("fill",b.color);
} else {
chart.body.setAttribute("fill","#666");
}
if (b.atm != 0) {
chart.atmosphere.setAttribute("r",(b.eqr + b.atm) * coordkm);
} else {
chart.atmosphere.setAttribute("r",0);
}
var SOIr = b.SOI * coordkm;
if (SOIr > 10000) SOIr = 10000;
chart.bodySOI.setAttribute("r", SOIr);
chart.bodySOIlabel.setAttribute("d",describeArc(mid,mid,(b.SOI * coordkm)+7,90,270,1));
chart.SOId.innerHTML = Math.round(b.SOIAlt).toLocaleString();
if (body.geoAlt < body.SOI) {
chart.geosync.setAttribute("r", (b.geoSMA * coordkm));
if ( (b.geoSMA * coordkm) > 60 ) {
chart.geosynclabel.setAttribute("d",describeArc(mid,mid,(b.geoSMA * coordkm)+27,60,300));
chart.syncm.innerHTML = (Math.round(b.geoAlt*10)/10).toLocaleString();
} else {
chart.geosynclabel.setAttribute("d","M 0 0");
}
} else {
chart.geosynclabel.setAttribute("d","M 0 0");
chart.geosync.setAttribute("r", "0");
}
chart.satellite.setAttribute("r",s.SMA * coordkm);
if (s.Ap < b.atm) chart.satellite.classList.add("warning");
else chart.satellite.classList.remove("warning");
if (c.Pe < b.atm) chart.carrier.classList.add("warning");
else chart.carrier.classList.remove("warning");
chart.carrier.setAttribute("d","M " + mid + " " + ((view/2) - s.SMA * coordkm) +
" a " + (c.sma * coordkm) + "," + (c.SMA * coordkm) + " 0 1,0 1,0");
var sats = Number.parseInt(inputs.satellites.value);
if (sats >= 3 && flipLOS.checked == true) {
var sepang = ( 2 * Math.PI ) / sats;
var dString = "";
var half = Math.round(sats/1.9);
for (var i = 0; i <= sats; i++) {
var curang = i * sepang;
var xc = mid + Math.sin(curang) * s.SMA * coordkm;
var yc = mid - Math.cos(curang) * s.SMA * coordkm;
if (i > 0) {dString += " L ";} else {dString += " M ";}
dString += xc + " " + yc;
for (var j = 0; j <= half; j++) {
var checkpos = (i + j) * sepang;
var checkang = checkpos - curang;
var h = Math.cos( 0.5 * checkang ) * s.SMA;
if (h*1.001 >= b.eqr) {
var cxc = mid + Math.sin(checkpos) * s.SMA * coordkm;
var cyc = mid - Math.cos(checkpos) * s.SMA * coordkm;
dString += " L " + cxc + " " + cyc;
dString += " M " + xc + " " + yc;
}
}
if (i > 0 && i < sats) {
for (var j = 0; j <= sats; j++) {
var ix = xc + Math.sin(j * sepang) * 7.5;
var iy = yc + Math.cos(j * sepang) * 7.5;
dString += " L " + ix + " " + iy;
}
dString += " M " + xc + " " + yc;
}
}
chart.constellation.setAttribute("d",dString);
} else {
chart.constellation.setAttribute("d","M 0 0");
}
var minLOS = minLOSCalc(b);
var rad = Math.round( (( b.eqr + minLOS) ) * coordkm);
if (sats >= 3 && ( minLOS * 10 >= s.Ap || isNaN(s.Ap) ) && rad > 60 ) {
chart.lineofsight.setAttribute("r",rad);
chart.lineofsightlabel.setAttribute("d",describeArc(mid,mid,rad+27,60,300));
chart.msa.innerHTML = (Math.round(minLOS*10)/10).toLocaleString();
} else {
chart.lineofsight.setAttribute("r",0);
chart.lineofsightlabel.setAttribute("d","M 0 0");
}
if (!c.e) {
chart.launchpoint.setAttribute("cy",-1000);
} else {
chart.launchpoint.setAttribute("cy",(view/2) - s.SMA * coordkm);
}
}
function debug(str) {
var output = document.getElementById("debug");
output.innerHTML += str + "<br>";
}
// Next two functions courtesy http://stackoverflow.com/a/18473154
function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
var angleInRadians = (angleInDegrees-90) * Math.PI / 180.0;
return {
x: centerX + (radius * Math.cos(angleInRadians)),
y: centerY + (radius * Math.sin(angleInRadians))
};
}
function describeArc(x, y, radius, startAngle, endAngle, flip){
if (!flip) var flip = 0;
var start = polarToCartesian(x, y, radius, endAngle);
var end = polarToCartesian(x, y, radius, startAngle);
var largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1";
var d = [
"M", start.x, start.y,
"A", radius, radius, 0, largeArcFlag, flip, end.x, end.y
].join(" ");
return d;
}
setup();
update();
</script>
</html>