From 298bb0670853e5e5db9b7bb0755a6a80052c9fe7 Mon Sep 17 00:00:00 2001 From: Aebestach Date: Thu, 25 Jul 2024 18:53:24 +0800 Subject: [PATCH] test commit --- JS/calculate.js | 34 ++++++++++++++++++++++++++++++++++ index.html | 8 ++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 JS/calculate.js diff --git a/JS/calculate.js b/JS/calculate.js new file mode 100644 index 0000000..b8883fc --- /dev/null +++ b/JS/calculate.js @@ -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); +} diff --git a/index.html b/index.html index 455580f..4d9ac60 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,7 @@ Sun Synchronous Orbit Calculator +
@@ -58,18 +59,21 @@

Sun Synchronous Orbit Calculator


- + + +
Calculation Result
-

+        
1
+