VR-Vantage 2.8 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ellipsoid.h
Go to the documentation of this file.
1 /* © 1998 JRM Technologies, Inc.*/
2 #ifndef ELLIPSOID_H_
3 #define ELLIPSOID_H_
4 
5 #include "JRMlibrary.h"
6 #include "JRMlibraryDLLstub.h"
7 
8 
9 #ifdef __cplusplus
10 extern "C"
11 {
12 #endif
13 
14  /* -------------- STRUCTURE CREATION -------------------------- */
15 
16  typedef struct
17  {
18  double lat; // latitude [degN] : -90=SouthPole, 90=NorthPole
19  double lon; // longitude [degE]: 0=Prime Meridian, 359=1deg West of Prime Meridian
20  double alt; // altitude [m] above ellipsoid
22 
23  typedef struct
24  {
25  double X; // distance [m] away from ellipsoid center along direction to prime meridian
26  double Y; // distance [m] away from ellipsoid center along direction to east longitudinal meridian
27  double Z; // distance [m] away from ellipsoid center along direction to North geodetic pole
29 
30 
31  typedef struct
32  {
33  double a; // distance [m] of ellipsoid surface from ellipsoid center along direction to prime meridian at equator
34  double b; // distance [m] of ellipsoid surface from ellipsoid center along direction to east longitudinal meridian at equator
35  double c; // distance [m] of ellipsoid surface from ellipsoid center along direction to North geodetic pole
36  int naxes; // Number of axes actually used: 1=sphere (a=b=c, fill c at least); 2=biaxial ellipsoid ((a=b)!=c, fill b and c at least; 3=triaxial ellipsoid (a!=b!=c, fill all).
37  } ellipsoid;
38 
39  typedef struct
40  {
41  double rho,beta; //km,rad
42  double h1,angle; //km,rad
43  double h2,phi; //km,rad
44  double range,minh; //km,km
45  double path_i,path_j,path_k; //km,km,km
46  int lenn; // 0 = default short path, 1 = long path for cases where h1, h2, and one angle are specified.
47  double PathAzEoN; // Path azimuth [deg East of North] (used if Iprm=0,1,10,11)
48  int pathtype; // Path type : horizontal(1), slant(2), slant to space or ground(3)
49  } MODPATH;
50 
51  typedef struct
52  {
53  double earthRadius; // [m]
54  double sensAlt; // [m]
55  double objAlt; // [m]
56  double groundRange; // [m]
57  double slantRange; // [m]
58  double ViewAzEofN; // [deg] From sensor to object. RT doesn't actually have this yet, but should.
59  } RTPATH;
60 
61  typedef struct
62  {
63  VECTOR s,m; // [km]
64  } SEUPATH;
65 
66 
67  /* -------------- STRUCTURE CREATION AND SIMPLE FUNCTIONS ----- */
68  JRMLIBRARY_API ellipsoid MakeEllipsoid(double a, double b, double c, int naxes);
69  JRMLIBRARY_API GEODETIC_LOCATION MakeGeoD(double lat, double lon, double alt);
70  JRMLIBRARY_API GEOCENTRIC_LOCATION MakeGeoC(double X, double Y, double Z);
79 
80  /* ------------------ POSITION PROPERTIES and AXIS GENERATION ------ */
81  JRMLIBRARY_API double RangeToTOA(double alt, VECTOR SEU, double EarthRadius, double altTOA); // SPHERICAL EARTH ONLY
82  JRMLIBRARY_API double RangeToTOAOrEarth(double alt, VECTOR SEU, double EarthRadius, double altTOA); // SPHERICAL EARTH ONLY
83  JRMLIBRARY_API double E_Alt(ellipsoid E, VECTOR R);
85  JRMLIBRARY_API int NEDaxes(GEOCENTRIC_LOCATION R, ellipsoid E, VECTOR* North, VECTOR* East, VECTOR* Down);
86  JRMLIBRARY_API int GetHVAxesAtGivenAzEl(double az_deg, double el_deg, VECTOR *Horiz, VECTOR *Vert);
87  JRMLIBRARY_API double RelativeRoll(EULERzyx incident, VECTOR LOS_NED, EULERzyx reflector);
88  JRMLIBRARY_API int GetModtranPathParms(double rho, double altlo, double althi, VECTOR *sensor, VECTOR *matsys, MODPATH *modpath, jrmbool hitflag); // SPHERICAL EARTH ONLY
93  JRMLIBRARY_API double ModBeta(VECTOR r, double rho); // SPHERICAL EARTH ONLY
94  JRMLIBRARY_API double ModAlt(VECTOR r, double rho); // SPHERICAL EARTH ONLY
95  JRMLIBRARY_API double ModPhi(VECTOR r, double rho); // SPHERICAL EARTH ONLY
96  JRMLIBRARY_API VECTOR ModRhoHat(VECTOR r, double rho); // SPHERICAL EARTH ONLY
97  JRMLIBRARY_API double earth_radius(int model); // SPHERICAL EARTH ONLY
98  JRMLIBRARY_API double RangeToSphere(double rho, double alt, double alpha); // SPHERICAL EARTH ONLY
99  JRMLIBRARY_API double rangetheta(double h1, double h2, double theta, double rho); // SPHERICAL EARTH ONLY
100  JRMLIBRARY_API double RangeToNextLayer(double alt, double theta, double rho, double lobound, double hibound); // SPHERICAL EARTH ONLY
101 
102  /* -------------------- COORDINATE CONVERSIONS ---------------------- */
105  JRMLIBRARY_API int FRD2RUB(EULERzyx FRD_orient, VECTOR *rotvec, double *rotmag);
140 
141  /* ----------------------- TRACK MANIPULATION --------------------------- */
142  typedef struct
143  {
144  double timestamp; // [s] relative time at which this information is valid.
145  GEODETIC_LOCATION geoD; // Used by the "Transaction Layer" API. Same purpose as "position" below, but geospecific, not relative,
146  VECTOR position; // General-purpose positioning (see context for units)
147  EULERzyx orient; // General-purpose rotation of an object body space relative to a global space, using Euler body {+z, +y, +x} convention.
152  } TRACK; // General-purpose structure which places an object at a certain global location, then rotates this object about its local origin.
153 
154  JRMLIBRARY_API int CompareTRACKs(void *AV, void *BV);
155  // Used for sorting TRACKs by increasing timestamp
156 
157  JRMLIBRARY_API void SortTRACKs(TRACK *track, int ntracks);
158  // Used for sorting TRACKs by increasing timestamp
159 
161  // Given two objects A and B about ellipsoid E, returns the position and orientation of B relative to A's FRD system.
162 
164  // Given a position/orientation of object B with respect to a local FRD system at A,
165  // and a rotation O of A's system about A's origin,
166  // returns a new TRACK giving the position/orientation of B with respect to the new rotated system at A,
167 
168  JRMLIBRARY_API int Add_Track(TRACK **c, int *nc, TRACK toadd);
169  // Adds TRACK toadd to end of array c and increments nc
170 
171  JRMLIBRARY_API int Free_Tracks(TRACK **track);
172  // Frees TRACK memory
173 
174  JRMLIBRARY_API int GetSensorGlobalPositionAndFRD_Orientation(ellipsoid E, GEODETIC_LOCATION ScenarioGeoD, double SensorRange, double SensorElevationAngle_deg, double SensorAzimuthAngle_deg_fromSouth, GEOCENTRIC_LOCATION *SensC, GEODETIC_LOCATION *SensD, EULERzyx *SensO);
175 
177  // StartOrientAtEndpoint: Given orientation startFRD w.r.t. NED at startC, projects this orientation along LOS, and returns it as seen at endC.
178 
179 
180  JRMLIBRARY_API void CalculateSensorAndTargetLOSAngles(ellipsoid E, GEOCENTRIC_LOCATION sensorC, EULERzyx sensorO, GEOCENTRIC_LOCATION targetC, EULERzyx targetO, VECTOR *totargetFRD, VECTOR *tosensorFRD);
181  // Inputs :
182  // sensorC = geocentric location of sensor
183  // sensorO = EULERzyx orientation of sensor FRD w.r.t. its local NED
184  // targetC = geocentric location of target
185  // targetO = EULERzyx orientation of sensor FRD w.r.t. its local NED
186  // Outputs :
187  // totargetFRD = unit vector at sensor, pointing to target in sensor's FRD frame
188  // tosensorFRD = unit vector at target, pointing to sensor in target's FRD frame
189 
190  JRMLIBRARY_API VECTOR sensRUB2hitNED(ellipsoid E, GEOCENTRIC_LOCATION sens_geoC, EULERzyx ifov_FRD_orientation, double range, VECTOR sensRUB);
191 
192  //JRMLIBRARY_API void MoveGEOCbyGivenPathLength(GEOCENTRIC_LOCATION *C, VECTOR trajhatNED, double pathlength, ellipsoid E);
193  // Moves a geocentric position by a given (small) path length in a given direction while maintaining altitude.
194 
195 
196  /* ------------------- EPHEMERIS & SCENARIO POSITIONAL CALCULATIONS ----------------- */
197  typedef struct
198  {
199  // ------- axiomatic --------
200  ellipsoid E; // Earth ellipsoid
201  double minalt; // [m] <0 indicates a sea floor
202  GEODETIC_LOCATION sourceD; // source Geodetic location
203  EULERzyx sourceO; // source local orientation ([rad] FRD w.r.t. NED)
204  VECTOR sourceV; // source linear velocity ([m/s] in geo-local NED)
205  GEODETIC_LOCATION targetD; // target Geodetic location
206  EULERzyx targetO; // target local orientation ([rad] FRD w.r.t. NED)
207  VECTOR targetV; // target linear velocity ([m/s] in geo-local NED)
208  EULERzyx CMassetO; // target EW/CW countermeasure asset absolute orientation ([rad] FRD w.r.t. NED) -- OPTIONAL
209  int CMassetStatus; // 0=all off, 1=Datalink on, 2=RF_Jammer on, 3=RF_Decoy on. -- OPTIONAL
210  // ------ derived -----------
211  double range; // [m] source-target range
212  double range2back; // [m] source-background range
213  GEODETIC_LOCATION backD; // background geodetic location (to earth ellipsoid or TOA in LOS direction)
214  VECTOR totargetFRD; // [unitless cosines] direction to target in sensor's FRD frame
215  VECTOR tosourceFRD; // [unitless cosines] direction to source in target's FRD frame
216  VECTOR VrelativeFRD; // [m/s] target-source relative velocity in sensor's FRD frame
217  } ST_PLACEMENT; // Source-Target placement & target CM asset status
218 
222 
223  typedef struct
224  {
225  // INPUTS:
226  double lat; // [deg] Scenario Latitude
227  double lon; // [deg] Scenario Longitude
228  JRMTIME current; // Current date/time in Astronomical Julian format. Time is in 0-23.99 hr format and corresponds to the local time at the given geodetic lat/lon, where every geodetic point in the same time zone has the same local time. The time zones are defined such that longitude 0 is in the center of a 15-degree time zone, such that every 15-degree longitudinal interval, starting at longitude 7.5, comprises another separate time zone.
229  double lhn; // [hrs] local hour noon. The local time at which the sun crosses the given longitude. Differs from 12:00 because of intra-zone time standardization.
230  ellipsoid E; // Ellipsoid used for Earth
231  // OUTPUTS:
232  double phMoon; // [unitless 0-4] Moon Phase : 0=new, 1=quarter moon, 2=half, 3=3/4 full moon, 4=full moon;
233  double elMoon; // [deg] Lunar elevation angle relative to tangent plane at {lat,lon}
234  double azMoon; // [deg] Lunar azimuth angle measured from local South toward local East at {lat,lon}
235  double raMoon; // [rad] Lunar right ascension
236  double decMoon; // [rad] Lunar declination
237  double latMoon; // [deg] latitude currently having moon directly overhead
238  double lonMoon; // [deg] longitude currently having moon directly overhead
239  double rangeMoon; // [km] Earth-to-Moon distance
240  double fracMoon; // [unitless] illuminated fraction of Moon disk
241  VECTOR moon; // [unitless -1->1] cosine {x,y,z} components of unit vector toward Lunar source in local South,East,Up system at {lat,lon}
242  double elSun; // [deg] Solar elevation angle relative to tangent plane at {lat,lon}
243  double azSun; // [deg] Solar azimuth angle measured from local South toward local East at {lat,lon}
244  double raSun; // [rad] Solar right ascension
245  double decSun; // [rad] Solar declination
246  double latSun; // [deg] latitude currently having sun directly overhead
247  double lonSun; // [deg] longitude currently having sun directly overhead
248  double rangeSun; // [km] Earth-to-Sun distance
249  VECTOR sun; // [unitless -1->1] cosine {x,y,z} components of unit vector toward Solar source in local South,East,Up system at {lat,lon}
250  double sunrise, sunset; // [hrs] Local hours (23.99 format) of sunrise and sunset
251  VECTOR sunmax; // [unitless -1->1] cosine {x,y,z} components of unit vector toward highest Solar source direction in local South,East,Up system at {lat,lon}
252  VECTOR sunplane; // [unitless -1->1] cosine {x,y,z} components of unit vector defining plane of solar motion across sky, in local South,East,Up system at {lat,lon}
253  VECTOR suneast; // [unitless -1->1] cosine {x,y,z} components of cross product (sunplane X sunmax).
254  JRMTIME last_env; // Date/Time environment last updated:
255  JRMTIME last_diurnal; // Date/Time diurnal irradiance arrays last updated.
256  } EPHEMERIS;
257 
258 
259  /* ------------------- GEOMETRIC INTERSECTION CALCULATIONS ------------- */
260 
265 
266 
267 
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif // ELLIPSOID_H_
273 


Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)