13 #include <matrix/LibMatrix.h>
14 #include <vl/topoView.h>
15 #include <matrix/vlTaitBryan.h>
16 #include <matrix/3dBoundingVolume.h>
18 #include "tdbutil/mathUtilities.h"
21 #include <boost/math/special_functions/fpclassify.hpp>
23 #define DtSIGN(x) (((x) > (0.0)) ? (1.0) : (-1.0))
25 #define DtALMOST(x, y, e) (((x)<=((y)+(e))) && ((x)>=((y)-(e))))
27 #define DtGRAVITY_CONSTANT (9.81)
28 #define DtPI_OVER_TWO (1.570796327)
29 #define DtTWO_PI (6.283185307)
30 #define DtMETERS_TO_FEET (3.2808)
31 #define DtMETERS_PER_SEC_TO_MPH (2.23)
32 #define DtLN2 (0.693147181)
34 #define SIN(x) DtSin(x)
35 #define COS(x) DtCos(x)
36 #define TAN(x) DtTan(x)
38 #define ASIN(x) DtAsin(x)
39 #define ACOS(x) DtAcos(x)
40 #define ATAN(x) DtAtan(x)
41 #define ATAN2(y, x) DtAtan2((y), (x))
43 #define DtFRand() ((double) rand() / RAND_MAX)
44 #define DtIRandom(from, to) DtIntRandom(from, to)
46 class Coordinate_System;
68 DtConstDcm orientation,
72 DtVectorRef newPosition,
73 DtVectorRef newVelocity,
74 DtDcm& newOrientation,
75 DtVectorRef newAngVelocity);
79 DtVectorRef newLinearAcceleration,
81 DtConstDcm vehicleInertia,
82 DtVectorRef newAngAcceleration);
85 DtVectorRef returnForce);
89 DtVectorRef resultTorqueAboutOrigin);
94 DtDcm& inertiaInNewFrame);
98 DtDcm& inertiaInNewFrame);
101 double errorIntegral,
103 double proportionalGain,
105 double derivativeGain,
106 double biasForce = 0.0,
107 double* control = 0);
116 double tolerance = 0.0);
140 const double coneAngle,
142 double* testAnglePtr = 0);
147 const double wedgeAngle,
158 return sqrt(vec[DtX]*vec[DtX] + vec[DtY]*vec[DtY] + vec[DtZ]*vec[DtZ]);
163 return vec[DtX]*vec[DtX] + vec[DtY]*vec[DtY] + vec[DtZ]*vec[DtZ];
188 void setPole(
double freq);
189 void output(DtTaitBryan* input,
191 DtTaitBryan* output);
195 double output(
double input,
215 DtExponent = nonlinearity+1.0;
223 double DtOutput(
double input)
225 return DtSIGN(input) * DtGain * pow(fabs(input), DtExponent);
271 bool yIsForward=
false);
280 bool upsideDown =
false);
285 const DtDcm& topoToLocal, DtDcm& orientation);
298 const DtDcm& topoToLocal, DtDcm& localOrientation);
313 double heading,
const DtVector& position, DtDcm& bodyToRef);
321 const Coordinate_System& coordSystem,
const DtVector& localPosition,
322 DtDcm& bodyToLocalDcm);
351 double cosR =
DtCos(r);
353 if (DtIsZero<double>(cosR))
361 return DtSin(r) / cosR;
406 double* isectParam1 = 0,
double *isectParam2 = 0,
407 bool* parallel = 0,
bool* collinear = 0);
424 const Coordinate_System& coordinateSystem);
430 const Coordinate_System& coordinateSystem);
432 const Coordinate_System& coordinateSystem);
439 const Coordinate_System& coordinateSystem);
441 const Coordinate_System& coordinateSystem);
454 const DtVector& targetPosition,
const Coordinate_System& coordinateSystem);
459 const DtVector& targetPosition,
const Coordinate_System& coordinateSystem);
464 const DtVector& targetPosition,
const Coordinate_System& coordinateSystem);
469 const Coordinate_System& coordinateSystem);
477 const Coordinate_System& coordinateSystem);
486 const Coordinate_System& coordinateSystem);
495 const Coordinate_System& coordinateSystem);
503 const Coordinate_System& coordinateSystem);
513 const Coordinate_System& coordinateSystem);
521 const Coordinate_System& coordinateSystem);
533 const Dt3dBoundingVolume* box,
const DtTaitBryan& boxToLocalOrientation,
543 const Coordinate_System& coordinateSystem);
549 const Coordinate_System& coordinateSystem);
557 const Coordinate_System& coordinateSystem);
563 const Coordinate_System& coordinateSystem);
569 const DtVector& localLinePt2,
const Coordinate_System& coordinateSystem);
577 const DtPoint& chordEnd,
578 const DtPoint& testPoint, DtPoint & closestPoint,
579 const Coordinate_System& coordSys);
594 const DtVector&
point,
const Coordinate_System& coordinateSystem,
608 return v1[0]*v2[0] + v1[1]*v2[1];
618 return v1[0]*v2[1] - v1[1]*v2[0];
640 return DtModPerLo(atan2(v[1], v[0]), -M_PI, M_PI);
658 const DtVector& localVector,
const Coordinate_System& coordinateSystem,
673 const DtTaitBryan& localOrientation,
674 const Coordinate_System& coordinateSystem,
675 DtTaitBryan& geocentricOrientation);
688 const DtVector& geocentricVector,
const Coordinate_System& coordinateSystem,
704 const DtTaitBryan& geocentricOrientation,
705 const Coordinate_System& coordinateSystem,
706 DtTaitBryan& localOrientation);
743 &geocPosition,
const DtTaitBryan& local, DtTaitBryan& geoc);
776 const DtTaitBryan& local);
796 &geocPosition,
const DtTaitBryan& geoc, DtTaitBryan& local);
837 int& minutesOut,
double& secondsOut);
844 if (boost::math::isnan(vector.x()) ||
845 boost::math::isnan(vector.y()) ||
846 boost::math::isnan(vector.z()))
859 if (boost::math::isnan(tb.phi()) ||
860 boost::math::isnan(tb.psi()) ||
861 boost::math::isnan(tb.theta()))
874 if (boost::math::isnan(dcm[0].x()) ||
875 boost::math::isnan(dcm[0].y()) ||
876 boost::math::isnan(dcm[0].z()) ||
877 boost::math::isnan(dcm[1].x()) ||
878 boost::math::isnan(dcm[1].y()) ||
879 boost::math::isnan(dcm[1].z()) ||
880 boost::math::isnan(dcm[2].x()) ||
881 boost::math::isnan(dcm[2].y()) ||
882 boost::math::isnan(dcm[2].z()))
895 #include <boost/algorithm/string.hpp>
896 template<
typename SequenceSequenceT,
typename RangeT,
typename PredicateT >
898 SequenceSequenceT& Result,
901 boost::algorithm::token_compress_mode_type eCompress=boost::algorithm::token_compress_off )
905 ::boost::algorithm::iter_split(
908 ::boost::algorithm::token_finder( Pred, eCompress ) );