VR-Vantage 3.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Objects.h
Go to the documentation of this file.
1 /* © 1998 JRM Technologies, Inc.*/
2 
3 
4 
5 /***********************************
6 Copyright JRM Enterprises, Inc. 1998
7 All rights reserved.
8 
9 This code is the intellectual property of JRM Enterprises, Inc.
10 It may not be used or released as source or compiled binary form
11 without the prior written consent of JRM Enterprises, Inc.
12 ***********************************/
13 
14 
15 #ifndef OBJECTS_H_
16 #define OBJECTS_H_
17 
18 #include "JRMlibrary.h"
19 #include "Ellipsoid.h"
20 
21 #include "SigSimDefines.h"
22 #include "SigSimStructs.h"
23 
24 #include "particles.h"
25 #include "Radar.h"
26 
27 
28 #if SIGSIM_PRODUCT == SIGSIM3A
29 //#include "polygons.h"
30 //#include "GFE-NRT.h"
31 #include "Sonar.h"
32 #include "RFsig.h"
33 #endif
34 
35 
36 #include "sigsim.h"
37 #include "sigsimDLLstub.h"
38 
39 
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #endif
44 
45  /* ------------ DEFINITIONS, ENUMERANTS, and DATA STRUCTURES ------------------ */
46 
47  typedef enum
48  {
55  } OBJECT_TYPE;
56 
57  typedef struct
58  {
61  double thrust; // [kg/hr] engine thrust
62  } OBJECT_STATE; // stub
63 
64  typedef struct
65  {
66  VECTOR Rview; // unit vector tangent to refracted path (at sensor location) to ID [unitless cosines, in sensor-local (North, East, Down) system]
67  VECTOR Rtarget; // Orientation of path away from target in target local NED system. [unitless cosines]
68  double Range; // Path length [m]
69  double Rdot; // rate of change of Refracted LOS path length [m/s].
70  } Rpath;
71 
72  typedef struct
73  {
74  char imagefile[SIGSIM_STRING_SIZE];
75  double Rmin, Rave, Rmax; // [W/cm2] image emittance
76  double ax, bx; // [um] image waveband
78 
79  typedef struct
80  {
82  } OBJECT_VIEWS;
83 
84  typedef struct
85  {
86  char object_id[SIGSIM_STRING_SIZE];
87  char object_subdirectory[SIGSIM_STRING_SIZE];
90 
91  int ntracks; // Number of TRACKS in track array
92  TRACK *track; // Expected trajectory
93  GEODETIC_LOCATION geod_loc; // Position of origin of local FRD system
94  GEOCENTRIC_LOCATION geoc_loc; // Position of origin of local FRD system
95  EULERzyx FRD_orientation; // Relates object body FRD to instantaneous local NED.
96  VECTOR ned_linear_velocity; // [m/s] Current linear velocity
97  VECTOR ned_linear_acceleration; // [m/s2] Curent linear acceleration
98  VECTOR ned_angular_velocity; // [rad/s] Current angular velocity. Magnitude gives speed clockwise about direction
99  VECTOR ned_angular_acceleration; // [rad/s2] Current angular acceleration. Magnitude gives accel clockwise about direction
100 
101  double length, width, height; // [m] calculated
102  long nmatls; // number of materials in the mp_table array
103  MATL_PROP_TABLE *mp_table; // array of material property data (BRDF and areal RCS)
104  OBJECT_VIEWS *view; // legacy SigSimC-only option for representing object matclass
105 
106 #ifdef _POLYGONS_H_
107  char *geometryfile; // Geometry file (e.g. OpenFlight)
108  POLY_ARRAY *geometry; // Loaded geometry from geometry file (if any)
109 #endif
110 #ifdef _CTDR_CPDR_H_
111  SPIRITS_TABLE *spirits_table; // SPIRITS surface temp
112  PLUME_FLOWFIELD *spf_table; // SPF plume flowfield
113  PLUME_RADIANCE_MAP *spurc_table; // SPURC plume radiance projection LUT
114  USCSET *uscset; // JRM Universal Scatter Center set
115  SMOKE_PROJECTION_MAP *combic_table; // holds smoke cloud projection for given FOV
116  POLY_ARRAY *muses_table; // Muses surface temp
117 #endif
118 #ifdef _GFE_NRT_
119  SPIRITS_PLUMEFIT *pfit; // Spirits plume fit data
120  MSIC_PS_DATASPEC *msic; // MSIC-format Point Source Spectral Radiance Datacube
121 #endif
122 #ifdef _SIGSIM_RADAR_H_
123  SCATTER_TABLE *scat_table; // scatter center table for all the sensor center frequencies to be played
124  SCATTER_VECTOR_TABLE *scat_vector_table;// scatter center table for all the sensor center frequencies to be played
125  RCS_TABLE *rcs_table; // holder for polarized RCS 2D LUT
126  double rcs_sigma; // Default RCS [1]
127  OLD_RCS_TABLE *old_rcs_table;
128  char rcs_file[SIGSIM_STRING_SIZE]; // Radar Cross section file
129  RF_JAMMER *rfjammer; // RF Jammer
130  RF_DECOY *rfdecoy; // RF Chaff/decoy
131 #endif
132 #ifdef _SIGSIM_SONAR_H_
133  TARGET *target; // Sonar Target Properties
134 #endif
135 #ifdef _RFSIG_H_
136  DATALINK_PARTICIPANT *datalink; // Datalink
137 #endif
138 #ifdef _PARTICLES_H_
139  PARTICLEINPUT *pinput; // Particle System Input
140  PARTICLESYSTEM *psystem; // Particle System Parameters (derived from pinput)
141 #endif
142 
143  } OBJECT;
144 
145 
146  // InitializeObject sets all object parameters to 0 or null. It does not free any existing memory.
147  // Inputs : object = pointer to OBJECT
148  // Returns: SIGSIM_FUNCTION_FAILURE if object is NULL,
149  // SIGSIM_SUCCESS upon successful completion.
150  SIGSIM_API int InitializeObject(OBJECT *object);
151 
152 
153  // AllocateObjects allocates (but does not fill) an array of OBJECTs of length nobjects.
154  // Inputs : nobjects = number of OBJECTs to be allocated.
155  // Outputs: Object = Pointer to array of OBJECTs to be allocated.
156  // ms_poly_array and rcs_table will be NULL by default.
157  // Returns: SIGSIM_MEMORY_ALLOCATION_ERROR if Object array already allocated or otherwise cannot be allocated.
158  // SIGSIM_SUCCESS on successful completion.
159  SIGSIM_API int AllocateObjects(int nobjects, OBJECT **Object); // Allocates general array of objects
160 
161 
162  // Free_Objects frees the memory allocated to an array of OBJECTs.
163  // Inputs : object = pointer to array of OBJECTs
164  // nobjects = size of object array
165  // Returns: SIGSIM_FUNCTION_FAILURE if object array is already NULL,
166  // SIGSIM_SUCCESS upon successful completion.
167  SIGSIM_API int Free_Objects(OBJECT **object, int nobjects);
168 
169  // Free_Object_Arrays frees the memory allocated to the arrays within an array of OBJECTs,
170  // but not that associated with the object array itself.
171  // Inputs : object = array of OBJECTs
172  // nobjects = size of object array
173  // Returns: SIGSIM_FUNCTION_FAILURE if object array is already NULL,
174  // SIGSIM_SUCCESS upon successful completion.
175  SIGSIM_API int Free_Object_Arrays(OBJECT *object, int nobjects);
176 
177  // ---------- State Updates -------------
178 
179  // UpdateObjectKinematics() is intended to update the position and FOV for this object by indexing into the proper track record based on the simtime.
180  // INPUTS : sens points to object with one or more track records filled in.
181  // E defines the Earth ellipsoid for geodetic to geocentric conversion
182  // simtime is the simulation time in seconds.
183  // OUTPUTS: object->{geoc_loc, geod_loc} corresponding to simtime (from track records)
184  // object->{ned_linear_velocity, ned_angular_velocity, ned_linear_acceleration, ned_angular_acceleration} corresponding to simtime (from track records).
185  SIGSIM_API int UpdateObjectKinematics(OBJECT *object, ellipsoid E, double simtime);
186 
187  // ObjectThermalSpinUp() forms nodal mesh for object matl systems and plays a time-step update to initialize them.
188  SIGSIM_API int ObjectThermalSpinUp(OBJECT *object, double spinupPeriod, METIN *metin);
189 
190  /* ----------------------- PROJECTIONS AND INTERSECTIONS ----------------------- */
191 
192  SIGSIM_API int GetBackgroundHits(ellipsoid E, OBJECT obj, VECTOR Rtarget, double delta, int ngeoC, VECTOR *TNED, GEOCENTRIC_LOCATION *geoC);
195  SIGSIM_API int TargetTransverseDimensions(VECTOR right, VECTOR down, int nvecs, VECTOR *corner, double *horizontal, double *vertical);
196 
197  /* -------------------- RADIANCE CALCULATION -------------------------- */
198  SIGSIM_API double computerad(OBJECT *objectin, SENSOR *sens, VECTOR direction);
199 
200  // SetMinMaxObjectRadiances() can be used to set the OBJECT structure minimum and maximum radiances and passbands for use with the UseRadImage switch,
201  // but note that all passbands will be the SAME, all maximum radiances will be the SAME, and all minimum radiances will be the SAME, for all faces of the object cube.
202  // For specification of different parameters for each face, the user is expected to either use GetScenario, or use a call to rademit_approx as follows:
203  // Given a passband ax and bx [in microns], and a face temperature T [in degK], the associated radiance is given by:
204  // double itd;
205  // rad = rademit_approx(ax, bx, T, 10, &itd);
206  // This should be done for Tmin and Tmax, for each face.
207  //
208  // Inputs: object = pointer to OBJECT whose passband and radiances are to be calculated.
209  // bmpax = wavelength [um] of start of passband associated with the image.
210  // bmpbx = wavelength [um] of end of passband associated with the image.
211  // bmptlo = temperature [degC] of start of image dynamic range.
212  // bmpthi = temperature [degC] of end of image dynamic range.
213  // Outputs: Passband starting wavelengths object->{axf,axb,axl,axr,axu,axd}.
214  // Passband ending wavelengths object->{bxf,bxb,bxl,bxr,bxu,bxd}.
215  // Minimum radiances object->{rminf, rminb, rminl, rminr, rminu, rmind}.
216  // Maximum radiances object->{rmaxf, rmaxb, rmaxl, rmaxr, rmaxu, rmaxd}.
217  // Returns: SIGSIM_SUCCESS upon successful completion.
218  SIGSIM_API int SetMinMaxObjectRadiances(OBJECT *object, double bmpax, double bmpbx, double bmptlo, double bmpthi);
219 
220  // FillObjectRadianceFromImages() fills OBJECT radiance images.
221  // If object->view->xxx.imageFile(s) exist, they will be read and converted
222  // to radiances stored in object->view->xxx.Rave. Here 'xxx' and 'x' denote a particular face {u,d,r,l,f,b}.
223  // Inputs : sigsim_data_dir = string containing the name of the main data directory.
224  // object = pointer to OBJECT whose radiance tables are to be filled.
225  // Uses: object->{front,back,left,right,up,down}_rad_file.
226  // object->{rmaxf,rmaxb,rmaxl,rmaxr,rmaxu,rmaxd}
227  // object->{rminf,rminb,rminl,rminr,rminu,rmind}
228  // Outputs: object->{radf,radb,radl,radr,radu,radd}
229  // Returns: SIGSIM_FILE_NOT_FOUND*(-1) if sigsim_data_dir/object/bmp/object->{front,back,left,right,up,down}_rad_file is not found or can't be read.
230  // SIGSIM_SUCCESS upon successful completion.
231  SIGSIM_API int FillObjectRadianceFromImages(char *sigsim_data_dir, OBJECT *object);
232 
233  SIGSIM_API double ObjectRadianceFromImage(OBJECT *object, SENSOR *sens, VECTOR NED);
234 
235 
236 #ifdef _SIGSIM_RADAR_H_
237  /* ------------- RADAR --------------------- */
238 
239  // ReturnScatterAspect() gets the most relevant XPatch scatter center table for that target az/el aspect and frequency.
240  // Returns FALSE if no appropriate data exists.
241  // Not required if CalcRFReflectedPower is to be called, but useful if one is to pass this info to 3rd party codes.
242  // "el" [deg] measured from FR plane toward D,
243  // "az" [deg] measured on FR plane counter-clockwise about D from F
244  // "freq" [Hz]
245  //SIGSIM_API jrmbool ReturnScatterAspect(OBJECT *object, double az, double el, double freq, SCATTER_ASPECT *sa);
246  SIGSIM_API jrmbool ReturnScatterVectorAspect(OBJECT *object, double az, double el, double freq, SCATTER_VECTOR_ASPECT *aspect);
247  SIGSIM_API jrmbool ReturnScatterAspect(OBJECT *object, double az, double el, double freq, RCS_ASPECT *aspect);
248 
249  // ReturnRCSAspect() makes sure that the relavent RCS data is available for this az/el aspect and frequency
250  // Returns FALSE if no appropriate data exists.
251  // Not required if CalcRFReflectedPower is to be called, but useful if one is to pass this info to 3rd party codes.
252  // "el" [deg] measured from FR plane toward D,
253  // "az" [deg] measured on FR plane counter-clockwise about D from F
254  // "freq" [Hz]
255  SIGSIM_API jrmbool ReturnRCSAspect(OBJECT *object, double az, double el, double freq, RCS_ASPECT *ra);
256 
257  // FillObjectRCS() fills OBJECT RCS table from the specified file.
258  // If object->rcs_file exists, then it will be read into object->old_rcs_table
259  // Inputs : sigsim_data_dir = string containing the name of the main data directory (this routine will look for the object/rcs subdirectory).
260  // object = pointer to OBJECT whose RCS table is to be filled.
261  // Uses: object->rcs_file
262  // Outputs: object->old_rcs_table
263  // Returns: SIGSIM_FILE_NOT_FOUND if sigsim_data_dir/object/rcs/object->rcs_file is not found or can't be read.
264  // SIGSIM_SUCCESS upon successful completion.
265  SIGSIM_API int FillObjectRCS(char *sigsim_data_dir, OBJECT *object);
266 
267  /*
268  // CalcObjectRCS() performs coherent ray-sums over all scatter centers to calculate rcs and stores in object->rcs.
269  // Internal function.
270  SIGSIM_API int CalcObjectRCS(OBJECT *object);
271  */
272  SIGSIM_API jrmComplex getSigSimTargetRCS(double az_deg, double el_deg, double freq_Hz, RCS_TABLE *rcs_table, enum Polarization pol);
273  SIGSIM_API void getSigSimTargetRCSAllPol (double az_deg, double el_deg, double freq_Hz, RCS_TABLE *rcs_table, jrmComplex *HH, jrmComplex *HV, jrmComplex *VH, jrmComplex *VV);
274 
275 #endif // _SIGSIM_RADAR_H_
276 
277 
278 #ifdef _PARTICLES_H_
279  /* ------------------------ PARTICLE SYSTEM ROUTINES ------------------------------- */
280  SIGSIM_API int UpdateObjectParticleEffects(char *sigsim_atm_dir, OBJECT *object, METIN *metin);
281 
282  SIGSIM_API int PrintParticleSystem(OBJECT *object, SPECTRAL_DOMAIN *spectrum);
283 #endif // _PARTICLES_H_
284 
285 
286 #ifdef _POLYGONS_H_
287  /* ------------------------ OBJECT GEOMETRY ROUTINES ------------------------------- */
288 
289  typedef struct
290  {
291  long polyID; // ID of polygon hit
292  VECTOR norm_g; // Normal in global space
293  jrmbool inout; // TRUE = ray enters face, FALSE = ray exits face
294  VECTOR v1,v2,v3;// Vertices in global space
295  VECTOR hit_g; // Position of hitpoint in global space
296  VECTOR hit_b; // Position of hitpoint in body space
297  VECTOR hit_v; // Distances from vertices {v1, v2, v3}
298  double dist; // Distance along global +x from global origin.
299  } OBJHIT; // Object hitpoint
300 
301  /* -------------------------- OBJECT CREATION --------------------------- */
302 
303  // AllocateObjectArray allocates (but does not fill) an array of OBJECTs of length num_objects, and also allocates the ms_poly_array for each.
304  // Inputs : num_objects = number of OBJECTs to be allocated.
305  // polys_per_object = array of integers, each specifying the number of polygons in the corresponding OBJECT's ms_poly_array.
306  // Outputs: object = Pointer to array of OBJECTs to be allocated.
307  // rcs_table will be NULL by default.
308  // Returns: SIGSIM_MEMORY_ALLOCATION_ERROR if Object array or ms_poly_array already allocated or otherwise cannot be allocated.
309  // SIGSIM_SUCCESS on successful completion.
310  SIGSIM_API int AllocateObjectArray(int num_objects, int *polys_per_object, OBJECT **object);
311 
312  // AddToObject() modifies composite OBJECT to add new OBJECTs according to placement/orientation in corresponding TRACK array.
313  // Inputs : composite = pointer to pre-allocated OBJECT to be added to.
314  // nobjects = number of OBJECTs in object array to be added. Should also equal number of TRACKs in track array.
315  // object = array of OBJECTs to be added to composite OBJECT.
316  // track = array of TRACKs on a one-to-one correspondence with the object array. Each TRACK gives the position and orientation of the corresponding OBJECT to be added, as measured in the composite OBJECT's body FRD system.
317  // Returns: The number of polygons in the final composite OBJECT's ms_poly_array, after all OBJECTs have been added. int i;
318  SIGSIM_API long AddToObject(OBJECT *composite, int nobjects, OBJECT *object, TRACK *track);
319 
320  SIGSIM_API int CreateCone(int nmb_faces, double length, double angle, VERTEX base_center, VECTOR dir, OBJECT* cone);
321  // "nmb_faces" specifies the number of MS_POLYGONs to use in construction of the cone.
322  // "length" is in meters
323  // "angle" is in radians and is half of the angle at the cone apex
324  // "base_center" is in meters, and refers to the location of the center of the cone base relative to the object local origin in object-local FRD.
325  // "dir" is a vector specifying the direction from base center to the apex vertex in object-local FRD.
326  SIGSIM_API int CreateCyl(int nmb_faces, double length, double radius, VERTEX center, VECTOR dir, OBJECT* cyl);
327  // "nmb_faces" specifies the number of MS_POLYGONs to use in construction of the cylinder.
328  // "length" is in meters
329  // "radius" is in meters
330  // "center" is in meters, and refers to the location of the center of the cylinder relative to the object local origin in object-local FRD.
331  // "dir" is a vector specifying the direction of the cylinder axis in object-local FRD, and has bi-directional ambiguity.
332  SIGSIM_API int BoxTestObject(OBJECT *object, double length, double width, double height, double patch);
333 
334  /* ----------------- COORDINATE TRANSFORMATIONS ----------------------------- */
335  SIGSIM_API int GetTargetSensorNEDProjPolygons(OBJECT *obj, SENSOR *sens, ellipsoid E, POLY_ARRAY *p);
336  // Translates object's polygons to sensor NED system.
337  // "obj" contains the polygons to be translated.
338  // "proj" is the output array of translated NED polygons
339  // "nmb_tr" is the number of polygons in the output "proj" array.
340 
341  /* ----------------------- PROJECTIONS AND INTERSECTIONS ----------------------- */
342  SIGSIM_API int GetObjectBoundingBox(OBJECT *obj, VECTOR FRDright, VECTOR FRDdown, double *up, double *down, double *left, double *right);
343  SIGSIM_API int PolyNirt(OBJECT *object, TRACK track, OBJHIT **hit);
344  // PolyNirt inputs an object placed at a certain track.position within a global space at arbitrary track.orientation.
345  // A ray is then fired along the x-axis of the global space, and intersects the object at certain points.
346  // PolyNirt allocates and returns an array of nhit "OBJHIT" structures containing the intersection data.
347  // NOTE : Assumes track.position is in same units as poly vertices !!!
348  SIGSIM_API int Free_OBJHITs(OBJHIT *hits);
349  SIGSIM_API int GetTargetNEDBoundingBox(OBJECT *obj, VECTOR Rtarget, int *nvecs, VECTOR *corner);
350  SIGSIM_API void ObjectDimensions(OBJECT *objectin);
351  // CalcObjectLOSFrameExtents() finds the downrange and maximum crossrange extents of the object relative to a local NED vector.
352  SIGSIM_API int CalcObjectLOSFrameExtents(OBJECT object, VECTOR to_eye_NED, double *crossrange, double *downrange);
353 
354  /* ---------------------- STATE UPDATES -------------------- */
355 
356  // UpdateObjectMSPOLYARRAYTemperatures() merely updates the ms_poly_array temperatures (degK) with the mp_table.Tsurf temperatures corresponding to the instantiated material system.
357  SIGSIM_API int UpdateObjectMSPOLYARRAYTemperatures(OBJECT *object);
358 
359 #endif // _POLYGONS_H_
360 
361 #ifdef __cplusplus
362 }
363 #endif
364 
365 #endif //OBJECTS_H_
366 
367 


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