]> git.example.dev Git - research-obsidian.git/commitdiff
updated: jank missile script
author2weiEmu <zweiemu@gmail.com>
Tue, 3 Feb 2026 15:19:06 +0000 (16:19 +0100)
committer2weiEmu <zweiemu@gmail.com>
Tue, 3 Feb 2026 15:19:06 +0000 (16:19 +0100)
Nebulous Command/__pycache__/calc.cpython-314.pyc [new file with mode: 0644]
Nebulous Command/missile-simulator.py [new file with mode: 0644]

diff --git a/Nebulous Command/__pycache__/calc.cpython-314.pyc b/Nebulous Command/__pycache__/calc.cpython-314.pyc
new file mode 100644 (file)
index 0000000..9687afa
Binary files /dev/null and b/Nebulous Command/__pycache__/calc.cpython-314.pyc differ
diff --git a/Nebulous Command/missile-simulator.py b/Nebulous Command/missile-simulator.py
new file mode 100644 (file)
index 0000000..581462b
--- /dev/null
@@ -0,0 +1,112 @@
+from calc import ships, jammers, radars, select_ship, select_jammer, select_radar
+import cv2 as cv
+import numpy as np
+import math
+
+HEIGHT = 540
+WIDTH = 960
+
+def calculate_return_power_density(
+        radiated_power, gain, rcs, aperture_size, distance) -> float:
+    numerator = radiated_power * (gain ** 2) * (rcs / 10) * aperture_size
+    denominator = 16 * (math.pi ** 2) * (distance ** 4)
+    return numerator / denominator
+
+
+def calculate_noise(gain, noise_filtering, total_jamming_power) -> float:
+    return ((10 ** -7) + (total_jamming_power * gain)) * (10 ** (noise_filtering / 10))
+
+
+def calculate_signal_loss(return_power_density) -> float:
+    return 10 * math.log10(return_power_density * 1000)
+
+
+def main():
+    img = np.zeros((HEIGHT, WIDTH, 3), np.uint8)
+    cv.imshow("Canvas", img)
+
+    # for now we only do tracking with EO sensor, I don't want to model the
+    # other sensors right now
+    # first we need to setup the scenario
+    # i.e. what kind of radar, what kind of mods does the radar have?
+    # is the radar tracking or targeting?
+    r = select_radar()
+    sign_scrambl = int(input("How many signature scramblers does the ship have?"))
+    adap_rad_recv = int(input("How many adaptive radar receivers does the ship have?"))
+
+    # what is the missile? Side on and front on detection ranges
+    # what kinda mods does the missile have
+    # at what ranges will it be detected by the ship
+    s = select_ship()
+    j1 = select_jammer()
+    j2 = select_jammer()
+
+
+    radar_coating_layers = int(input("How many layers of radar coating do you have?"))
+
+    first_definite_detect_distance = 0
+    first_detect_distance_rpd = 0
+    first_detect_distance_sensitivity = 0
+
+    # we assume the missile starts at 15000m and we will just move it by
+    # 5m every time.
+    # (yes, it's fine my computer will compute jsut fine im sure), but
+    # we go the other way just for easier saving
+    for d in range(5, 15000, 5):
+        rcs = s.rcs_m2
+        if (radar_coating_layers == 1):
+            rcs = s.rcs_m2 * 0.6
+        if (radar_coating_layers == 2):
+            rcs = s.rcs_m2 * 0.4528
+        rpd = calculate_return_power_density(r.radiated_power_kw, r.gain_db, rcs, r.aperture_size_m2, d)
+        # return power density of the missile from the radar
+
+        sensitivity = (r.sensitivity_dBm) * (1 - (sign_scrambl * 0.1))
+        noise_filtering = r.noise_filtering_dB + (adap_rad_recv * -0.7)
+
+        total_jamming_power = (j1.radiated_power_kw * j1.gain_db) / (4 * math.pi * (d ** 2))
+        total_jamming_power += 0.876 * (j2.radiated_power_kw * j2.gain_db) / (4 * math.pi * (d ** 2))
+        n = calculate_noise(r.gain_db, noise_filtering, total_jamming_power) # how much noise is coming from the jammers
+
+        s_l = calculate_signal_loss(rpd)
+
+        # first the noise check
+        if (rpd > n):
+            first_detect_distance_rpd = d
+
+        # then the sensitivty check
+        if (sensitivity < s_l):
+            first_detect_distance_sensitivity = d
+
+        # if both pass, then, save this as new distance
+        if (rpd > n and sensitivity < s_l):
+            first_definite_detect_distance = d
+
+    # display the visual, frame by frame / step by step simulation
+    print("Distance of Definite detection:", first_definite_detect_distance)
+    print("Distance of Sensitivity detection:", first_detect_distance_sensitivity)
+    print("Distance of RPD detection:", first_detect_distance_rpd)
+
+    c_center = (0, int(HEIGHT / 2))
+    cv.circle(img, c_center, radius=2, color=(255, 0, 0), thickness=2)
+
+    rad = int(first_definite_detect_distance * 0.064)
+    cv.circle(img, c_center, radius=rad, color=(0, 255, 0), thickness=5)
+    cv.putText(img, "Detected", (rad, int(HEIGHT / 2) + 50), cv.FONT_HERSHEY_PLAIN, 1.5, (200, 200, 200), 2)
+
+    cv.line(img, c_center, (rad, int(HEIGHT / 2)), color=(128, 128, 0), thickness=2)
+    cv.putText(img, f"{first_definite_detect_distance}m", (int(rad / 2), int(HEIGHT / 2) - 50), cv.FONT_HERSHEY_PLAIN, 1.5, (200, 200, 200), 2)
+
+    rad = int(first_detect_distance_sensitivity * 0.064)
+    cv.circle(img, c_center, radius=rad, color=(128, 128, 0), thickness=5)
+
+    rad = int(first_detect_distance_rpd * 0.064)
+    cv.circle(img, c_center, radius=rad, color=(0, 0, 255), thickness=5)
+
+    cv.imshow("Canvas", img)
+    cv.waitKey(0)
+    cv.destroyAllWindows()
+
+
+if __name__ == "__main__":
+    main()