WSF
WsfUtil.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
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 WSFUTIL_HPP
13#define WSFUTIL_HPP
14
15#include "wsf_export.h"
16
17#include <vector>
18
19class UtEntity;
20class UtInput;
21#include "UtMatrix.hpp"
22#include "UtSphericalEarth.hpp"
23#include "UtVec3.hpp"
24class WsfPlatform;
25class WsfScenario;
26class WsfTrack;
27#include "WsfTrackId.hpp"
28
30namespace WsfUtil
31{
32template<class T1, class T2>
33double TimeToDestination(T1& aSource, T2& aDest, const double aVel[3]);
34
35template<class T1, class T2>
36double DistanceToDestination(T1& aSource, T2& aDest);
37
38int WSF_EXPORT CountBitsOn(unsigned int aBitMask);
39
43inline unsigned int GenerateBitMask(int aNumBits)
44{
45 assert((aNumBits >= 1) && (aNumBits <= 32));
46 if (aNumBits <= 0)
47 {
48 return 0;
49 }
50 else if (aNumBits >= 32)
51 {
52 return 0xFFFFFFFF;
53 }
54 return 0xFFFFFFFF >> (32 - aNumBits);
55}
56
57void WSF_EXPORT ClosestApproachPoint2D(const double aMoverLocWCS[3],
58 const double aMoverVelWCS[3],
59 const double aTargetLocWCS[3],
60 double aClosestLocWCS[3]);
61
62double WSF_EXPORT ClosestApproachPoint3D(const double aMoverLocWCS[3],
63 const double aMoverVelWCS[3],
64 const double aTargetLocWCS[3],
65 double aClosestLocWCS[3]);
66
67bool WSF_EXPORT PotentiallyWithinRange(double aSimTime, WsfPlatform* aObject1Ptr, WsfPlatform* aObject2Ptr, double aMaximumRange);
68
69
70bool WSF_EXPORT TriangulateLocation(const double aOriginWCS_1[3],
71 const double& aBearing1,
72 const double& aElevation1,
73 const double aOriginWCS_2[3],
74 const double& aBearing2,
75 const double& aElevation2,
76 double aLocationWCS[3]);
77
78
79void WSF_EXPORT ConvertRangeBearing(const double aFromLocationWCS[3], UtEntity* aToEntity, double& aRange, double& aBearing);
80
81void WSF_EXPORT ErrorNED(double aRange,
82 double aBearing,
83 double aElevation,
84 double aRangeError,
85 double aBearingError,
86 double aElevationError,
87 double aErrorNED[3]);
88
89void WSF_EXPORT ErrorNED(double aRange, double aBearing, double aRangeError, double aBearingError, double aErrorNED[3]);
90
91int WSF_EXPORT TrackIdToInt(const WsfTrackId& aTrackId);
92
93WsfTrackId WSF_EXPORT IntToTrackId(int aIntTrackId);
94
95void WSF_EXPORT CovarianceToEllipse_2x2(std::vector<double>& aMatrix,
96 double& aSemiMajorAxis,
97 double& aSemiMinorAxis,
98 double& aBearingRad);
99
100double WSF_EXPORT BallisticPropagate(const UtVec3d& aLocationWCS,
101 const UtVec3d& aVelocityWCS,
102 double aStopAltitude,
103 UtVec3d& aPropagatedLocationWCS,
104 UtVec3d& aPropagatedVelocityWCS);
105
106void WSF_EXPORT MakeTrack(double aSimTime, WsfTrack& aTrack, WsfPlatform& aTarget, WsfPlatform& aSource);
107
108
110static const unsigned short cLLA_ERROR_VALID = 0x01;
111static const unsigned short cSPEED_ERROR_VALID = 0x02;
112static const unsigned short cHEADING_ERROR_VALID = 0x04;
113
115 unsigned short& aValidity,
116 double& aStDevLat,
117 double& aStDevLon,
118 double& aStDevAlt,
119 double& aStDevSpeed,
120 double& aStDevHeading);
121
122void WSF_EXPORT PrintLLA(const std::string& aLabel, double aLocationWCS[3]);
123void WSF_EXPORT PrintLLA(const std::string& aLabel, double aLat, double aLon, double aAlt);
124void WSF_EXPORT PrintLength(const std::string& aLabel, double aLength);
125
137template<class T1, class T2>
138double TimeToDestination(T1& aSource, T2& aDest, const double aVel[3])
139{
140 return DistanceToDestination(aSource, aDest) / UtVec3d::Magnitude(aVel);
141}
142
151template<class T1, class T2>
152double DistanceToDestination(T1& aSource, T2& aDest)
153{
154 double sourceLat;
155 double sourceLon;
156 double sourceAlt;
157 double destLat;
158 double destLon;
159 double destAlt;
160 aSource.GetLocationLLA(sourceLat, sourceLon, sourceAlt);
161 aDest.GetLocationLLA(destLat, destLon, destAlt);
162 double heading;
163 double distance;
164 UtSphericalEarth::GreatCircleHeadingAndDistance(sourceLat, sourceLon, destLat, destLon, heading, distance);
165 return distance;
166}
167
175template<class T1, class T2>
176double SlantRange(T1& aSource, T2& aDest)
177{
178 double sourceLocWCS[3];
179 double destLocWCS[3];
180 aSource.GetLocationWCS(sourceLocWCS);
181 aDest.GetLocationWCS(destLocWCS);
182 double targetVec[3];
183 UtVec3d::Subtract(targetVec, destLocWCS, sourceLocWCS);
184 return UtVec3d::Magnitude(targetVec);
185}
186
187} // end namespace WsfUtil
188
189#endif
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfTrackId.hpp:33
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
A set of utilities that perform generic calculations among WSF objects.
Definition WsfAttributeContainer.hpp:54
static const unsigned short cSPEED_ERROR_VALID
Definition WsfUtil.hpp:111
bool WSF_EXPORT TriangulateLocation(const double aOriginWCS_1[3], const double &aBearing1, const double &aElevation1, const double aOriginWCS_2[3], const double &aBearing2, const double &aElevation2, double aLocationWCS[3])
Definition WsfUtil.cpp:277
WsfTrackId WSF_EXPORT IntToTrackId(int aIntTrackId)
Definition WsfUtil.cpp:261
double DistanceToDestination(T1 &aSource, T2 &aDest)
Calculate the great circle distance from a source to a destination.
Definition WsfUtil.hpp:152
double SlantRange(T1 &aSource, T2 &aDest)
Calculate the slant range distance from a source to a destination (second parameter is const).
Definition WsfUtil.hpp:176
void WSF_EXPORT PrintLLA(const std::string &aLabel, double aLocationWCS[3])
Calls PrintLLA() for the LLA representation of aLocationWCS.
Definition WsfUtil.cpp:625
void WSF_EXPORT ClosestApproachPoint2D(const double aMoverLocWCS[3], const double aMoverVelWCS[3], const double aTargetLocWCS[3], double aClosestLocWCS[3])
Definition WsfUtil.cpp:62
static const unsigned short cLLA_ERROR_VALID
Validity Masks associated with the "aValidity" parameter in the following method:
Definition WsfUtil.hpp:110
double TimeToDestination(T1 &aSource, T2 &aDest, const double aVel[3])
Calculate the time it would take an object (e.g., a WsfPlatform) to traverse a great circle distance ...
Definition WsfUtil.hpp:138
void WSF_EXPORT CovarianceToEllipse_2x2(std::vector< double > &aMatrix, double &aSemiMajorAxis, double &aSemiMinorAxis, double &aBearingRad)
Definition WsfUtil.cpp:338
void WSF_EXPORT GetErrorEstimateLLA_SpeedHeading(const WsfTrack &aTrack, unsigned short &aValidity, double &aStDevLat, double &aStDevLon, double &aStDevAlt, double &aStDevSpeed, double &aStDevHeading)
Definition WsfUtil.cpp:564
void WSF_EXPORT PrintLength(const std::string &aLabel, double aLength)
Definition WsfUtil.cpp:646
void WSF_EXPORT ErrorNED(double aRange, double aBearing, double aElevation, double aRangeError, double aBearingError, double aElevationError, double aErrorNED[3])
Definition WsfUtil.cpp:411
double WSF_EXPORT BallisticPropagate(const UtVec3d &aLocationWCS, const UtVec3d &aVelocityWCS, double aStopAltitude, UtVec3d &aPropagatedLocationWCS, UtVec3d &aPropagatedVelocityWCS)
Definition WsfUtil.cpp:457
int WSF_EXPORT CountBitsOn(unsigned int aBitMask)
Definition WsfUtil.cpp:40
static const unsigned short cHEADING_ERROR_VALID
Definition WsfUtil.hpp:112
bool WSF_EXPORT PotentiallyWithinRange(double aSimTime, WsfPlatform *aObject1Ptr, WsfPlatform *aObject2Ptr, double aMaximumRange)
Definition WsfUtil.cpp:198
void WSF_EXPORT ConvertRangeBearing(const double aFromLocationWCS[3], UtEntity *aToEntity, double &aRange, double &aBearing)
Definition WsfUtil.cpp:398
void WSF_EXPORT MakeTrack(double aSimTime, WsfTrack &aTrack, WsfPlatform &aTarget, WsfPlatform &aSource)
Fill a track with truth information on aTarget with aSource as the track source.
Definition WsfUtil.cpp:505
int WSF_EXPORT TrackIdToInt(const WsfTrackId &aTrackId)
Definition WsfUtil.cpp:250
double WSF_EXPORT ClosestApproachPoint3D(const double aMoverLocWCS[3], const double aMoverVelWCS[3], const double aTargetLocWCS[3], double aClosestLocWCS[3])
Definition WsfUtil.cpp:143
unsigned int GenerateBitMask(int aNumBits)
Definition WsfUtil.hpp:43
Copyrights Multiple, All Rights Reserved