WSF
BrawlerUtil.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI//REL TO USA ONLY
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef BRAWLERUTIL_HPP
13#define BRAWLERUTIL_HPP
14
15#include "UtEntity.hpp"
16class UtInput;
17#include "brawler_export.h"
18
19#include "UtFortMat3.hpp"
20#include "UtMatrix.hpp"
21#include "UtVec3.hpp"
22
25namespace BRAWLER
26{
29// BRAWLER Constants
30double const grav = 32.17405;
31double const pi = 3.141592654;
32double const rad = pi / 180.0;
33double const hafpi = 1.570796327; // pi/2.0;
34double const twopi = 6.283185308; // pi*2.0;
35double const root2 = 1.414213562;
36double const ftnmi = 0.000164578834;
37double const eps = 1.e-35;
38double const re = 20890377.0;
39double const xlarge = 1.e38;
40double const degrees2meters = 111194.92664456; // 111194.92664455873734580833886041
41double const degrees2feet = 364812.76313; // 364812.76313253408783362183046679
42double const cFtSec2PerG = 32.1740; // TODO - use "grav" instead?
43
46// BRAWLER enumerations /// ////////////////////////////////////////////
48{
49 nowepn = 0, // none
50 kndsrm = 1, // short range missile
51 kndmrm = 2, // medium range missile
52 kndlrm = 3, // long range missile
53 kndmis = 3, // missile
54 kndgun = 4, // guns
55 knddew = 5, // directed energy weapon
56 kndwpn = 5 // weapon
57};
58enum ManeuverValueComponentType // used by TunnelVisionMultiplier() to replace "tnl_mult", copied from valhst.fi
59{
60 i_voffef = 1, // offensive
61 i_vlospd = 2, // low speed recovery
62 i_vform = 3, // station keeping (formation)
63 i_compr = 4, // route-point
64 i_valdfx = 5, // defensive
65 i_gaval = 6, // ground avoidance
66 i_vvec = 7, // vector following
67 i_villum = 8, // illumination (missile guiding)
68 i_vmusup = 9, // mutual support
69 i_valevd = 10, // missile evasion
70 i_vmaim = 11, // missile aiming
71 i_vdisng = 12, // disengage
72 i_sepval = 13, // separation
73 i_vescrt = 14, // escort bomber
74 i_vsamz = 15, // SAM avoidance
75 i_vavbdd = 16, // bad aspect avoidance
76 i_hddval = 17, // hard-deck
77 i_terrval = 18, // terrain
78 i_vdew = 19, // directed energy weapon
79 i_vtpt = 20 // third part targeting
80};
89{
90 mxskr = 4,
91 irskr = 1,
92 saskr = 2,
93 acskr = 3,
95};
97{
98 i_ovroff = 1, // OVERLY OFFENSIVE
99 i_nmusup = 2, // ATTENTION TO MUTUAL SUPPORT
100 i_nospd = 3 // ATTENTION TO AIRSPEED MAINTENANCE
101};
109{
110 ROUTE = 1,
112 CAP = 3
113};
114
117// BRAWLER utility functions ////////////////////////////////////////////
118
122BRAWLER_EXPORT double amin1(const double a, const double b);
123BRAWLER_EXPORT double amax1(const double a, const double b);
124BRAWLER_EXPORT double amax1(const double a, const double b, const double c);
126
130int sign(const int a, const int b);
131double sign(const double a, const double b);
133
135bool btest(const int var, const int pos);
136bool lbit(const int word, const int n);
137
140double arccos(const double a);
141double arcsin(const double a);
142
145double avnorm(const UtVec3d& x);
146
147/*not needed yet*/
148// lmatch(a,b,c) (std::find(std::begin(a), std::end(a), c) != std::end(a))
149// iand(a,b) (a&b)
150
163double border(const double z, const double z0);
164
169double cauchy(const double z, const double z0);
170
176double reward(const double z, const double z0);
178
184double dist(const UtVec3d& a, const UtVec3d& b);
185
191double energy(const UtVec3d& pos, const UtVec3d& vel);
192
199double egy(double z, double s);
200
212UtFortMat3d makecs(const UtVec3d& xVec, const UtVec3d& zVec);
213
227UtFortMat3d makcsi(const UtVec3d& xVec, const UtVec3d& zVec);
228
231UtFortMat3d makex(const UtVec3d& cxin);
232
234UtFortMat3d makeh(const UtVec3d& cxin);
235// makecs_inner(const UtVec3d& bx, const UtVec3d& by);
236
237double headeg(UtVec3d v);
238
249BRAWLER_EXPORT double ramp(const double xlo, const double xval, const double xhi);
250
257void vsplit(const UtVec3d& v, const UtVec3d& x, UtVec3d& vl, UtVec3d& vt);
258
265double xlimit(const double xreq, const double xmax, const double xmin);
266
267
268UtFortMat3d bodyax(const UtFortMat3d& rwe, // returns rbe, leave in util???
269 double alpha);
270
271UtFortMat3d NEDToECSRotation(UtEntity& ref);
272
273UtFortMat3d mrotx(UtFortMat3d a, double chi);
275double AtmosphereDensityRatio(double altitude);
277double SpeedOfSound(double altitude);
278
280double LOSangleSigma(const UtFortMat3d& M, const UtMatrixd& R6, double R);
281
285BRAWLER_EXPORT void nabort(const std::string& str);
286
293BRAWLER_EXPORT double param1(int i, double xx, double* aray);
294
304BRAWLER_EXPORT double tbl1(double x, double* z, double* xval, int nxval);
305
317double tbl1b(double x, double* z, int nx, double xmin, double xmax); // TODO
318
335BRAWLER_EXPORT double tbl2(double x, double y, double* z, double* xval, int nxval, double* yval, int nyval);
336
349double tbl2e(double x, double y, double* z, double* xval, int nxval, double* yval, int nyval);
350
368BRAWLER_EXPORT void invtb2(double* tbl, double z, int nr, int ir, double pr, bool revdir, int nc, int& ic, double& pc);
369
381BRAWLER_EXPORT void srch(double* x, int nx, double xint, int& ilow, double& p);
382
390bool maxcnt(int& count, bool zprnt, int mcount, const std::string& subnam);
391
392double dsxdot(double xdes, double x, double xdot, double xdotmx, double tau);
393
394UtVec3d vorth(const UtVec3d& a, const UtVec3d& b);
395
396UtVec3d rotz(double phi, const UtVec3d& vin);
397
398// replicates aimpt()
399BRAWLER_EXPORT bool AimPoint(const UtVec3d& xa, double sa, const UtVec3d& xt, const UtVec3d& vt, double st, UtVec3d& aimp);
400
401
402BRAWLER_EXPORT void intcpt(const UtVec3d& xa,
403 double sa,
404 const UtVec3d& xt,
405 const UtVec3d& vt,
406 double closmn,
407 double angint,
408 double hdes,
409 UtVec3d& desdir,
410 double& sdes);
411
412void intcpt_inner(const UtVec3d& x_atkr,
413 double sa,
414 const UtVec3d& x_tgt,
415 const UtVec3d& vt,
416 double closmn,
417 double angint,
418 double hdes,
419 double vs,
420 const UtVec3d& xlos,
421 double range,
422 UtVec3d& desdir,
423 double& sdes);
424
425BRAWLER_EXPORT bool TryReadCommand(UtInput& aInput, std::string& aCommand);
426BRAWLER_EXPORT void ReadValue(UtInput& aInput, int& aValue);
427BRAWLER_EXPORT void ReadValue(UtInput& aInput, double& aValue);
428} // namespace BRAWLER
429
430#endif
#define tbl(r, c)
#define xlo
Definition WsfNORAD_OrbitalPropagator.cpp:242
UtVec3d pos
Definition WsfScriptTrackClass.cpp:1881
UtVec3d vel
Definition WsfScriptTrackClass.cpp:1881
Definition BrawlerUtil.cpp:28
int sign(const int a, const int b)
Definition BrawlerUtil.cpp:45
MissionType
Definition BrawlerUtil.hpp:109
@ ROUTE
Definition BrawlerUtil.hpp:110
@ CAP
Definition BrawlerUtil.hpp:112
@ ESCORT
Definition BrawlerUtil.hpp:111
double const rad
Definition BrawlerUtil.hpp:32
double border(const double z, const double z0)
Definition BrawlerUtil.cpp:80
bool btest(const int var, const int pos)
Returns true if the bit at pos in var is set.
Definition BrawlerUtil.cpp:55
void ReadValue(UtInput &aInput, int &aValue)
Definition BrawlerUtil.cpp:1439
double tbl2e(double x, double y, double *z, double *xval, int nxval, double *yval, int nyval)
Definition BrawlerUtil.cpp:654
double LOSangleSigma(UtFortMat3d M, UtMatrixd R6, double R)
Definition BrawlerUtil.cpp:462
void nabort(const std::string &str)
Definition BrawlerUtil.cpp:495
MissileModeState
Definition BrawlerUtil.hpp:82
@ ILLUMINATE
2 = shot imminent/in progress, aim and fire (i.e. weapon in flight)
Definition BrawlerUtil.hpp:86
@ AIMFIRE
1 = interested in shot, get in evenlope (i.e. have a WEAPON_TASK)
Definition BrawlerUtil.hpp:85
@ NOTASK
Definition BrawlerUtil.hpp:83
@ INTERCEPT
0 = not interested in shot (default)
Definition BrawlerUtil.hpp:84
double const degrees2meters
Definition BrawlerUtil.hpp:40
double dsxdot(double xdes, double x, double xdot, double xdotmx, double tau)
Definition BrawlerUtil.cpp:1085
double const eps
Definition BrawlerUtil.hpp:37
double amin1(const double a, const double b)
Definition BrawlerUtil.cpp:30
UtVec3d vorth(const UtVec3d &a, const UtVec3d &b)
Definition BrawlerUtil.cpp:1103
double tbl2(double x, double y, double *z, double *xval, int nxval, double *yval, int nyval)
Definition BrawlerUtil.cpp:563
double tbl1b(double x, double *z, int nx, double xmin, double xmax)
Definition BrawlerUtil.cpp:539
WeaponType
Definition BrawlerUtil.hpp:48
@ kndmrm
Definition BrawlerUtil.hpp:51
@ knddew
Definition BrawlerUtil.hpp:55
@ kndgun
Definition BrawlerUtil.hpp:54
@ kndlrm
Definition BrawlerUtil.hpp:52
@ kndwpn
Definition BrawlerUtil.hpp:56
@ kndsrm
Definition BrawlerUtil.hpp:50
@ nowepn
Definition BrawlerUtil.hpp:49
@ kndmis
Definition BrawlerUtil.hpp:53
double tbl1(double x, double *z, double *xval, int nxval)
Definition BrawlerUtil.cpp:506
UtVec3d rotz(double phi, const UtVec3d &vin)
Definition BrawlerUtil.cpp:1112
bool TryReadCommand(UtInput &aInput, std::string &aCommand)
Definition BrawlerUtil.cpp:1389
double headeg(UtVec3d v)
Definition BrawlerUtil.cpp:217
UtFortMat3d makex(const UtVec3d &cxin)
Definition BrawlerUtil.cpp:191
double energy(const UtVec3d &pos, const UtVec3d &vel)
Definition BrawlerUtil.cpp:113
double arccos(const double a)
Definition BrawlerUtil.cpp:65
void vsplit(const UtVec3d &v, const UtVec3d &x, UtVec3d &vl, UtVec3d &vt)
Definition BrawlerUtil.cpp:241
bool AimPoint(const UtVec3d &xa, double sa, const UtVec3d &xt, const UtVec3d &vt, double st, UtVec3d &aimp)
Definition BrawlerUtil.cpp:1150
void invtb2(double *tbl, double z, int nr, int ir, double pr, bool revdir, int nc, int &ic, double &pc)
Definition BrawlerUtil.cpp:741
double param1(int i, double xx, double *aray)
Definition BrawlerUtil.cpp:501
double SpeedOfSound(double altitude)
From atmos.f calculating VS.
Definition BrawlerUtil.cpp:374
double const pi
Definition BrawlerUtil.hpp:31
UtFortMat3d mrotx(UtFortMat3d a, double chi)
Definition BrawlerUtil.cpp:300
double const root2
Definition BrawlerUtil.hpp:35
JobType
Definition BrawlerUtil.hpp:103
@ FLIGHT_LEAD
Definition BrawlerUtil.hpp:104
@ ELEMENT_LEAD
Definition BrawlerUtil.hpp:105
@ WINGMAN
Definition BrawlerUtil.hpp:106
double egy(double z, double s)
Definition BrawlerUtil.cpp:118
UtFortMat3d bodyax(const UtFortMat3d &rwe, double alpha)
Definition BrawlerUtil.cpp:267
UtFortMat3d NEDToECSRotation(UtEntity &ref)
Definition BrawlerUtil.cpp:283
ManeuverValueComponentType
Definition BrawlerUtil.hpp:59
@ i_vdew
Definition BrawlerUtil.hpp:78
@ i_vlospd
Definition BrawlerUtil.hpp:61
@ i_gaval
Definition BrawlerUtil.hpp:65
@ i_vmaim
Definition BrawlerUtil.hpp:70
@ i_vsamz
Definition BrawlerUtil.hpp:74
@ i_sepval
Definition BrawlerUtil.hpp:72
@ i_vform
Definition BrawlerUtil.hpp:62
@ i_terrval
Definition BrawlerUtil.hpp:77
@ i_villum
Definition BrawlerUtil.hpp:67
@ i_valevd
Definition BrawlerUtil.hpp:69
@ i_hddval
Definition BrawlerUtil.hpp:76
@ i_vescrt
Definition BrawlerUtil.hpp:73
@ i_vdisng
Definition BrawlerUtil.hpp:71
@ i_compr
Definition BrawlerUtil.hpp:63
@ i_vtpt
Definition BrawlerUtil.hpp:79
@ i_vmusup
Definition BrawlerUtil.hpp:68
@ i_vvec
Definition BrawlerUtil.hpp:66
@ i_valdfx
Definition BrawlerUtil.hpp:64
@ i_vavbdd
Definition BrawlerUtil.hpp:75
@ i_voffef
Definition BrawlerUtil.hpp:60
double xlimit(const double xreq, const double xmax, const double xmin)
Definition BrawlerUtil.cpp:253
double amax1(const double a, const double b)
Definition BrawlerUtil.cpp:35
double cauchy(const double z, const double z0)
Definition BrawlerUtil.cpp:96
double avnorm(const UtVec3d &x)
Definition BrawlerUtil.cpp:75
double arcsin(const double a)
Definition BrawlerUtil.cpp:70
double reward(const double z, const double z0)
Definition BrawlerUtil.cpp:102
WeaponSeekerType
Definition BrawlerUtil.hpp:89
@ acskr
Definition BrawlerUtil.hpp:93
@ irskr
Definition BrawlerUtil.hpp:91
@ mxskr
Definition BrawlerUtil.hpp:90
@ armskr
Definition BrawlerUtil.hpp:94
@ saskr
Definition BrawlerUtil.hpp:92
double const degrees2feet
Definition BrawlerUtil.hpp:41
bool lbit(const int word, const int n)
Definition BrawlerUtil.cpp:60
double const twopi
Definition BrawlerUtil.hpp:34
double const grav
Definition BrawlerUtil.hpp:30
double const ftnmi
Definition BrawlerUtil.hpp:36
void srch(double *x, int nx, double xint, int &ilow, double &p)
Definition BrawlerUtil.cpp:963
double const cFtSec2PerG
Definition BrawlerUtil.hpp:42
UtFortMat3d makecs(const UtVec3d &xVec, const UtVec3d &zVec)
Definition BrawlerUtil.cpp:123
bool maxcnt(int &count, bool zprnt, int mcount, const std::string &subnam)
Definition BrawlerUtil.cpp:1022
double const hafpi
Definition BrawlerUtil.hpp:33
UtFortMat3d makcsi(const UtVec3d &xVec, const UtVec3d &zVec)
Definition BrawlerUtil.cpp:157
void intcpt(const UtVec3d &xa, double sa, const UtVec3d &xt, const UtVec3d &vt, double closmn, double angint, double hdes, UtVec3d &desdir, double &sdes)
Definition BrawlerUtil.cpp:1257
double ramp(const double xlo, const double xval, const double xhi)
Definition BrawlerUtil.cpp:227
UtFortMat3d makeh(const UtVec3d &cxin)
Equiv to makex with cxin assumed zero.
Definition BrawlerUtil.cpp:198
double AtmosphereDensityRatio(double altitude)
From atmos.f calculating DR.
Definition BrawlerUtil.cpp:315
InherentBiasFaultTypes
Definition BrawlerUtil.hpp:97
@ i_nospd
Definition BrawlerUtil.hpp:100
@ i_nmusup
Definition BrawlerUtil.hpp:99
@ i_ovroff
Definition BrawlerUtil.hpp:98
double const re
Definition BrawlerUtil.hpp:38
double dist(const UtVec3d &a, const UtVec3d &b)
Definition BrawlerUtil.cpp:108
double const xlarge
Definition BrawlerUtil.hpp:39
void intcpt_inner(const UtVec3d &x_atkr, double sa, const UtVec3d &x_tgt, const UtVec3d &vt, double closmn, double angint, double hdes, double vs, const UtVec3d &xlos, double range, UtVec3d &desdir, double &sdes)
Definition BrawlerUtil.cpp:1306
Copyrights Multiple, All Rights Reserved