Skip to content

Commit

Permalink
test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aebestach committed Jul 25, 2024
1 parent 8bedd87 commit 298bb06
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
34 changes: 34 additions & 0 deletions JS/calculate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function calculate() {
// Get form values
var galaxy = document.getElementById('system').value;
var planet = document.getElementById('planet').value;
var alt = parseFloat(document.getElementById('altitude').value);
var ecc = parseFloat(document.getElementById('eccentricity').value);
var j2 = parseFloat(document.getElementById('j2').value);

// Calculate
var R_E = 6371; // Replace with actual value
var μ = 398600; // Replace with actual value
var T_year = 365.25 * 24 * 60 * 60; // Replace with actual value
var J2 = j2;

var ρ = 2 * Math.PI / T_year;
var SMA = alt + R_E;
var p = SMA * (1 - ecc * ecc);
var period = 2 * Math.PI * Math.sqrt(SMA * SMA * SMA / μ);
var ΔΩ = period * ρ;
var cosi = (ΔΩ * p * p) / (-3 * Math.PI * J2 * R_E * R_E);
var inc = Math.acos(cosi);

var result;
/*if (galaxy == 'Stock') {
var C20 = -1 * (J2 * Math.sqrt(5)) / 5;
result = [planet, inc.toFixed(4), SMA.toFixed(2), ecc, C20.toExponential(17)];
} else {
result = [planet, inc.toFixed(4), SMA.toFixed(2), ecc];
}*/
var C20 = -1 * (J2 * Math.sqrt(5)) / 5;
result = [planet, inc.toFixed(4), SMA.toFixed(2), ecc, C20.toExponential(17)];
// Display result
document.getElementById('resultContent').innerText = JSON.stringify(result);
}
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<title>Sun Synchronous Orbit Calculator</title>
<!-- Link Bootstrap CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<div class="container mt-5">
Expand Down Expand Up @@ -58,18 +59,21 @@ <h1 class="text-center">Sun Synchronous Orbit Calculator</h1><br>
</div>
<div class="form-group row">
<div class="col-sm-10 offset-sm-2">
<button type="calculate" class="btn btn-primary">Calculate</button>
<button type="button" onclick="calculate()" class="btn btn-primary">Calculate</button>
<button type="button" class="btn btn-secondary ml-2">Generate Configuration File</button>
<button type="button" class="btn btn-danger ml-2">Clear</button>
</div>
</div>
</form>
<!-- Result Display Box -->
<h5>Calculation Result</h5>
<div class="mt-4 border p-3">
<pre id="resultContent"></pre>
<pre id="resultContent">1</pre>
</div>
</div>

<!-- Include Bootstrap JS -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="JS/calculate.js"></script>
</body>
</html>

0 comments on commit 298bb06

Please sign in to comment.