From 5e7f1c029bbb40eb4c64c6e03ad1152e1d6141e9 Mon Sep 17 00:00:00 2001
From: Thomas West <tw00956@surrey.ac.uk>
Date: Tue, 3 Sep 2024 15:19:15 +0000
Subject: [PATCH] Lambert Solver Final Position when leaving the SOI of a body.

---
 Function/calculate_rf.m | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 Function/calculate_rf.m

diff --git a/Function/calculate_rf.m b/Function/calculate_rf.m
new file mode 100644
index 0000000..e93dd61
--- /dev/null
+++ b/Function/calculate_rf.m
@@ -0,0 +1,14 @@
+function rf = calculate_rf(rp, Omega, i, omega)
+    % Initial periapsis vector in orbital plane
+    r_peri = [rp * cosd(omega); rp * sind(omega); 0];
+    
+    % Rotation matrix for inclination
+    R_i = [1 0 0; 0 cosd(i) -sind(i); 0 sind(i) cosd(i)];
+    
+    % Rotation matrix for RAAN
+    R_Omega = [cosd(Omega) -sind(Omega) 0; sind(Omega) cosd(Omega) 0; 0 0 1];
+    
+    % Apply rotations
+    r_inclined = R_i * r_peri;  % Rotate by inclination
+    rf = R_Omega * r_inclined;  % Rotate by RAAN
+end
-- 
GitLab