VR-Vantage 3.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 [SEU]
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);
82 
83 
84  /* ------------------ POSITION PROPERTIES and AXIS GENERATION ------ */
85  JRMLIBRARY_API double RangeToTOA(double alt, VECTOR SEU, double EarthRadius, double altTOA); // SPHERICAL EARTH ONLY
86  JRMLIBRARY_API double RangeToTOAOrEarth(double alt, VECTOR SEU, double EarthRadius, double altTOA); // SPHERICAL EARTH ONLY
87  JRMLIBRARY_API double E_Alt(ellipsoid E, VECTOR R);
89  JRMLIBRARY_API int NEDaxes(GEOCENTRIC_LOCATION R, ellipsoid E, VECTOR* North, VECTOR* East, VECTOR* Down);
90  JRMLIBRARY_API int Get_HV_Axes_NED(VECTOR NED, VECTOR *horizontal, VECTOR *vertical);
91  JRMLIBRARY_API int GetHVAxesAtGivenAzEl(double az_deg, double el_deg, VECTOR *Horiz, VECTOR *Vert);
92  JRMLIBRARY_API double RelativeRoll(EULERzyx incident, VECTOR LOS_NED, EULERzyx reflector);
93  JRMLIBRARY_API int GetModtranPathParms(double rho, double altlo, double althi, VECTOR *sensor, VECTOR *matsys, MODPATH *modpath, jrmbool hitflag); // SPHERICAL EARTH ONLY
96  JRMLIBRARY_API MODPATH ConvertRTPathToModPath(RTPATH rt, jrmbool hitflag); // FLAT EARTH
97  JRMLIBRARY_API MODPATH ConvertRTPathToModPath2(RTPATH rt, jrmbool hitflag); // SPHERICAL EARTH
100  JRMLIBRARY_API SEUPATH ConvertModPathToSEUPath(MODPATH mp); // SPHERICAL EARTH
101  JRMLIBRARY_API double ModBeta(VECTOR r, double rho); // SPHERICAL EARTH ONLY
102  JRMLIBRARY_API double ModAlt(VECTOR r, double rho); // SPHERICAL EARTH ONLY
103  JRMLIBRARY_API double ModPhi(VECTOR r, double rho); // SPHERICAL EARTH ONLY
104  JRMLIBRARY_API VECTOR ModRhoHat(VECTOR r, double rho); // SPHERICAL EARTH ONLY
105  JRMLIBRARY_API double earth_radius(int model); // SPHERICAL EARTH ONLY
106  JRMLIBRARY_API double RangeToSphere(double rho, double alt, double alpha); // SPHERICAL EARTH ONLY
107  JRMLIBRARY_API double rangetheta(double h1, double h2, double theta, double rho); // SPHERICAL EARTH ONLY
108  JRMLIBRARY_API double RangeToNextLayer(double alt, double theta, double rho, double lobound, double hibound); // SPHERICAL EARTH ONLY
109 
110  /* -------------------- COORDINATE CONVERSIONS ---------------------- */
113  JRMLIBRARY_API int FRD2RUB(EULERzyx FRD_orient, VECTOR *rotvec, double *rotmag);
154 
155  /* ----------------------- TRACK MANIPULATION --------------------------- */
156  typedef struct
157  {
158  double timestamp; // [s] relative time at which this information is valid.
159  GEODETIC_LOCATION geoD; // Used by the "Transaction Layer" API. Same purpose as "position" below, but geospecific, not relative,
160  VECTOR position; // General-purpose positioning (see context for units)
161  EULERzyx orient; // General-purpose rotation of an object body space relative to a global space, using Euler body {+z, +y, +x} convention.
166  unsigned int appearance;
167  } TRACK; // General-purpose structure which places an object at a certain global location, then rotates this object about its local origin.
168 
169 
170  JRMLIBRARY_API int ReadTrackFile(char *track_file, int *ntracks, TRACK **track);
171  JRMLIBRARY_API int WriteTrackFile(char *track_file, int ntracks, TRACK *track);
172 
173  JRMLIBRARY_API int CompareTRACKs(void *AV, void *BV);
174  // Used for sorting TRACKs by increasing timestamp
175 
176  JRMLIBRARY_API void SortTRACKs(TRACK *track, int ntracks);
177  // Used for sorting TRACKs by increasing timestamp
178 
180  // Given two objects A and B about ellipsoid E, returns the position and orientation of B relative to A's FRD system.
181 
183  // Given a position/orientation of object B with respect to a local FRD system at A,
184  // and a rotation O of A's system about A's origin,
185  // returns a new TRACK giving the position/orientation of B with respect to the new rotated system at A,
186 
187  JRMLIBRARY_API int Add_Track(TRACK **c, int *nc, TRACK toadd);
188  // Adds TRACK toadd to end of array c and increments nc
189 
190  JRMLIBRARY_API int Free_Tracks(TRACK **track);
191  // Frees TRACK memory
192 
193  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);
194 
196  // StartOrientAtEndpoint: Given orientation startFRD w.r.t. NED at startC, projects this orientation along LOS, and returns it as seen at endC.
197 
198  // GetLOSOrientationAtTarget() finds, for a given sensor and object,
199  // the orientation relative to the OBJECT's local FRD system of the object-to-sensor LOS path.
200  // {az,el} are in [deg]. el is measured positive towards +z fom xy plane, az is measured counterclockwise about +z from +x.
201  JRMLIBRARY_API int GetLOSOrientationAtTarget(double *az, double *el, GEOCENTRIC_LOCATION sensgeoC, GEOCENTRIC_LOCATION objgeoC, EULERzyx objFRDwrtNED, ellipsoid E);
202 
203 
204  JRMLIBRARY_API void CalculateSensorAndTargetLOSAngles(ellipsoid E, GEOCENTRIC_LOCATION sensorC, EULERzyx sensorO, GEOCENTRIC_LOCATION targetC, EULERzyx targetO, VECTOR *totargetFRD, VECTOR *tosensorFRD);
205  // Inputs :
206  // sensorC = geocentric location of sensor
207  // sensorO = EULERzyx orientation of sensor FRD w.r.t. its local NED
208  // targetC = geocentric location of target
209  // targetO = EULERzyx orientation of sensor FRD w.r.t. its local NED
210  // Outputs :
211  // totargetFRD = unit vector at sensor, pointing to target in sensor's FRD frame
212  // tosensorFRD = unit vector at target, pointing to sensor in target's FRD frame
213 
214  JRMLIBRARY_API VECTOR sensRUB2hitNED(ellipsoid E, GEOCENTRIC_LOCATION sens_geoC, EULERzyx ifov_FRD_orientation, double range, VECTOR sensRUB);
215 
216  //JRMLIBRARY_API void MoveGEOCbyGivenPathLength(GEOCENTRIC_LOCATION *C, VECTOR trajhatNED, double pathlength, ellipsoid E);
217  // Moves a geocentric position by a given (small) path length in a given direction while maintaining altitude.
218 
219 
220  /* ------------------- EPHEMERIS & SCENARIO POSITIONAL CALCULATIONS ----------------- */
221 
222  typedef struct
223  {
224  // INPUTS:
225  double lat; // [deg] Scenario Latitude
226  double lon; // [deg] Scenario Longitude
227  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.
228  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.
229  ellipsoid E; // Ellipsoid used for Earth
230  // OUTPUTS:
231  double phMoon; // [unitless 0-4] Moon Phase : 0=new, 1=quarter moon, 2=half, 3=3/4 full moon, 4=full moon;
232  double elMoon; // [deg] Lunar elevation angle relative to tangent plane at {lat,lon}
233  double azMoon; // [deg] Lunar azimuth angle measured from local South toward local East at {lat,lon}
234  double raMoon; // [rad] Lunar right ascension
235  double decMoon; // [rad] Lunar declination
236  double latMoon; // [deg] latitude currently having moon directly overhead
237  double lonMoon; // [deg] longitude currently having moon directly overhead
238  double rangeMoon; // [km] Earth-to-Moon distance
239  double fracMoon; // [unitless] illuminated fraction of Moon disk
240  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}
241  double elSun; // [deg] Solar elevation angle relative to tangent plane at {lat,lon}
242  double azSun; // [deg] Solar azimuth angle measured from local South toward local East at {lat,lon}
243  double raSun; // [rad] Solar right ascension
244  double decSun; // [rad] Solar declination
245  double latSun; // [deg] latitude currently having sun directly overhead
246  double lonSun; // [deg] longitude currently having sun directly overhead
247  double rangeSun; // [km] Earth-to-Sun distance
248  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}
249  double sunrise, sunset; // [hrs] Local hours (23.99 format) of sunrise and sunset
250  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}
251  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}
252  VECTOR suneast; // [unitless -1->1] cosine {x,y,z} components of cross product (sunplane X sunmax).
253  JRMTIME last_env; // Date/Time environmental irradiance arrays last updated.
254  JRMTIME last_diurnal; // Date/Time diurnal irradiance arrays last updated.
255  } EPHEMERIS;
256 
257  // OrientationInMetSEU(): Given METIN tangent plane system location fm and sensor or object location C, find sensor or object's local orientSEU vector as seen in METIN.fm local SEU.
259 
260 
261 
262  typedef struct
263  {
264  // ------- axiomatic --------
265  ellipsoid E; // Earth ellipsoid
266  double minalt; // [m] <0 indicates a sea floor
267  GEODETIC_LOCATION sourceD; // source Geodetic location
268  EULERzyx sourceO; // source local orientation ([rad] FRD w.r.t. NED)
269  VECTOR sourceV; // source linear velocity ([m/s] in geo-local NED)
270  GEODETIC_LOCATION targetD; // target Geodetic location
271  EULERzyx targetO; // target local orientation ([rad] FRD w.r.t. NED)
272  VECTOR targetV; // target linear velocity ([m/s] in geo-local NED)
273  EULERzyx CMassetO; // target EW/CW countermeasure asset absolute orientation ([rad] FRD w.r.t. NED) -- OPTIONAL
274  int CMassetStatus; // 0=all off, 1=Datalink on, 2=RF_Jammer on, 3=RF_Decoy on. -- OPTIONAL
275  // ------ derived -----------
276  double range; // [m] source-target range
277  double range2back; // [m] source-background range
278  GEODETIC_LOCATION backD; // background geodetic location (to earth ellipsoid or TOA in LOS direction)
279  VECTOR totargetFRD; // [unitless cosines] direction to target in sensor's FRD frame
280  VECTOR tosourceFRD; // [unitless cosines] direction to source in target's FRD frame
281  VECTOR VrelativeFRD; // [m/s] target-source relative velocity in sensor's FRD frame
282  } ST_PLACEMENT; // Source-Target placement & target CM asset status
283 
284 
288 
289 
290  typedef struct
291  {
292  GEOCENTRIC_LOCATION geoc_loc; // Geocentric location of FOV apex (i.e. start point)
293  GEODETIC_LOCATION geodetic_loc; // -- UNUSED IN SS EXCEPT AS INPUT THROUGH SCENARIO FILE
294  EULERzyx FRD_orientation; // Gives orientation of FOV's FRD system w.r.t. local NED at geoD
295  VECTOR ned_view; // sensor orientation in [North, East, Down]
296  double vfov, hfov; // [deg] vertical and horizontal full angles-of-view
297  long hsamples, vsamples; // [unitless]
298  double hifov_mrad, vifov_mrad; // [mrad] detector fov's calculated as hfov/hsamples, etc.
299  } FOV;
300 
301  // RotateToPixel() finds the NED VECTOR which corresponds to rotating the FOV center (fov.ned_view) to pixel {hpixel,vpixel},
302  // where the upper-leftmost pixel is defined to be {0,0}.
303  JRMLIBRARY_API VECTOR RotateVectorToPixel(FOV fov, int hpixel, int vpixel);
304 
305  // RotateVectorToPixel() finds the orientation of FRD w.r.t. NED which corresponds to rotating the FOV center (fov.FRD_orientation) to pixel {hpixel,vpixel},
306  // where the upper-leftmost pixel is defined to be {0,0}.
307  JRMLIBRARY_API EULERzyx RotateOrientToPixel(FOV fov, int hpixel, int vpixel);
308 
309 
310  /* ------------------- GEOMETRIC INTERSECTION CALCULATIONS ------------- */
311 
316 
317 
318 
319 #ifdef __cplusplus
320 }
321 #endif
322 
323 #endif // ELLIPSOID_H_
324 


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