Skip to content

Commit a9cbc17

Browse files
committed
ecef <=> eci: keep _naive functions
1 parent 5b0ea03 commit a9cbc17

5 files changed

Lines changed: 39 additions & 49 deletions

File tree

+matmap3d/aer2eci.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
%% AER2ECI convert AER (azimuth, elevation, slant range) to ECI
22
%
3-
% NOTE: because underlying ecef2eci() is rotation only, error can be order
4-
% 1..10%
5-
%
63
%%% Inputs
74
% * utc: datetime UTC
85
% * az,el,rng: (degrees, meters)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
%% ECEF2ECI rotate ECEF coordinates to ECI
2-
% because this doesn't account for nutation, etc. error is often > 1%
1+
%% ECEF2ECI_NAIVE rotate ECEF coordinates to ECI
2+
% because this doesn't account for nutation, etc. error is generally significant
33
%
44
%%% Inputs
55
% x0, y0, z0: ECEF position (meters)
66
% utc: time UTC
77
%%% Outputs
88
% * x,y,z: ECI position (meters)
99

10-
function [x,y,z] = ecef2eci(utc, x0, y0, z0)
10+
function [x,y,z] = ecef2eci_naive(utc, x0, y0, z0)
1111
arguments
1212
utc (:,1) datetime
1313
x0 (:,1) {mustBeReal,mustBeEqualSize(utc,x0)}
@@ -19,9 +19,9 @@
1919
gst = matmap3d.greenwichsrt(juliandate(utc));
2020

2121
% Convert into ECEF
22-
x = nan(size(gst));
23-
y = nan(size(x));
24-
z = nan(size(x));
22+
x = nan(like=gst);
23+
y = nan(like=gst);
24+
z = nan(like=gst);
2525

2626
for j = 1:length(x)
2727
eci = matmap3d.R3(gst(j)).' * [x0(j), y0(j), z0(j)].';
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
%% ECI2ECEF rotate ECI coordinates to ECEF
2-
% because this doesn't account for nutation, etc. error is often > 1%
1+
%% ECI2ECEF_NAIVE rotate ECI coordinates to ECEF
2+
% because this doesn't account for nutation, etc. error is generally significant
33
%
44
% x_eci, y_eci, z_eci: eci position vectors
55
% utc: Matlab datetime UTC
66
%
77
% x,y,z: ECEF position (meters)
8-
function [x,y,z] = eci2ecef(utc, x_eci, y_eci, z_eci)
8+
9+
function [x,y,z] = eci2ecef_naive(utc, x_eci, y_eci, z_eci)
910
arguments
1011
utc (:,1) datetime
1112
x_eci (:,1) {mustBeReal,mustBeEqualSize(utc,x_eci)}
@@ -16,9 +17,9 @@
1617
% Greenwich hour angles (radians)
1718
gst = matmap3d.greenwichsrt(juliandate(utc));
1819

19-
x = nan(size(x_eci));
20-
y = nan(size(x));
21-
z = nan(size(x));
20+
x = nan(like=x_eci);
21+
y = nan(like=y_eci);
22+
z = nan(like=z_eci);
2223

2324
for j = 1:length(x)
2425
ecef = matmap3d.R3(gst(j)) * [x_eci(j), y_eci(j), z_eci(j)].';

.archive/juliantime.m

Lines changed: 0 additions & 34 deletions
This file was deleted.

octave/juliandate.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
%% juliandate datetime to Julian time
2+
%
3+
% from D.Vallado Fundamentals of Astrodynamics and Applications p.187
4+
% and J. Meeus Astronomical Algorithms 1991 Eqn. 7.1 pg. 61
5+
%
6+
% parameters:
7+
% t: datetime vector
8+
%
9+
% results:
10+
% jd: julian date (days since Jan 1, 4173 BCE
11+
12+
function jd = juliandate(t)
13+
14+
[y, mon, d, h, m, s] = datevec(t);
15+
16+
i = mon < 3;
17+
y(i) = y(i) - 1;
18+
mon(i) = mon(i) + 12;
19+
20+
A = fix(y / 100.);
21+
B = 2 - A + fix(A / 4.);
22+
C = ((s / 60. + m) / 60. + h) / 24.;
23+
24+
jd = fix(365.25 * (y + 4716)) + fix(30.6001 * (mon + 1)) + d + B - 1524.5 + C;
25+
26+
end

0 commit comments

Comments
 (0)