|
LRAUV
revA
|
Contains useful math-related utilities. More...
#include <AuvMath.h>
Public Member Functions | |
| template<> | |
| uint8_t | FlipEndian (uint8_t value) |
| Has no effect, but included for use by template functions that accept uint8_t. More... | |
| template<> | |
| int8_t | FlipEndian (int8_t value) |
| Has no effect, but included for use by template functions that accept int8_t. More... | |
| template<> | |
| uint16_t | FlipEndian (uint16_t value) |
| template<> | |
| int16_t | FlipEndian (int16_t value) |
| template<> | |
| uint32_t | FlipEndian (uint32_t value) |
| template<> | |
| int32_t | FlipEndian (int32_t value) |
| template<> | |
| uint64_t | FlipEndian (uint64_t value) |
| template<> | |
| int64_t | FlipEndian (int64_t value) |
| template<> | |
| float | FlipEndian (float value) |
| template<> | |
| double | FlipEndian (double value) |
Static Public Member Functions | |
| template<typename T > | |
| static T | Limit (const T &value, const T &limit1, const T &limit2) |
| Makes sure a variable falls within defined limits... More... | |
| template<typename T > | |
| static bool | InLimit (const T &value, const T &limit1, const T &limit2) |
| Tests if a variable falls within defined limits... More... | |
| template<typename T > | |
| static T | Min (const T &a, const T &b) |
| Returns the lesser of the two arguments If either input is nan, nan is returned Unit tests in AuvMath_Test.testMin. More... | |
| template<typename T > | |
| static T | Max (const T &a, const T &b) |
| Returns the greater of the two arguments If either input is nan, nan is returned Unit tests in AuvMath_Test.testMin. More... | |
| template<typename T > | |
| static T | Square (T number) |
| Square function (opposite of sqrt(T)) More... | |
| template<typename T > | |
| static void | Swap (T &a, T &b) |
| Swaps the two arguments. More... | |
| template<typename T > | |
| static T | FlipEndian (T value) |
| Does not test the endianness of the input value, Just flips it. More... | |
| template<typename T > | |
| static T | Round (const T &value, const T &divisor) |
| Makes sure a variable is divisible by specified divisor... More... | |
| template<typename T > | |
| static T | Sign (const T &x) |
| Returns signum function: If input is nan, nan is returned Unit tests in AuvMath_Test.testSign. More... | |
| template<typename T > | |
| static T | ModPi (const T &angle) |
| modulo Pi function: If input is nan, nan is returned Unit tests in AuvMath_Test.testModPi More... | |
| template<typename T > | |
| static T | NanZero (const T &value) |
| Casts nan values to zero – otherwise returns the value Unit tests in AuvMath_Test.testNanZero. More... | |
| template<typename T > | |
| static int | FindLtEqIndex (const T *values, const T &value, const unsigned int indexMin, const unsigned int indexMax) |
| Finds the index within an array where the value is <= the supplied value Searches from indexMin to indexMax within the array. More... | |
| template<typename T > | |
| static T | Interpolate1D (const T &x, const T &data0, const T &data1, const T &x0, const T &x1) |
| Examines a 2 element data field for the value, where x0 <= x <= x1 Unit tests in AuvMath_Test.testInterpolate1D. More... | |
| template<typename T > | |
| static T | Interpolate2D (const T &x, const T &y, T data[][2], const T &x0, const T &x1, const T &y0, const T &y1) |
| Examines a 2x2 data field for the value, where x0 <= x <= x1, y0 <= y <= y1, Unit tests in AuvMath_Test.testInterpolate2D. More... | |
| template<typename T > | |
| static T | Interpolate3D (const T &x, const T &y, const T &z, T data[][2][2], const T &x0, const T &x1, const T &y0, const T &y1, const T &z0, const T &z1) |
| Examines a 2x2x2 data field for the value, where x0 <= x <= x1, y0 <= y <= y1, z0 <= z <= z1 Unit tests in AuvMath_Test.testInterpolate3D. More... | |
| template<typename T > | |
| static T | Interpolate4D (const T &w, const T &x, const T &y, const T &z, T data[][2][2][2], const T &w0, const T &w1, const T &x0, const T &x1, const T &y0, const T &y1, const T &z0, const T &z1) |
| Examines a 2x2x2x2 data field for the value, where w0 <= w <= w1, x0 <= x <= x1, y0 <= y <= y1, z0 <= z <= z1 Unit tests in AuvMath_Test.testInterpolate4D. More... | |
| static double | BulkModulus (double salinity, double temperature, double pressure) |
| Seawater bulk modulus (S,T,P) More... | |
| static double | Density (double salinity, double temperature, double pressure) |
| Seawater density (S,T,P) More... | |
| static double | OceanDepth (const double &pressure, const double &latitude) |
| OceanDepth (pressure, latitude) More... | |
| static double | OceanPressure (const double &depth, const double &latitude) |
| OceanPressure (depth, latitude) More... | |
| template<typename T > | |
| static void | ShellSort (T array[], int arraySize) |
| static bool | AreaContains (float x, float y, int segments, float *x0, float *y0, float *x1, float *y1) |
| static bool | TriangleContains (float x, float y, float x0, float y0, float x1, float y1, float x2, float y2) |
| static void | UnitVectorToAzimuthAndElevation (Point3D &uhat, float &azimuth, float &elevation) |
| static void | AzimuthAndElevationToUnitVector (float &azimuth, float &elevation, Point3D &uhat) |
Static Public Attributes | |
| static const double | TWOPI = M_PI * 2.0 |
| static const double | DEG_TO_RAD = atan( 1 ) / 45 |
| static const double | RAD_TO_DEG = 45 / atan( 1 ) |
Contains useful math-related utilities.
Originally called Math.h, but could be confused with math.h
|
static |
|
static |
References Point3D::setX(), Point3D::setY(), and Point3D::setZ().
Referenced by DAT::getSimulatedMeasurements().
|
static |
Seawater bulk modulus (S,T,P)
UNESCO Tech Paper Mar Sci 44 (1983)
Use As: bulkmod_(S,T,P)
Input: salinity (psu) temperature (K) pressure (Pa)
Output: Bulk Modulus in Pa
Example: BulkModulus(35,283.15,4e7) -> 2.404604869e9 BulkModulus(35,298.15,1e8)-> 2.710894504e9 UNESCO 36 p19
Copyright (c) 1996 by Moss Landing Marine Laboratories Separated out from DENSITY_83 15 February 1992; W. BroenkowUnit tests in AuvMath_Test.testBulkModulus
Referenced by Density(), and AuvMath_Test::testBulkModulus().
|
static |
Seawater density (S,T,P)
International Equation of State of Seawater (1980) UNESCO Tech Paper Mar Sci 44 (1983)
Use As: density_(S,T,P)
Input: S = Salinity (psu) T = Temperature (K) P = Pressure (Pa) Output: density (kg/m3)
Example: Density(34.567,278.15,2e7) -> 1036.409 Density(35,298.15,1e8) -> 1062.53817 UNESCO 44 p19
Copyright (c) 1996 by Moss Landing Marine Laboratories William Broenkow Checks perfectly with UNESCO 44. This function requires BulkmodUnit tests in AuvMath_Test.testDensity
References BulkModulus().
Referenced by CTD_NeilBrown::getSimulatedData(), CTD_NeilBrown::preprocessData(), EnvSimulator::simulateSensors(), and AuvMath_Test::testDensity().
|
static |
Finds the index within an array where the value is <= the supplied value Searches from indexMin to indexMax within the array.
Assumes the array is in increasing order. Unit tests in AuvMath_Test.testFindLtEqIndex
Referenced by EnvSimulator::simulateSensors(), and AuvMath_Test::testFindLtEqIndex().
|
static |
Does not test the endianness of the input value, Just flips it.
Referenced by FlipEndian(), BlobValue::getElement(), and BlobValue::setElement().
| uint8_t AuvMath::FlipEndian | ( | uint8_t | value | ) |
Has no effect, but included for use by template functions that accept uint8_t.
| int8_t AuvMath::FlipEndian | ( | int8_t | value | ) |
Has no effect, but included for use by template functions that accept int8_t.
| uint16_t AuvMath::FlipEndian | ( | uint16_t | value | ) |
| int16_t AuvMath::FlipEndian | ( | int16_t | value | ) |
| uint32_t AuvMath::FlipEndian | ( | uint32_t | value | ) |
| int32_t AuvMath::FlipEndian | ( | int32_t | value | ) |
| uint64_t AuvMath::FlipEndian | ( | uint64_t | value | ) |
| int64_t AuvMath::FlipEndian | ( | int64_t | value | ) |
| float AuvMath::FlipEndian | ( | float | value | ) |
References FlipEndian().
| double AuvMath::FlipEndian | ( | double | value | ) |
References FlipEndian().
|
static |
Tests if a variable falls within defined limits...
Tests whether a variable falls within defined limits...
Either limit may be min or max. If any input is nan, false is returned Unit tests in AuvMath_Test.testLimit
Either limit may be min or max. If any input is nan, nan is returned
Referenced by PNI_TCM::runnable().
|
static |
Examines a 2 element data field for the value, where x0 <= x <= x1 Unit tests in AuvMath_Test.testInterpolate1D.
Referenced by TableLogWriter::interpolateDataEntry(), AuvMath_Test::testInterpolate1D(), HFRadarModelPoint::travelTime(), and EnvSimulator::twoLineEstimate().
|
static |
Examines a 2x2 data field for the value, where x0 <= x <= x1, y0 <= y <= y1, Unit tests in AuvMath_Test.testInterpolate2D.
Referenced by HFRCMSpaceInterpolator::interpolateRaveledTwoDimensionalGrid(), HFRadarModelPoint::makeFine(), and AuvMath_Test::testInterpolate2D().
|
static |
Examines a 2x2x2 data field for the value, where x0 <= x <= x1, y0 <= y <= y1, z0 <= z <= z1 Unit tests in AuvMath_Test.testInterpolate3D.
Referenced by EnvSimulator::interpolate(), HFRCMReconstructedInterpolator::interpolateRaveledThreeDimensionalGrid(), HFRadarModelCalc::lookup(), and AuvMath_Test::testInterpolate3D().
|
static |
Examines a 2x2x2x2 data field for the value, where w0 <= w <= w1, x0 <= x <= x1, y0 <= y <= y1, z0 <= z <= z1 Unit tests in AuvMath_Test.testInterpolate4D.
Referenced by AuvMath_Test::testInterpolate4D().
|
static |
Makes sure a variable falls within defined limits...
Either limit may be min or max. If any input is nan, nan is returned Unit tests in AuvMath_Test.testLimit
Either limit may be min or max. If any input is nan, nan is returned
Referenced by VerticalControl::controlDepth(), VerticalControl::controlDepthRate(), HorizontalControl::controlHeading(), VerticalControl::elevatorControl(), HorizontalControl::headingControl(), PeakDetectVsDepth::initialize(), EZServoServo::limit(), VerticalControl::massAndElevatorControl(), VerticalControl::massControl(), Trajectory::project(), LoopControl::run(), SBIT::run(), PitchServo::run(), DepthServo::run(), VerticalControl::setBuoyancy(), VerticalControl::setMassAndElevator(), VerticalControl::setPitch(), VerticalControl::setPitchRate(), and AuvMath_Test::testLimit().
|
inlinestatic |
Returns the greater of the two arguments If either input is nan, nan is returned Unit tests in AuvMath_Test.testMin.
References MAX.
Referenced by CommandLine::commandIbitMcp3553(), ValueClause::eval(), HDF5Dataset::HDF5Dataset(), PeakDetectHorizontal::initialize(), HFRadarModelPoint::makeFine(), Slate::RegisterCodedName(), Slate::RegisterDataAccess(), Slate::RegisterElementURI(), AuvMath_Test::testMax(), and HDF5Dataset::writeDataValue().
|
inlinestatic |
Returns the lesser of the two arguments If either input is nan, nan is returned Unit tests in AuvMath_Test.testMin.
References MIN.
Referenced by TempGradientCalculator::captureTempGradPeak(), CommandLine::commandIbitMcp3553(), VerticalControl::controlDepth(), ValueClause::eval(), Circle::initialize(), HFRadarModelPoint::makeFine(), Aanderaa_O2::runnable(), WetLabsBB2FL::runnable(), Aanderaa_O2::starting(), WetLabsBB2FL::starting(), DecimationLogWriter::Str2DecimationType(), LogWriter::Str2ServiceType(), AuvMath_Test::testMin(), and HDF5Dataset::writeDataValue().
|
static |
modulo Pi function: If input is nan, nan is returned Unit tests in AuvMath_Test.testModPi
References M_1_2PI, and M_2PI.
Referenced by Location::AtBearingEllipsoid(), Point::calcSatisfied(), ZigZag::calculate(), HorizontalControl::controlHeading(), Lane::doRun(), HorizontalControl::headingControl(), Point::initialize(), Circle::isSatisfied(), PNI_TCM::processData(), Trajectory::project(), YawRateCalculator::run(), PitchRateCalculator::run(), Circle::run(), Simulator::run(), WaterDepthEnvelope::runIfUnsatisfied(), OffshoreEnvelope::runIfUnsatisfied(), AHRS_3DMGX3::runnable(), AHRS_sp3003D::runnable(), and AuvMath_Test::testModPi().
|
static |
Casts nan values to zero – otherwise returns the value Unit tests in AuvMath_Test.testNanZero.
Referenced by HFRCMVirtualSurfaceDrifter::advect(), VerticalControl::controlDepth(), VerticalControl::controlDepthRate(), HorizontalControl::controlHeading(), DeadReckonUsingCompactModelForecast::deadReckon(), DeadReckoner::deadReckon(), VerticalControl::elevatorControl(), HorizontalControl::headingControl(), VerticalControl::massAndElevatorControl(), VerticalControl::massControl(), Onboard::run(), PitchServo::run(), DepthServo::run(), HorizontalControl::setHeadingRate(), VerticalControl::setPitchRate(), and AuvMath_Test::testNanZero().
|
static |
OceanDepth (pressure, latitude)
For pressure in pascals and latitude in radians, return depth in meters.
Use As: OceanDepth(pressure, latitude)
Input: pressure (Pa), latitude (radians) Output: Depth (m)
Example: Depth(5e7,0.628318531) -> 4906.08 Depth(1e8,1.570796327) -> 9674.23 UNESCO 44 p28
Note: For more accurate results an additional factor of the ratio of the actual geopotential anomaly/gravity must be added. This correction will be less than 2 m.
Ref: UNESCO Tech Paper Mar Sci 44 (1983) Copyright (c) 1996 by Moss Landing Marine Laboratories 17 Jan 1996; W. Broenkow Matlabized from UNESCO83.FORUnit tests in AuvMath_Test.testOceanDepth
Referenced by CTD_NeilBrown::preprocessData(), Depth_Keller::run(), and AuvMath_Test::testOceanDepth().
|
static |
OceanPressure (depth, latitude)
For depth in meters and latitude in radians, return pressure in pascals.
Use As: OceanPressure(depth, latitude)
Input: depth (m), latitude (radians) Output: pressure (Pa)
Example: OceanPressure(4906.08,0.628318531) -> 5e7 OceanPressure(9674.23,1.570796327) -> 1e8 UNESCO 44 p28
Ref: UNESCO Tech Paper Mar Sci 44 (1983)Unit tests in AuvMath_Test.testOceanPressure
Referenced by CTD_NeilBrown::getSimulatedData(), Depth_Keller::run(), ExternalSim::run(), EnvSimulator::simulateSensors(), and AuvMath_Test::testOceanPressure().
|
static |
Makes sure a variable is divisible by specified divisor...
If any input is nan, nan is returned Unit tests in AuvMath_Test.testRound
If any input is nan, nan is returned
Referenced by AuvMath_Test::testRound().
|
inlinestatic |
Referenced by AuvMath_Test::testShellSort().
|
static |
Returns signum function: If input is nan, nan is returned Unit tests in AuvMath_Test.testSign.
Referenced by Point::calcSatisfied(), Mtx::Comp0(), Mtx::Comp1(), Mtx::Comp2(), Float::compare(), Double::compare(), HorizontalControl::headingControl(), AsyncPiEstimator::run(), HorizontalControl::setHeading(), VerticalControl::setMassAndElevator(), and AuvMath_Test::testSign().
|
inlinestatic |
Square function (opposite of sqrt(T))
Referenced by Location::GetDistanceFast(), NavChartDb::getDistanceFromShore(), NavChartDb::getSeaFloorDepth(), and NavChartDb::updateClosest().
|
inlinestatic |
Swaps the two arguments.
Referenced by AuvMath_Test::testSwap(), and Matrix3x3::transpose().
|
static |
References AreaContains().
|
static |
Referenced by DAT::directionsToAngles().
|
static |
Referenced by ExternalSim::run().
|
static |
Referenced by DVL_micro::simNQ1().
|
static |