Skip to content

Commit 390a106

Browse files
committed
bug fixes, function header updates, reorganization
1 parent cee6479 commit 390a106

6 files changed

Lines changed: 57 additions & 47 deletions

File tree

EXAMPLES.mlx

22.5 KB
Binary file not shown.
780 Bytes
Binary file not shown.

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Creates high-resolution renderings of the Earth and the major celestial bodies i
3737

3838

3939

40-
<br/><br/>
41-
<br/><br/>
40+
41+
<br><br><br><br>
4242

4343

4444

@@ -63,27 +63,25 @@ Sets the plot background for drawing celestial bodies in 3D.
6363

6464

6565

66-
<br/><br/>
67-
<br/><br/>
66+
<br><br><br><br>
6867

6968

7069

7170

7271
# Examples and Additional Documentation
7372

74-
- See "EXAMPLES.mlx" or the "Examples" tab on the File Exchange page for examples.
73+
- See `EXAMPLES.mlx` or the "Examples" tab on the File Exchange page for examples.
7574
- See [Visualizing Celestial Bodies in 3D.pdf](https://tamaskis.github.io/files/Visualizing_Celestial_Bodies_in_3D.pdf) (also included with download) for additional documentation.
7675

7776

7877

7978

80-
<br/><br/>
81-
<br/><br/>
79+
<br><br><br><br>
8280

8381

8482

8583

8684
# Installation
8785

88-
- Open "3D Earth and Celestial Bodies (planet3D).mltbx" in the "INSTALL" folder to install as a toolbox. MATLAB will automatically perform the installation and add all the functions, images, and data to the MATLAB search path.
86+
- Open "`3D Earth and Celestial Bodies (planet3D).mltbx`" in the "`INSTALL`"" folder to install as a toolbox. MATLAB will automatically perform the installation and add all the functions, images, and data to the MATLAB search path.
8987
- Alternatively, the "planet3D" folder can be copy and pasted into the folder containing the script that you want to use the functions in. At the beginning of the script, include "`addpath('planet3D')`" to add all functions, images, and data to the MATLAB search path.

Technical Documentation/Visualizing_Celestial_Bodies_in_3D.pdf renamed to Visualizing_Celestial_Bodies_in_3D.pdf

File renamed without changes.

planet3D/background.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
% See also planet3D, ground_track.
88
%
99
% Copyright © 2021 Tamas Kis
10-
% Last Update: 2022-07-06
10+
% Last Update: 2023-05-20
1111
% Website: https://tamaskis.github.io
1212
% Contact: tamas.a.kis@outlook.com
1313
%
14-
% TECHNICAL DOCUMENTATION:
14+
% Technical Documentation:
1515
% https://tamaskis.github.io/files/Visualizing_Celestial_Bodies_in_3D.pdf
1616
%
1717
%--------------------------------------------------------------------------
1818
%
1919
% ------
2020
% INPUT:
2121
% ------
22-
% spec - (char) 'Black', 'Stars', or 'Milky Way'
22+
% spec - (char array) 'Black', 'Stars', or 'Milky Way'
2323
%
2424
% -----
2525
% NOTE:
2626
% -----
27-
% --> The function call on "background" MUST occur before the function
28-
% call on "planet3D".
27+
% The function call on "background" MUST occur before the function call
28+
% on "planet3D".
2929
%
3030
%==========================================================================
3131
function background(spec)

planet3D/planet3D.m

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,41 @@
1111
% See also background, ground_track.
1212
%
1313
% Copyright © 2021 Tamas Kis
14-
% Last Update: 2023-05-17
14+
% Last Update: 2023-05-20
1515
% Website: https://tamaskis.github.io
1616
% Contact: tamas.a.kis@outlook.com
1717
%
18-
% TECHNICAL DOCUMENTATION:
18+
% Technical Documentation:
1919
% https://tamaskis.github.io/files/Visualizing_Celestial_Bodies_in_3D.pdf
2020
%
2121
%--------------------------------------------------------------------------
2222
%
2323
% ------
2424
% INPUT:
2525
% ------
26-
% planet - (OPTIONAL) (char) 'Sun', 'Moon', 'Mercury', 'Venus',
27-
% 'Earth', 'Earth Cloudy', 'Earth Coastlines',
26+
% planet - (OPTIONAL) (char array) 'Sun', 'Moon', 'Mercury',
27+
% 'Venus', 'Earth', 'Earth Cloudy', 'Earth Coastlines',
2828
% 'Earth Night', 'Earth Night Cloudy', 'Mars',
2929
% 'Jupiter', 'Saturn', 'Uranus', 'Neptune', or 'Pluto'
3030
% (defaults to 'Earth Cloudy')
3131
% opts - (OPTIONAL) (1×1 struct) plot options
32-
% • Clipping - (char) 'on' or 'off' (defaults to 'off')
33-
% --> if 'on', the surface will be "clipped" to fit
34-
% the axes when zooming in
35-
% • Color - (char or 1×3 double) line color (only relevant
32+
% • Clipping - (char array) 'on' or 'off' (defaults to 'off')
33+
% if 'on', the surface will be "clipped" to fit the
34+
% axes when zooming in
35+
% • Color - (char array or 1×3 double) line color (only relevant
3636
% when drawing Earth coastlines)
37-
% --> can be specified as a name, short name, or RGB
38-
% triplet [rgb]
37+
% can be specified as a name, short name, or RGB
38+
% triplet [rgb]
3939
% • FaceAlpha - (1×1 double) 0 for 100% transparency, 1 for 100%
4040
% opacity
4141
% • LineWidth - (1×1 double) line width (only relevant when drawing
4242
% Earth coastlines)
43-
% • LineStyle - (char) line style (only relevant when drawing Earth
44-
% coastlines)
43+
% • LineStyle - (char array) line style (only relevant when drawing
44+
% Earth coastlines)
4545
% • Position - (3×1 double) position of planet's geometric center
46-
% • RefPlane - (char) 'equatorial' or 'ecliptic'
46+
% • RefPlane - (char array) 'equatorial' or 'ecliptic'
4747
% • RotAngle - (1×1 double) rotation angle [deg]
48-
% • Units - (char) 'AU', 'ft', 'km', 'm', 'mi', or 'nmi'
48+
% • Units - (char array) 'AU', 'ft', 'km', 'm', 'mi', or 'nmi'
4949
%
5050
% -------
5151
% OUTPUT:
@@ -55,18 +55,17 @@
5555
% -----
5656
% NOTE:
5757
% -----
58-
% --> All fields of "opts" do NOT have to be defined; when a field is
59-
% left undefined, the rest of the plot settings are set to default
60-
% values.
61-
% --> Use the "background" function included with download to set the
62-
% plot background. When using "background" to set the plot
63-
% background, the function call on "background" must occur BEFORE the
64-
% function call on "planet3D", otherwise the background will be
65-
% plotted over the celestial body.
66-
% --> If you want to produce separate plots on separate figures using the
67-
% "planet3D" function, always use the "drawnow" command before
68-
% initializing a new figure to ensure that the correct plots are
69-
% drawn on the correct figures.
58+
% • All fields of "opts" do NOT have to be defined; when a field is left
59+
% undefined, the rest of the plot settings are set to default values.
60+
% • Use the "background" function included with download to set the plot
61+
% background. When using "background" to set the plot background, the
62+
% function call on "background" must occur BEFORE the function call on
63+
% "planet3D", otherwise the background will be plotted over the
64+
% celestial body.
65+
% • If you want to produce separate plots on separate figures using the
66+
% "planet3D" function, always use the "drawnow" command before
67+
% initializing a new figure to ensure that the correct plots are drawn
68+
% on the correct figures.
7069
%
7170
%==========================================================================
7271
function planet_surface = planet3D(planet,opts)
@@ -276,10 +275,18 @@
276275
% Performs translation.
277276
% ---------------------
278277

278+
% translates coordinates of surface object
279279
planet_surface.XData = planet_surface.XData+position(1);
280280
planet_surface.YData = planet_surface.YData+position(2);
281281
planet_surface.ZData = planet_surface.ZData+position(3);
282282

283+
% translates coordinates of Earth coastlines
284+
if strcmpi(planet,'Earth Coastlines')
285+
x_coast = x_coast+position(1);
286+
y_coast = y_coast+position(1);
287+
z_coast = z_coast+position(1);
288+
end
289+
283290
% --------------------------------------------------------------
284291
% Drawing additional lines (i.e. coastlines or rings of Saturn).
285292
% --------------------------------------------------------------
@@ -315,8 +322,8 @@
315322
% speed - we plot the bands of Saturns rings as individual lines
316323
% and don't want to plot thousands of lines) - this shrinking
317324
% process is condensed from the reduced_data_points function (see
318-
% https://www.mathworks.com/matlabcentral/fileexchange/86218-reduce
319-
% -number-of-data-points-reduce_data_points)
325+
% https://github.com/tamaskis/Useful_Functions_for_MATLAB-MATLAB/
326+
% blob/main/functions/reduce_data_points.m)
320327
n_new = 200;
321328
colors = colors(1:round(n/n_new):n,:);
322329

@@ -333,18 +340,23 @@
333340
% the planet s(https://en.wikipedia.org/wiki/Rings_of_Saturn)
334341
r = conversion_factor*(R+7000000+((80000000-7000000)/n_new)*i);
335342

336-
% x, y, and z coordinates of Saturns rings in equatorial plane
337-
x_ring = position(1)+r*cos(theta);
338-
y_ring = position(2)+r*sin(theta);
339-
z_ring = position(3)*ones(size(theta));
343+
% x, y, and z coordinates of Saturns rings in equatorial plane,
344+
% centered at origin
345+
x_ring = r*cos(theta);
346+
y_ring = r*sin(theta);
347+
z_ring = ones(size(theta));
340348

341-
% rotates rings to equatorial plane (uses same rotation matrix
342-
% as tilting the planet earlier in code)
349+
% tilts rings
343350
new_coordinates = R1*[x_ring;y_ring;z_ring];
344351
x_ring = new_coordinates(1,:);
345352
y_ring = new_coordinates(2,:);
346353
z_ring = new_coordinates(3,:);
347354

355+
% centers rings on main body
356+
x_ring = x_ring+position(1);
357+
y_ring = y_ring+position(1);
358+
z_ring = z_ring+position(1);
359+
348360
% plots the jth ring
349361
plot3(x_ring,y_ring,z_ring,'Color',colors(i,:));
350362

0 commit comments

Comments
 (0)