-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from itchono/develop-110
Presentation Push
- Loading branch information
Showing
49 changed files
with
1,222 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
function imseq_fancy(y, save_path, nfmax, view_dim) | ||
% Expect y to be (6, N) | ||
% no need to interpolate vectors unless you have VERY big skips in L | ||
% Reference: https://www.mathworks.com/help/matlab/ref/getframe.html | ||
% Splits by orbit number | ||
|
||
[~, ~, ~, ~, ~, L] = unpack_mee(y); | ||
|
||
if nargin < 3 | ||
nfmax = 20; | ||
view_dim = 3; | ||
end | ||
|
||
%% Data processing | ||
ind_orbits = find(diff(mod(L, 2*pi)) < 0); | ||
num_orbits = length(ind_orbits); | ||
|
||
%% Initial plot stuff | ||
L_sample = linspace(0, 2*pi, 100); | ||
plot_sphere(0, 0, 0, 6378e3, [0.3010, 0.7450, 0.9330]); | ||
hold on | ||
|
||
cm = colormap("turbo"); | ||
th = title(sprintf("Orbit 1 of %d", num_orbits)); | ||
|
||
% plot initial trace | ||
cart_sample = mee2cartesian([repmat(y(1:5, 1), 1, numel(L_sample)); L_sample]); | ||
plot3(cart_sample(1, :), cart_sample(2, :), cart_sample(3, :), "Color", cm(1, :), "DisplayName", "Initial Orbit", "LineWidth", 1, "LineStyle", "--"); | ||
|
||
% plot main orbit | ||
main_orbit = plot3(cart_sample(1, :), cart_sample(2, :), cart_sample(3, :), "Color", "black", "DisplayName", "Current Orbit", "LineWidth", 1); | ||
|
||
% plot final trace | ||
cart_sample = mee2cartesian([repmat(y(1:5, end), 1, numel(L_sample)); L_sample]); | ||
plot3(cart_sample(1, :), cart_sample(2, :), cart_sample(3, :), "Color", cm(end, :), "DisplayName", "Final Orbit", "LineWidth", 1, "LineStyle", "--"); | ||
|
||
% colorbar | ||
colorbar; | ||
clim([1,num_orbits]); | ||
|
||
axis equal | ||
view(view_dim) | ||
|
||
%% Initialize path | ||
workingDir = save_path; | ||
mkdir(workingDir) | ||
mkdir(workingDir,"images") | ||
|
||
%% Animation | ||
% spacing; never plot more than 20 frames | ||
stride = max(1, ceil(num_orbits/nfmax)); | ||
|
||
% ensure we always plot the last orbit | ||
ii = 1; % counter | ||
for j = [1:stride:num_orbits, num_orbits] | ||
% Update plots | ||
idx = ind_orbits(j); | ||
cart_sample = mee2cartesian([repmat(y(1:5, idx), 1, numel(L_sample)); L_sample]); | ||
main_orbit.XData = cart_sample(1, :); | ||
main_orbit.YData = cart_sample(2, :); | ||
main_orbit.ZData = cart_sample(3, :); | ||
|
||
% Add shadow of previous orbits | ||
colour_idx = ceil(j/num_orbits*length(cm)); | ||
plot3(cart_sample(1, :), cart_sample(2, :), cart_sample(3, :), "Color", cm(colour_idx, :), "LineWidth", 1); | ||
|
||
th.String = sprintf("Orbit %d of %d", j, num_orbits); | ||
|
||
% Draw and get frame | ||
drawnow | ||
exportgraphics(gcf, fullfile(workingDir,"images",sprintf("anim-%d.png", ii))) | ||
ii = ii + 1; % JANK but works | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
function imseq_osculating_mee(y, save_path, view_dim) | ||
% Expect y to be (6, N) | ||
% no need to interpolate vectors unless you have VERY big skips in L | ||
% Reference: https://www.mathworks.com/help/matlab/ref/getframe.html | ||
% Splits by orbit number | ||
|
||
[~, ~, ~, ~, ~, L] = unpack_mee(y); | ||
|
||
if nargin < 3 | ||
view_dim = 3; | ||
end | ||
|
||
%% Data processing | ||
ind_orbits = find(diff(mod(L, 2*pi)) < 0); | ||
num_orbits = length(ind_orbits); | ||
|
||
%% Initial plot stuff | ||
L_sample = linspace(0, 2*pi, 100); | ||
plot_sphere(0, 0, 0, 6378e3, [0.3010, 0.7450, 0.9330]); | ||
hold on | ||
|
||
cm = colormap("winter"); | ||
|
||
% plot initial trace | ||
cart_sample = mee2cartesian([repmat(y(1:5, 1), 1, numel(L_sample)); L_sample]); | ||
plot3(cart_sample(1, :), cart_sample(2, :), cart_sample(3, :), "Color", cm(1, :), "DisplayName", "Initial Orbit", "LineWidth", 1, "LineStyle", "--"); | ||
|
||
% plot main orbit | ||
main_orbit = plot3(cart_sample(1, :), cart_sample(2, :), cart_sample(3, :), "Color", "black", "DisplayName", "Current Orbit", "LineWidth", 1); | ||
|
||
% plot final trace | ||
cart_sample = mee2cartesian([repmat(y(1:5, end), 1, numel(L_sample)); L_sample]); | ||
plot3(cart_sample(1, :), cart_sample(2, :), cart_sample(3, :), "Color", cm(end, :), "DisplayName", "Final Orbit", "LineWidth", 1, "LineStyle", "--"); | ||
|
||
axis equal | ||
axis off | ||
view(view_dim) | ||
|
||
%% Initialize path | ||
workingDir = save_path; | ||
mkdir(workingDir) | ||
mkdir(workingDir,"images") | ||
|
||
%% Animation | ||
% spacing; never plot more than 20 frames | ||
stride = max(1, ceil(num_orbits/20)); | ||
|
||
% ensure we always plot the last orbit | ||
ii = 1; % counter | ||
for j = [1:stride:num_orbits, num_orbits] | ||
% Update plots | ||
idx = ind_orbits(j); | ||
cart_sample = mee2cartesian([repmat(y(1:5, idx), 1, numel(L_sample)); L_sample]); | ||
main_orbit.XData = cart_sample(1, :); | ||
main_orbit.YData = cart_sample(2, :); | ||
main_orbit.ZData = cart_sample(3, :); | ||
|
||
% Add shadow of previous orbits | ||
colour_idx = ceil(j/num_orbits*length(cm)); | ||
plot3(cart_sample(1, :), cart_sample(2, :), cart_sample(3, :), "Color", cm(colour_idx, :), "LineWidth", 0.5); | ||
|
||
|
||
% Draw and get frame | ||
drawnow | ||
exportgraphics(gcf, fullfile(workingDir,"images",sprintf("anim-%d.png", ii))) | ||
ii = ii + 1; % JANK but works | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,55 @@ | ||
function plot_elements_ke(y, t, y_target) | ||
[p, f, g, h, k, L] = unpack_mee(y); | ||
[a, e, i, Omega, omega, theta] = mee2keplerian(p, f, g, h, k, L); | ||
[a, e, i, Omega, omega, ~] = mee2keplerian(p, f, g, h, k, L); | ||
|
||
ra = a .* (1 + e); | ||
rp = a .* (1 - e); | ||
|
||
days = t/86400; | ||
|
||
% size | ||
fh = gcf(); | ||
fh.Position(3:4) = [560, 600]; | ||
|
||
% Plots orbital elements in stacked plots | ||
tiledlayout(2, 1, 'TileSpacing', 'tight'); | ||
|
||
% Plots orbital elements in stacked plots | ||
subplot(211) | ||
plot(t/86400, a, "Color", [0, 0.4470, 0.7410], "LineWidth", 1); | ||
ax1 = nexttile; | ||
plot(days, a, "Color", [0, 0.4470, 0.7410], "LineWidth", 1); | ||
hold on | ||
plot(t/86400, ra, "LineWidth", 1); | ||
plot(t/86400, rp, "LineWidth", 1); | ||
plot(days, ra, "LineWidth", 1); | ||
plot(days, rp, "LineWidth", 1); | ||
legend("SMA", "AP Radius", "PE Radius", "Location", "best") | ||
title("Evolution of Orbital Elements"); | ||
ylabel("Radius") | ||
grid | ||
ylabel("Orbit Size (m)") | ||
grid on | ||
grid minor | ||
|
||
subplot(212) | ||
plot(t/86400, i, "LineWidth", 1) | ||
ax2 = nexttile; | ||
plot(days, i, "LineWidth", 1) | ||
hold on | ||
plot(t/86400, Omega, "LineWidth", 1) | ||
plot(t/86400, omega, "LineWidth", 1); | ||
legend("Inc", "\Omega", "\omega", "Location", "best"); | ||
ylabel("Orientation") | ||
grid | ||
plot(days, Omega, "LineWidth", 1) | ||
plot(days, omega, "LineWidth", 1); | ||
legend("i", "\Omega", "\omega", "Location", "best"); | ||
ylabel("Orientation (deg)") | ||
grid on | ||
grid minor | ||
|
||
xlabel("Elapsed Time (Days)") | ||
|
||
% Link x | ||
linkaxes([ax1, ax2],'x') | ||
|
||
% Tight xlim and final | ||
for aa = [ax1, ax2] | ||
xlim(aa, [min(days), max(days)]) | ||
xticks(aa, [xticks, round(max(days))]) | ||
end | ||
|
||
% Top label | ||
set(ax1,'XAxisLocation','top') | ||
converted_values = floor(interp1(t, L, xticks*86400, "linear", "extrap") /(2 * pi)); | ||
set(ax1, "XTickLabels", converted_values); | ||
xlabel(ax1,'Orbit Number') | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,60 @@ | ||
function plot_elements_mee(y, t, y_target) | ||
[p, f, g, h, k, ~] = unpack_mee(y); | ||
[p, f, g, h, k, L] = unpack_mee(y); | ||
|
||
days = t/86400; | ||
|
||
% size | ||
fh = gcf(); | ||
fh.Position(3:4) = [560, 600]; | ||
|
||
% Plots orbital elements in stacked plots | ||
subplot(311) | ||
plot(t/86400, p, "Color", [0, 0.4470, 0.7410], "LineWidth", 1); | ||
tiledlayout(3, 1, 'TileSpacing', 'tight'); | ||
|
||
ax1 = nexttile; | ||
plot(days, p, "Color", [0, 0.4470, 0.7410], "LineWidth", 1); | ||
yline(y_target(1), "--", "Color", [0, 0.4470, 0.7410], "LineWidth", 1); | ||
legend("p", "Location", "best") | ||
title("Evolution of Orbital Elements"); | ||
ylabel("Semi-Latus Rect.") | ||
grid | ||
ylabel("Orbit Size (m)") | ||
grid on | ||
grid minor | ||
|
||
subplot(312) | ||
plot(t/86400, f, "Color", [0.8500, 0.3250, 0.0980], "LineWidth", 1) | ||
ax2 = nexttile; | ||
plot(days, f, "Color", [0.8500, 0.3250, 0.0980], "LineWidth", 1) | ||
hold on | ||
plot(t/86400, g, "Color", [0.4660, 0.6740, 0.1880], "LineWidth", 1) | ||
plot(days, g, "Color", [0.4660, 0.6740, 0.1880], "LineWidth", 1) | ||
yline(y_target(2), "--", "Color", [0.8500, 0.3250, 0.0980], "LineWidth", 1) | ||
yline(y_target(3), "--", "Color", [0.4660, 0.6740, 0.1880], "LineWidth", 1) | ||
legend("f", "g", "Location", "best"); | ||
ylabel("Ecc. Vector") | ||
grid | ||
ylabel("Eccentricity Vector") | ||
set(gca,'XTickLabel',[]); | ||
grid on | ||
grid minor | ||
|
||
subplot(313) | ||
plot(t/86400, h, "Color", [0.9290, 0.6940, 0.1250], "LineWidth", 1) | ||
ax3 = nexttile; | ||
plot(days, h, "Color", [0.9290, 0.6940, 0.1250], "LineWidth", 1) | ||
hold on | ||
plot(t/86400, k, "Color", [0.4940, 0.1840, 0.5560], "LineWidth", 1); | ||
plot(days, k, "Color", [0.4940, 0.1840, 0.5560], "LineWidth", 1); | ||
yline(y_target(4), "--", "Color", [0.9290, 0.6940, 0.1250], "LineWidth", 1) | ||
yline(y_target(5), "--", "Color", [0.4940, 0.1840, 0.5560], "LineWidth", 1) | ||
legend("h", "k", "Location", "best"); | ||
ylabel("Nodal Position") | ||
grid | ||
grid on | ||
grid minor | ||
|
||
xlabel("Elapsed Time (Days)") | ||
|
||
% Link x | ||
linkaxes([ax1, ax2, ax3],'x') | ||
|
||
% Tight xlim and final | ||
for aa = [ax1, ax2, ax3] | ||
xlim(aa, [min(days), max(days)]) | ||
xticks(aa, [xticks, round(max(days))]) | ||
end | ||
|
||
% Top label | ||
set(ax1,'XAxisLocation','top') | ||
converted_values = floor(interp1(t, L, xticks*86400, "linear", "extrap") /(2 * pi)); | ||
set(ax1, "XTickLabels", converted_values); | ||
xlabel(ax1,'Orbit Number') | ||
end |
Oops, something went wrong.