Visual Servoing Platform  version 3.6.1 under development (2024-12-12)
vpMath Class Reference

#include <visp3/core/vpMath.h>

Public Types

typedef vpHomogeneousMatrix(* LongLattToHomogeneous) (double lonDeg, double latDeg, double radius)
 

Static Public Member Functions

static double deg (double rad)
 
static vpColVector deg (const vpRotationVector &r)
 
static vpColVector deg (const vpColVector &r)
 
static double rad (double deg)
 
static vpColVector rad (const vpColVector &r)
 
static float getAngleBetweenMinPiAndPi (const float &theta)
 
static double getAngleBetweenMinPiAndPi (const double &theta)
 
static float modulo (const float &value, const float &modulo)
 
static double modulo (const double &value, const double &modulo)
 
static double sqr (double x)
 
static double fact (unsigned int x)
 
static long double comb (unsigned int n, unsigned int p)
 
template<typename T >
static T clamp (const T &v, const T &lower, const T &upper)
 
static int round (double x)
 
static int sign (double x)
 
static bool nul (double x, double threshold=0.001)
 
static bool equal (double x, double y, double threshold=0.001)
 
static bool greater (double x, double y, double threshold=0.001)
 
template<class Type >
static Type maximum (const Type &a, const Type &b)
 
template<class Type >
static Type minimum (const Type &a, const Type &b)
 
template<class Type >
static Type abs (const Type &x)
 
static double sinc (double x)
 
static double sinc (double sinx, double x)
 
static double mcosc (double cosx, double x)
 
static double msinc (double sinx, double x)
 
static double sigmoid (double x, double x0=0., double x1=1., double n=12.)
 
template<class Type >
static void swap (Type &a, Type &b)
 
static bool isNaN (double value)
 
static bool isNaN (float value)
 
static bool isInf (double value)
 
static bool isInf (float value)
 
static bool isFinite (double value)
 
static bool isFinite (float value)
 
static bool isNumber (const std::string &str)
 
static double lineFitting (const std::vector< vpImagePoint > &imPts, double &a, double &b, double &c)
 
template<typename Tp >
static Tp saturate (unsigned char v)
 
template<typename Tp >
static Tp saturate (char v)
 
template<typename Tp >
static Tp saturate (unsigned short v)
 
template<typename Tp >
static Tp saturate (short v)
 
template<typename Tp >
static Tp saturate (unsigned v)
 
template<typename Tp >
static Tp saturate (int v)
 
template<typename Tp >
static Tp saturate (float v)
 
template<typename Tp >
static Tp saturate (double v)
 
static double getMean (const std::vector< double > &v)
 
static double getMedian (const std::vector< double > &v)
 
static double getStdev (const std::vector< double > &v, bool useBesselCorrection=false)
 
static int modulo (int a, int n)
 
static unsigned int modulo (unsigned int a, unsigned int n)
 
static vpHomogeneousMatrix ned2ecef (double lonDeg, double latDeg, double radius)
 
static vpHomogeneousMatrix enu2ecef (double lonDeg, double latDeg, double radius)
 
static vpHomogeneousMatrix enu2ned (const vpHomogeneousMatrix &enu_M)
 
template<typename T >
static std::vector< double > linspace (T start_in, T end_in, unsigned int num_in)
 
static std::vector< std::pair< double, double > > computeRegularPointsOnSphere (unsigned int maxPoints)
 
static std::vector< vpHomogeneousMatrixgetLocalTangentPlaneTransformations (const std::vector< std::pair< double, double > > &lonlatVec, double radius, LongLattToHomogeneous func)
 
static vpHomogeneousMatrix lookAt (const vpColVector &from, const vpColVector &to, vpColVector tmp)
 
template<>
unsigned char saturate (char v)
 
template<>
unsigned char saturate (unsigned short v)
 
template<>
unsigned char saturate (int v)
 
template<>
unsigned char saturate (short v)
 
template<>
unsigned char saturate (unsigned int v)
 
template<>
unsigned char saturate (float v)
 
template<>
unsigned char saturate (double v)
 
template<>
char saturate (unsigned char v)
 
template<>
char saturate (unsigned short v)
 
template<>
char saturate (int v)
 
template<>
char saturate (short v)
 
template<>
char saturate (unsigned int v)
 
template<>
char saturate (float v)
 
template<>
char saturate (double v)
 
template<>
unsigned short saturate (char v)
 
template<>
unsigned short saturate (short v)
 
template<>
unsigned short saturate (int v)
 
template<>
unsigned short saturate (unsigned int v)
 
template<>
unsigned short saturate (float v)
 
template<>
unsigned short saturate (double v)
 
template<>
short saturate (unsigned short v)
 
template<>
short saturate (int v)
 
template<>
short saturate (unsigned int v)
 
template<>
short saturate (float v)
 
template<>
short saturate (double v)
 
template<>
int saturate (float v)
 
template<>
int saturate (double v)
 
template<>
unsigned int saturate (float v)
 
template<>
unsigned int saturate (double v)
 

Detailed Description

Provides simple mathematics computation tools that are not available in the C mathematics library (math.h)

Examples
pf-nonlinear-example.cpp, and tutorial-ibvs-4pts-json.cpp.

Definition at line 110 of file vpMath.h.

Member Typedef Documentation

◆ LongLattToHomogeneous

typedef vpHomogeneousMatrix(* vpMath::LongLattToHomogeneous) (double lonDeg, double latDeg, double radius)

Definition at line 361 of file vpMath.h.

Member Function Documentation

◆ abs()

template<class Type >
static Type vpMath::abs ( const Type &  x)
inlinestatic

Find the absolute value of a number (or other).

Parameters
x: The number.
Returns
The absolute value of x
Examples
catchImageWarp.cpp, and catchRotation.cpp.

Definition at line 269 of file vpMath.h.

Referenced by vpImageTools::imageDifferenceAbsolute(), vpServo::secondaryTaskJointLimitAvoidance(), and vpMeNurbs::seekExtremities().

◆ clamp()

template<typename T >
static T vpMath::clamp ( const T &  v,
const T &  lower,
const T &  upper 
)
inlinestatic

Clamp a value to boundaries.

Parameters
v: The value to clamp.
lower,upper: The boundaries to clamp v to.

Throw a vpException if the value of lower is greater than upper.

Examples
testMath.cpp.

Definition at line 218 of file vpMath.h.

References vpException::badValue.

◆ comb()

long double vpMath::comb ( unsigned int  n,
unsigned int  p 
)
inlinestatic

Computes the number of combination of p elements inside n elements.

Parameters
n: total number of elements.
p: requested number of elements.
Returns
Combination number $ n! / ((n-p)! p!) $

Definition at line 395 of file vpMath.h.

References fact().

Referenced by vpMomentAlpha::compute(), vpMomentCentered::compute(), vpFeatureMomentCentered::compute_Lmu_pq(), vpNurbs::computeCurveDersPoint(), and vpPixelMeterConversion::convertMoment().

◆ computeRegularPointsOnSphere()

std::vector< std::pair< double, double > > vpMath::computeRegularPointsOnSphere ( unsigned int  maxPoints)
static

Compute the vector of longitude / latitude (in degree) couples for maxPoints regularly spaced on a sphere, using the following paper:

Following image illustrates the camera poses regularly spaced on a sphere:

Parameters
maxPoints: The number of point coordinates to be sampled on a sphere.
Returns
The vector of longitude / latitude (in degree) pairs for the maxPoints on a sphare.
Examples
catchMathUtils.cpp.

Definition at line 602 of file vpMath.cpp.

References deg(), and round().

◆ deg() [1/3]

vpColVector vpMath::deg ( const vpColVector r)
static

Convert angles of a column vector from radians to degrees.

Parameters
r: Column vector with angles in radians.
Returns
Corresponding column vector with angles converted in degrees.

Definition at line 745 of file vpMath.cpp.

References deg(), and vpArray2D< Type >::size().

◆ deg() [2/3]

vpColVector vpMath::deg ( const vpRotationVector r)
static

Convert angles of a rotation vector into degrees.

Parameters
r: Rotation vector with angles in radians.
Returns
Corresponding column vector with angles converted in degrees.

Definition at line 725 of file vpMath.cpp.

References deg(), vpException::fatalError, and vpArray2D< Type >::size().

◆ deg() [3/3]

static double vpMath::deg ( double  rad)
inlinestatic

Convert an angle in radians into degrees.

Parameters
rad: Angle in radians.
Returns
Angle converted in degrees.
Examples
calibrate-hand-eye.cpp, catchRotation.cpp, mbot-apriltag-2D-half-vs.cpp, mbot-apriltag-ibvs.cpp, mbot-apriltag-pbvs.cpp, moveBiclops.cpp, movePioneer.cpp, perfMatrixMultiplication.cpp, pf-nonlinear-example.cpp, servoAfma6AprilTagPBVS.cpp, servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp, servoAfma6MegaposePBVS.cpp, servoFrankaPBVS.cpp, servoPioneerPanSegment3D.cpp, servoPioneerPoint2DDepth.cpp, servoPioneerPoint2DDepthWithoutVpServo.cpp, servoPololuPtuPoint2DJointVelocity.cpp, servoUniversalRobotsPBVS.cpp, sonarPioneerReader.cpp, testFrankaJointVelocityLimits.cpp, testGenericTracker.cpp, testGenericTrackerDepth.cpp, testMath.cpp, testMocapQualisys.cpp, testMocapVicon.cpp, testMomentAlpha.cpp, testPixhawkDronePositionAbsoluteControl.cpp, testPixhawkDronePositionRelativeControl.cpp, testPixhawkDroneTakeoff.cpp, testPololuPosition.cpp, testPololuVelocity.cpp, testPose.cpp, testRobotAfma6Pose.cpp, testRobotFlirPtu.cpp, testRobotViper850.cpp, testRobotViper850Pose.cpp, testViper650.cpp, testViper850.cpp, trackMeLine.cpp, tutorial-homography-from-points.cpp, tutorial-ibvs-4pts-wireframe-robot-afma6.cpp, tutorial-ibvs-4pts-wireframe-robot-viper.cpp, tutorial-mb-generic-tracker-full.cpp, tutorial-mb-generic-tracker-live.cpp, tutorial-pose-from-points-live.cpp, and tutorial-pose-from-points-realsense-T265.cpp.

Definition at line 119 of file vpMath.h.

Referenced by vpHandEyeCalibration::calibrate(), vpMbTracker::computeCurrentProjectionError(), vpMbGenericTracker::computeCurrentProjectionError(), vpMbGenericTracker::computeProjectionError(), vpMbEdgeTracker::computeProjectionError(), computeRegularPointsOnSphere(), deg(), vpAfma6::getInverseKinematics(), vpMbDepthDenseTracker::loadConfigFile(), vpMbDepthNormalTracker::loadConfigFile(), vpMbEdgeTracker::loadConfigFile(), vpPoseVector::print(), vpFeatureSegment::print(), vpMeEllipse::printParameters(), vpServoData::save(), vpRobotAfma4::savePosFile(), vpRobotAfma6::savePosFile(), vpRobotFranka::savePosFile(), vpRobotUniversalRobots::savePosFile(), vpRobotViper650::savePosFile(), vpRobotViper850::savePosFile(), vpRobotFlirPtu::setJointVelocity(), vpRobotKinova::setJointVelocity(), vpRobotViper650::setPosition(), vpRobotViper850::setPosition(), vpRobotFlirPtu::setPosition(), vpRobotKinova::setPosition(), vpRobotPioneer::setVelocity(), and vpRobotBiclops::vpRobotBiclopsSpeedControlLoop().

◆ enu2ecef()

vpHomogeneousMatrix vpMath::enu2ecef ( double  lonDeg,
double  latDeg,
double  radius 
)
static

Compute from a given longitude, latitude and a sphere radius the homogeneous transformation from the ENU frame to the ECEF frame:

\[ \begin{bmatrix} X_{\text{ecef}} \\ Y_{\text{ecef}} \\ Z_{\text{ecef}} \end{bmatrix} = \begin{bmatrix} -\sin \lambda & -\sin \varphi \cos \lambda & \cos \varphi \cos \lambda \\ \cos \lambda & -\sin \varphi \sin \lambda & \cos \varphi \sin \lambda \\ 0 & \cos \varphi & \sin \varphi \end{bmatrix} + \begin{bmatrix} \text{r} \cos \varphi \cos \lambda \\ \text{r} \cos \varphi \sin \lambda \\ \text{r} \sin \varphi \end{bmatrix} \]

See also
Parameters
lonDeg: The longitude in degree or angle $\lambda$ in previous equation.
latDeg: The latitude in degree or angle $\varphi$ in previous equation.
radius: The sphere radius $r$ in meter.
Returns
The homogeneous transformation from ENU to ECEF frame.
See also
ned2ecef(), getLocalTangentPlaneTransformations()
Examples
catchMathUtils.cpp.

Definition at line 562 of file vpMath.cpp.

References rad().

◆ enu2ned()

vpHomogeneousMatrix vpMath::enu2ned ( const vpHomogeneousMatrix enu_M)
static

Convert from ENU (East-North-Up) to NED (North-East-Down) frame.

Parameters
enu_M: HomogeneousMatrix expressed in ENU frame.
Returns
Converted homogeneous matrix in NED frame.
Examples
catchHomogeneousMatrix.cpp.

Definition at line 776 of file vpMath.cpp.

◆ equal()

bool vpMath::equal ( double  x,
double  y,
double  threshold = 0.001 
)
inlinestatic

◆ fact()

double vpMath::fact ( unsigned int  x)
inlinestatic

Computes and returns x!

Parameters
x: parameter of factorial function.

Definition at line 379 of file vpMath.h.

Referenced by comb().

◆ getAngleBetweenMinPiAndPi() [1/2]

static double vpMath::getAngleBetweenMinPiAndPi ( const double &  theta)
inlinestatic

Convert angle between $-\pi$ and $\pi$.

Parameters
[in]thetaThe input angle we want to ensure it is in the interval $[-\pi ; \pi]$.
Returns
The corresponding angle in the interval $[-\pi ; \pi]$.

Definition at line 157 of file vpMath.h.

◆ getAngleBetweenMinPiAndPi() [2/2]

static float vpMath::getAngleBetweenMinPiAndPi ( const float &  theta)
inlinestatic

Convert angle between $-\pi$ and $\pi$.

Parameters
[in]thetaThe input angle we want to ensure it is in the interval $[-\pi ; \pi]$.
Returns
The corresponding angle in the interval $[-\pi ; \pi]$.
Examples
testImageCircle.cpp.

Definition at line 139 of file vpMath.h.

◆ getLocalTangentPlaneTransformations()

std::vector< vpHomogeneousMatrix > vpMath::getLocalTangentPlaneTransformations ( const std::vector< std::pair< double, double > > &  lonlatVec,
double  radius,
LongLattToHomogeneous  toECEF 
)
static

Compute transformations from the local tangent plane (e.g. NED, ECU, ...) to the ECEF frame.

See also

Following image illustrates the camera poses sampled using longitude / latitude coordinates:

Parameters
lonlatVec: Vector of longitude/latitude coordinates in degree.
radius: Sphere radius in meter.
toECEF: Pointer to the function computing from a longitude / latitude coordinates in degree and a radius the corresponding transformation from the local frame (e.g. NED or ENU) to the ECEF frame.
Returns
The vector of ecef_M_local homogeneous transformations.
See also
enu2ecef(), ned2ecef()
Examples
catchMathUtils.cpp.

Definition at line 653 of file vpMath.cpp.

◆ getMean()

◆ getMedian()

◆ getStdev()

◆ greater()

bool vpMath::greater ( double  x,
double  y,
double  threshold = 0.001 
)
inlinestatic

Compares $ x $ to $ y -$ threshold.

Parameters
x: x value.
y: y value.
threshold: Tolerance threshold.
Returns
true if $ x > y -$ threshold.

Definition at line 468 of file vpMath.h.

◆ isFinite() [1/2]

bool vpMath::isFinite ( double  value)
static

Returns whether a double is a finite value (neither infinite nor NaN).

Parameters
value: Double number to check.
Returns
true if value is neither infinite nor NaN (as defined by IEEE754 standard) and false otherwise.
Examples
testMath.cpp.

Definition at line 177 of file vpMath.cpp.

References isInf(), and isNaN().

Referenced by vpImage< Type >::getMinMaxValue().

◆ isFinite() [2/2]

bool vpMath::isFinite ( float  value)
static

Returns whether a float is a finite value (neither infinite nor NaN).

Parameters
value: Float number to check.
Returns
true if value is neither infinite nor NaN (as defined by IEEE754 standard) and false otherwise.

Definition at line 196 of file vpMath.cpp.

References isInf(), and isNaN().

◆ isInf() [1/2]

bool vpMath::isInf ( double  value)
static

Returns whether a double is an infinity value (either positive infinity or negative infinity).

Parameters
value: Double number to check.
Returns
true if value is a plus or minus infinity (as defined by IEEE754 standard) and false otherwise.
Examples
testMath.cpp.

Definition at line 136 of file vpMath.cpp.

Referenced by isFinite().

◆ isInf() [2/2]

bool vpMath::isInf ( float  value)
static

Returns whether a float is an infinity value (either positive infinity or negative infinity).

Parameters
value: Float number to check.
Returns
true if value is a plus or minus infinity (as defined by IEEE754 standard) and false otherwise.

Definition at line 157 of file vpMath.cpp.

◆ isNaN() [1/2]

bool vpMath::isNaN ( double  value)
static

Check whether a double number is not a number (NaN) or not.

Parameters
value: Double number to check.
Returns
true if value is Not A Number (as defined by IEEE754 standard) and false otherwise.
Examples
testMath.cpp, and tutorial-apriltag-detector-live-rgbd-structure-core.cpp.

Definition at line 92 of file vpMath.cpp.

Referenced by vpKeyPoint::compute3DForPointsOnCylinders(), vpComedi::getPhyData(), isFinite(), and vpHomogeneousMatrix::isValid().

◆ isNaN() [2/2]

bool vpMath::isNaN ( float  value)
static

Check whether a float number is not a number (NaN) or not.

Parameters
value: Float number to check.
Returns
true if value is Not A Number (as defined by IEEE754 standard) and false otherwise.

Definition at line 113 of file vpMath.cpp.

◆ isNumber()

bool vpMath::isNumber ( const std::string &  str)
static

Returns whether a string is a number.

Parameters
[in]str: String to check.
Returns
true if string is number and false otherwise.
Examples
testMath.cpp, tutorial-dnn-object-detection-live.cpp, and tutorial-megapose-live-single-object-tracking.cpp.

Definition at line 214 of file vpMath.cpp.

◆ lineFitting()

double vpMath::lineFitting ( const std::vector< vpImagePoint > &  imPts,
double &  a,
double &  b,
double &  c 
)
static

Compute the line equation using least-squares fitting that minimizes the cost function:

\[ \mathbf{E} = \sum_{i=1}^{n}\left ( ax_i + by_i - c \right )^2 \]

Parameters
imPts: Image points (size >= 3).
a: a coefficient.
b: b coefficient.
c: c coefficient.
Returns
The mean distance error (point-to-line distance) between the points and the fitted line.
Examples
catchLineFitting.cpp.

Definition at line 390 of file vpMath.cpp.

References vpException::dimensionError, vpMatrix::eigenValues(), vpImagePoint::get_u(), vpImagePoint::get_v(), and vpArray2D< Type >::size().

◆ linspace()

template<typename T >
static std::vector<double> vpMath::linspace ( start_in,
end_in,
unsigned int  num_in 
)
inlinestatic

Similar to the NumPy linspace function: "Return evenly spaced numbers over a specified interval." Code from: https://stackoverflow.com/a/27030598

Parameters
start_in: The starting value of the sequence.
end_in: The end value of the sequence.
num_in: Number of samples to generate.
Returns
Returns num_in evenly spaced samples, calculated over the interval [start_in, end_in].
Examples
catchMathUtils.cpp.

Definition at line 333 of file vpMath.h.

◆ lookAt()

vpHomogeneousMatrix vpMath::lookAt ( const vpColVector from,
const vpColVector to,
vpColVector  tmp 
)
static

Compute the transformation such that the camera located at from position looks toward to position.

Right-handed coordinate system for OpenGL (figure from https://learnopengl.com/Getting-started/Coordinate-Systems):

See also:

Parameters
from: Current camera position as a 3-dim vector with 3D coordinates (X,Y,Z) in meter..
to: Where the camera must point toward as a 3-dim vector with 3D coordinates (X,Y,Z) in meter.
tmp: Arbitrary up-vector as a 3-dim vector with coordinates along (X,Y,Z) in meter.
Returns
The homogeneous transformation from the camera frame to the OpenGL frame.
Examples
catchMathUtils.cpp, and photometricMappingVisualServoing.cpp.

Definition at line 689 of file vpMath.cpp.

References vpColVector::crossProd(), vpColVector::normalize(), and vpArray2D< Type >::size().

◆ maximum()

◆ mcosc()

double vpMath::mcosc ( double  cosx,
double  x 
)
static

Compute $ (1-cos(x))/x^2 $

Parameters
cosx: Value of cos(x).
x: Value of x.
Returns
$ (1-cos(x))/x^2 $

Definition at line 233 of file vpMath.cpp.

Referenced by vpRotationMatrix::buildFrom(), vpExponentialMap::direct(), and vpExponentialMap::inverse().

◆ minimum()

template<class Type >
static Type vpMath::minimum ( const Type &  a,
const Type &  b 
)
inlinestatic

◆ modulo() [1/4]

static double vpMath::modulo ( const double &  value,
const double &  modulo 
)
inlinestatic

Gives the rest of value divided by modulo when the quotient can only be an integer.

Parameters
[in]valueThe value we want to know the rest in the "modulo" operation.
[in]moduloThe divider.
Returns
double The rest as in a modulo operation.

Definition at line 192 of file vpMath.h.

◆ modulo() [2/4]

static float vpMath::modulo ( const float &  value,
const float &  modulo 
)
inlinestatic

Gives the rest of value divided by modulo when the quotient can only be an integer.

Parameters
[in]valueThe value we want to know the rest in the "modulo" operation.
[in]moduloThe divider.
Returns
float The rest as in a modulo operation.
Examples
pf-nonlinear-complex-example.cpp, ukf-nonlinear-complex-example.cpp, and ukf-nonlinear-example.cpp.

Definition at line 177 of file vpMath.h.

Referenced by vpImageCircle::computeAngularCoverageInRoI(), VISP_NAMESPACE_NAME::vpDirection::counterClockwise(), vpStatisticalTestShewhart::detectDownwardMeanDrift(), vpStatisticalTestShewhart::detectUpwardMeanDrift(), and vpStatisticalTestShewhart::getSignals().

◆ modulo() [3/4]

int vpMath::modulo ( int  a,
int  n 
)
static

Compute the modified modulo:

  • modulo(11, 10) == 1 == 11 % 10
  • modulo(-1, 10) == 9
Parameters
a: The dividend.
n: The divisor.
Returns
The modified modulo of a mod n.

Definition at line 447 of file vpMath.cpp.

◆ modulo() [4/4]

unsigned int vpMath::modulo ( unsigned int  a,
unsigned int  n 
)
static

Compute the modified modulo:

  • modulo(11, 10) == 1 == 11 % 10
Parameters
a: The dividend.
n: The divisor.
Returns
The modified modulo of a mod n.

Definition at line 458 of file vpMath.cpp.

◆ msinc()

double vpMath::msinc ( double  sinx,
double  x 
)
static

Compute $ (1-sinc(x))/x^2 $ with $ sinc(x) = sin(x) / x $.

Parameters
sinx: value of sin(x).
x: Value of x.
Returns
$ (1-sinc(x))/x^2 $

Definition at line 251 of file vpMath.cpp.

Referenced by vpExponentialMap::direct(), and vpExponentialMap::inverse().

◆ ned2ecef()

vpHomogeneousMatrix vpMath::ned2ecef ( double  lonDeg,
double  latDeg,
double  radius 
)
static

Compute from a given longitude, latitude and a sphere radius the homogeneous transformation from the NED frame to the ECEF frame:

\[ \begin{bmatrix} X_{\text{ecef}} \\ Y_{\text{ecef}} \\ Z_{\text{ecef}} \end{bmatrix} = \begin{bmatrix} -\sin \varphi \cos \lambda & -\sin \lambda & -\cos \varphi \cos \lambda \\ -\sin \varphi \sin \lambda & \cos \lambda & -\cos \varphi \sin \lambda \\ \cos \varphi & 0 & -\sin \varphi \end{bmatrix} + \begin{bmatrix} \text{r} \cos \varphi \cos \lambda \\ \text{r} \cos \varphi \sin \lambda \\ \text{r} \sin \varphi \end{bmatrix} \]

See also:

Parameters
lonDeg: The longitude in degree or angle $\lambda$ in previous equation.
latDeg: The latitude in degree or angle $\varphi$ in previous equation.
radius: The sphere radius $r$ in meter.
Returns
The homogeneous transformation from NED to ECEF frame.
See also
enu2ecef(), getLocalTangentPlaneTransformations()
Examples
catchMathUtils.cpp.

Definition at line 498 of file vpMath.cpp.

References rad().

◆ nul()

bool vpMath::nul ( double  x,
double  threshold = 0.001 
)
inlinestatic

◆ rad() [1/2]

vpColVector vpMath::rad ( const vpColVector r)
static

Convert angles of a column vector from degrees to radians.

Parameters
r: Column vector with angles in degrees.
Returns
Corresponding column vector with angles converted in radians.

Definition at line 761 of file vpMath.cpp.

References rad(), and vpArray2D< Type >::size().

◆ rad() [2/2]

static double vpMath::rad ( double  deg)
inlinestatic

Convert an angle in degrees into radian.

Parameters
deg: Angle in degrees.
Returns
Angle converted in radians.
Examples
calibrate-hand-eye.cpp, catchGenericTrackerDeterminist.cpp, catchImageWarp.cpp, catchPoseRansac2.cpp, catchPoseVector.cpp, catchQuaternion.cpp, catchRotation.cpp, exponentialMap.cpp, homographyHLM2DObject.cpp, homographyHLM3DObject.cpp, homographyHartleyDLT2DObject.cpp, homographyRansac2DObject.cpp, manServo4PointsDisplay.cpp, manServoMomentsSimple.cpp, manSimu4Dots.cpp, manSimu4Points.cpp, mbtEdgeKltTracking.cpp, mbtGenericTracking.cpp, mbtGenericTracking2.cpp, mbtGenericTrackingDepth.cpp, mbtGenericTrackingDepthOnly.cpp, mbtKltTracking.cpp, moveAfma4.cpp, moveBiclops.cpp, movePtu46.cpp, perfGenericTracker.cpp, perfImageWarp.cpp, pf-nonlinear-complex-example.cpp, pf-nonlinear-example.cpp, photometricMappingVisualServoing.cpp, photometricVisualServoing.cpp, photometricVisualServoingWithoutVpServo.cpp, servoAfma62DhalfCamVelocity.cpp, servoAfma6AprilTagIBVS.cpp, servoAfma6AprilTagPBVS.cpp, servoAfma6Cylinder2DCamVelocity.cpp, servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp, servoAfma6FourPoints2DCamVelocityLs_cur.cpp, servoAfma6FourPoints2DCamVelocityLs_cur_integrator.cpp, servoAfma6FourPoints2DCamVelocityLs_des.cpp, servoAfma6Line2DCamVelocity.cpp, servoAfma6SquareLines2DCamVelocity.cpp, servoAfma6TwoLines2DCamVelocity.cpp, servoBebop2.cpp, servoKinovaJacoJoint.cpp, servoMomentImage.cpp, servoMomentPoints.cpp, servoMomentPolygon.cpp, servoSimu3D_cMcd_CamVelocity.cpp, servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp, servoSimu3D_cdMc_CamVelocity.cpp, servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp, servoSimu4Points.cpp, servoSimuAfma6FourPoints2DCamVelocity.cpp, servoSimuCircle2DCamVelocityDisplay.cpp, servoSimuCylinder.cpp, servoSimuCylinder2DCamVelocityDisplay.cpp, servoSimuCylinder2DCamVelocityDisplaySecondaryTask.cpp, servoSimuFourPoints2DCamVelocityDisplay.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, servoSimuLine2DCamVelocityDisplay.cpp, servoSimuPoint2DhalfCamVelocity1.cpp, servoSimuPoint2DhalfCamVelocity2.cpp, servoSimuPoint2DhalfCamVelocity3.cpp, servoSimuSphere.cpp, servoSimuSphere2DCamVelocityDisplaySecondaryTask.cpp, servoSimuSquareLine2DCamVelocityDisplay.cpp, servoSimuThetaUCamVelocity.cpp, servoSimuViper850FourPoints2DCamVelocity.cpp, servoUniversalRobotsIBVS.cpp, servoUniversalRobotsPBVS.cpp, servoViper850FourPoints2DArtVelocityLs_cur.cpp, servoViper850FourPoints2DCamVelocityLs_cur.cpp, servoViper850FourPointsKinect.cpp, simulateCircle2DCamVelocity.cpp, simulateFourPoints2DCartesianCamVelocity.cpp, simulateFourPoints2DPolarCamVelocity.cpp, sonarPioneerReader.cpp, testCameraParametersConversion.cpp, testDisplacement.cpp, testFeatureMoment.cpp, testFeatureSegment.cpp, testFindMatch.cpp, testFrankaJointVelocity-2.cpp, testFrankaJointVelocity-3.cpp, testFrankaJointVelocity.cpp, testFrankaJointVelocityLimits.cpp, testGenericTracker.cpp, testGenericTrackerDepth.cpp, testKalmanAcceleration.cpp, testKalmanVelocity.cpp, testKeyPoint-2.cpp, testKeyPoint-4.cpp, testMath.cpp, testMatrix.cpp, testPixhawkDronePositionAbsoluteControl.cpp, testPixhawkDronePositionRelativeControl.cpp, testPixhawkRoverVelocityControl.cpp, testPololuPosition.cpp, testPololuVelocity.cpp, testPose.cpp, testPoseFeatures.cpp, testRobotBebop2.cpp, testRobotFlirPtu.cpp, testRobotViper650-frames.cpp, testRobotViper850-frames.cpp, testUniversalRobotsJointPosition.cpp, testUniversalRobotsJointVelocity.cpp, testViper650.cpp, testViper850.cpp, testVirtuoseWithGlove.cpp, testXmlParserHomogeneousMatrix.cpp, testXmlParserRectOriented.cpp, tutorial-detection-object-mbt-deprecated.cpp, tutorial-detection-object-mbt.cpp, tutorial-detection-object-mbt2-deprecated.cpp, tutorial-detection-object-mbt2.cpp, tutorial-draw-frame.cpp, tutorial-homography-from-points.cpp, tutorial-ibvs-4pts-display.cpp, tutorial-ibvs-4pts-image-tracking.cpp, tutorial-ibvs-4pts-ogre-tracking.cpp, tutorial-ibvs-4pts-ogre.cpp, tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter.cpp, tutorial-ibvs-4pts-wireframe-camera.cpp, tutorial-ibvs-4pts-wireframe-robot-afma6.cpp, tutorial-ibvs-4pts-wireframe-robot-viper.cpp, tutorial-ibvs-4pts.cpp, tutorial-image-simulator.cpp, tutorial-mb-edge-tracker.cpp, tutorial-mb-generic-tracker-apriltag-rs2.cpp, tutorial-mb-generic-tracker-apriltag-webcam.cpp, tutorial-mb-generic-tracker-full.cpp, tutorial-mb-generic-tracker-rgbd.cpp, tutorial-mb-hybrid-tracker.cpp, tutorial-mb-klt-tracker.cpp, tutorial-mb-tracker-full.cpp, tutorial-panda3d-renderer.cpp, ukf-nonlinear-complex-example.cpp, ukf-nonlinear-example.cpp, and wireframeSimulator.cpp.

Definition at line 129 of file vpMath.h.

Referenced by vpMbTracker::addPolygon(), vpMbTracker::addProjectionErrorPolygon(), vpMbGenericTracker::computeProjectionError(), enu2ecef(), vpRobotViper650::get_eJe(), vpRobotViper850::get_eJe(), vpAfma6::getInverseKinematics(), vpViper::getInverseKinematicsWrist(), vpRobotKinova::getJointPosition(), vpRobotPioneer::getVelocity(), vpRobotUniversalRobots::init(), vpAfma6::init(), vpViper650::init(), vpViper850::init(), vpMbtPolygon::isVisible(), vpMbTracker::loadCAOModel(), vpMbDepthDenseTracker::loadConfigFile(), vpMbDepthNormalTracker::loadConfigFile(), vpMbEdgeTracker::loadConfigFile(), vpWireFrameSimulator::navigation(), ned2ecef(), SoftwareArguments::parseArgs(), rad(), vpRobotAfma4::readPosFile(), vpRobotAfma6::readPosFile(), vpRobotFranka::readPosFile(), vpRobotUniversalRobots::readPosFile(), vpMbDepthDenseTracker::resetTracker(), vpMbDepthNormalTracker::resetTracker(), vpMbEdgeTracker::resetTracker(), vpMbGenericTracker::resetTracker(), vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(), vpRobotPololuPtu::vpRobotPololuPtu(), vpViper::vpViper(), vpViper650::vpViper650(), vpViper850::vpViper850(), and vpWireFrameSimulator::vpWireFrameSimulator().

◆ round()

◆ saturate() [1/37]

template<typename Tp >
static Tp vpMath::saturate ( char  v)
inlinestatic

Definition at line 304 of file vpMath.h.

◆ saturate() [2/37]

template<>
unsigned char vpMath::saturate ( char  v)
inlinestatic

Definition at line 495 of file vpMath.h.

◆ saturate() [3/37]

template<>
unsigned short vpMath::saturate ( char  v)
inlinestatic

Definition at line 581 of file vpMath.h.

◆ saturate() [4/37]

template<typename Tp >
static Tp vpMath::saturate ( double  v)
inlinestatic

Definition at line 310 of file vpMath.h.

◆ saturate() [5/37]

template<>
unsigned char vpMath::saturate ( double  v)
inlinestatic

Definition at line 536 of file vpMath.h.

References round().

◆ saturate() [6/37]

template<>
char vpMath::saturate ( double  v)
inlinestatic

Definition at line 574 of file vpMath.h.

References round().

◆ saturate() [7/37]

template<>
unsigned short vpMath::saturate ( double  v)
inlinestatic

Definition at line 617 of file vpMath.h.

References round().

◆ saturate() [8/37]

template<>
short vpMath::saturate ( double  v)
inlinestatic

Definition at line 641 of file vpMath.h.

References round().

◆ saturate() [9/37]

template<>
int vpMath::saturate ( double  v)
inlinestatic

Definition at line 653 of file vpMath.h.

References round().

◆ saturate() [10/37]

template<>
unsigned int vpMath::saturate ( double  v)
inlinestatic

Definition at line 666 of file vpMath.h.

References round().

◆ saturate() [11/37]

template<typename Tp >
static Tp vpMath::saturate ( float  v)
inlinestatic

Definition at line 309 of file vpMath.h.

◆ saturate() [12/37]

template<>
unsigned char vpMath::saturate ( float  v)
inlinestatic

Definition at line 530 of file vpMath.h.

References round().

◆ saturate() [13/37]

template<>
char vpMath::saturate ( float  v)
inlinestatic

Definition at line 568 of file vpMath.h.

References round().

◆ saturate() [14/37]

template<>
unsigned short vpMath::saturate ( float  v)
inlinestatic

Definition at line 611 of file vpMath.h.

References round().

◆ saturate() [15/37]

template<>
short vpMath::saturate ( float  v)
inlinestatic

Definition at line 636 of file vpMath.h.

References round().

◆ saturate() [16/37]

template<>
int vpMath::saturate ( float  v)
inlinestatic

Definition at line 648 of file vpMath.h.

References round().

◆ saturate() [17/37]

template<>
unsigned int vpMath::saturate ( float  v)
inlinestatic

Definition at line 661 of file vpMath.h.

References round().

◆ saturate() [18/37]

template<typename Tp >
static Tp vpMath::saturate ( int  v)
inlinestatic

Definition at line 308 of file vpMath.h.

◆ saturate() [19/37]

template<>
unsigned char vpMath::saturate ( int  v)
inlinestatic

Definition at line 515 of file vpMath.h.

◆ saturate() [20/37]

template<>
char vpMath::saturate ( int  v)
inlinestatic

Definition at line 553 of file vpMath.h.

◆ saturate() [21/37]

template<>
unsigned short vpMath::saturate ( int  v)
inlinestatic

Definition at line 601 of file vpMath.h.

◆ saturate() [22/37]

template<>
short vpMath::saturate ( int  v)
inlinestatic

Definition at line 628 of file vpMath.h.

◆ saturate() [23/37]

template<typename Tp >
static Tp vpMath::saturate ( short  v)
inlinestatic

Definition at line 306 of file vpMath.h.

◆ saturate() [24/37]

template<>
unsigned char vpMath::saturate ( short  v)
inlinestatic

Definition at line 520 of file vpMath.h.

◆ saturate() [25/37]

template<>
char vpMath::saturate ( short  v)
inlinestatic

Definition at line 558 of file vpMath.h.

◆ saturate() [26/37]

template<>
unsigned short vpMath::saturate ( short  v)
inlinestatic

Definition at line 596 of file vpMath.h.

◆ saturate() [27/37]

template<typename Tp >
static Tp vpMath::saturate ( unsigned char  v)
inlinestatic

Definition at line 303 of file vpMath.h.

◆ saturate() [28/37]

template<>
char vpMath::saturate ( unsigned char  v)
inlinestatic

Definition at line 543 of file vpMath.h.

◆ saturate() [29/37]

template<>
unsigned char vpMath::saturate ( unsigned int  v)
inlinestatic

Definition at line 525 of file vpMath.h.

◆ saturate() [30/37]

template<>
char vpMath::saturate ( unsigned int  v)
inlinestatic

Definition at line 563 of file vpMath.h.

◆ saturate() [31/37]

template<>
unsigned short vpMath::saturate ( unsigned int  v)
inlinestatic

Definition at line 606 of file vpMath.h.

◆ saturate() [32/37]

template<>
short vpMath::saturate ( unsigned int  v)
inlinestatic

Definition at line 632 of file vpMath.h.

◆ saturate() [33/37]

template<typename Tp >
static Tp vpMath::saturate ( unsigned short  v)
inlinestatic

Definition at line 305 of file vpMath.h.

◆ saturate() [34/37]

template<>
unsigned char vpMath::saturate ( unsigned short  v)
inlinestatic

Definition at line 510 of file vpMath.h.

◆ saturate() [35/37]

template<>
char vpMath::saturate ( unsigned short  v)
inlinestatic

Definition at line 548 of file vpMath.h.

◆ saturate() [36/37]

template<>
short vpMath::saturate ( unsigned short  v)
inlinestatic

Definition at line 624 of file vpMath.h.

◆ saturate() [37/37]

template<typename Tp >
static Tp vpMath::saturate ( unsigned  v)
inlinestatic

Definition at line 307 of file vpMath.h.

◆ sigmoid()

double vpMath::sigmoid ( double  x,
double  x0 = 0.,
double  x1 = 1.,
double  n = 12. 
)
inlinestatic

Sigmoid function between [x0,x1] with $ s(x)=0 if x\le x0$ and $ s(x)=1 if x \ge x1 $

Parameters
x: Value of x.
x0: Lower bound (default 0).
x1: Upper bound (default 1).
n: Degree of the exponential (default 12).
Returns
Sigmoid value $1/(1+exp(-n*((x-x0)/(x1-x0)-0.5)))$

Definition at line 481 of file vpMath.h.

◆ sign()

int vpMath::sign ( double  x)
inlinestatic

Return the sign of x.

Parameters
x: Value to test.
Returns
-1 if x is negative, +1 if positive and 0 if zero.

Definition at line 429 of file vpMath.h.

Referenced by vpThetaUVector::buildFrom(), vpMbEdgeTracker::computeVVSFirstPhase(), and vpMeNurbs::seekExtremities().

◆ sinc() [1/2]

double vpMath::sinc ( double  sinx,
double  x 
)
static

Compute sinus cardinal $ \frac{sin(x)}{x}$.

Parameters
sinx: Value of sin(x).
x: Value of x.
Returns
Sinus cardinal.

Definition at line 285 of file vpMath.cpp.

◆ sinc() [2/2]

double vpMath::sinc ( double  x)
static

Compute sinus cardinal $ \frac{sin(x)}{x} $.

Parameters
x: Value of x.
Returns
Sinus cardinal.

Definition at line 268 of file vpMath.cpp.

Referenced by vpThetaUVector::buildFrom(), vpRotationMatrix::buildFrom(), vpExponentialMap::direct(), vpFeatureThetaU::interaction(), and vpExponentialMap::inverse().

◆ sqr()

static double vpMath::sqr ( double  x)
inlinestatic

Compute x square value.

Returns
Square value $ x^2 $.
Examples
catchColorConversion.cpp, servoPololuPtuPoint2DJointVelocity.cpp, servoSimuSphere.cpp, servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp, testRobust.cpp, and tutorial-klt-tracker-with-reinit.cpp.

Definition at line 203 of file vpMath.h.

Referenced by vpMbTracker::addPolygon(), vpMbTracker::addProjectionErrorPolygon(), vpMbtDistanceCircle::computeInteractionMatrixError(), vpCircle::computeIntersectionPoint(), vpPose::computeResidual(), vpPose::computeResidualDementhon(), vpCalibration::computeStdDeviation(), vpCalibration::computeStdDeviation_dist(), vpMbDepthDenseTracker::computeVVS(), vpMbDepthNormalTracker::computeVVS(), vpMbEdgeTracker::computeVVS(), vpMbGenericTracker::computeVVS(), vpMbEdgeTracker::computeVVSInit(), vpMeterPixelConversion::convertEllipse(), vpMeterPixelConversion::convertLine(), vpPixelMeterConversion::convertLine(), vpPose::coplanar(), vpFeatureBuilder::create(), vpDot2::defineDots(), vpDisplayGTK::displayArrow(), vpCalibration::displayGrid(), vpImagePoint::distance(), vpImageDraw::drawArrow(), vpImageDraw::drawDottedLine(), vpMbtFaceDepthNormal::estimateFeatures(), vpImageFilter::getGaussianDerivativeKernel(), vpImageFilter::getGaussianKernel(), vpViper::getInverseKinematicsWrist(), vpImageTools::initUndistortMap(), vpImageTools::integralImage(), vpFeatureEllipse::interaction(), vpFeatureThetaU::interaction(), vpRotationMatrix::isARotationMatrix(), vpScale::KernelDensityGradient(), vpScale::KernelDensityGradient_EPANECHNIKOV(), vpMeLine::leastSquare(), vpMeNurbs::localReSample(), vpScale::MeanShift(), vpImageTools::normalizedCorrelation(), vpPose::poseVirtualVSrobust(), vpColorDepthConversion::projectColorToDepth(), vpCircle::projection(), vpSphere::projection(), vpNurbs::removeCurveKnot(), vpMeLine::reSample(), vpMeNurbs::sample(), vpMeLine::sample(), vpMeLine::seekExtremities(), vpMeNurbs::seekExtremitiesCanny(), vpImagePoint::sqrDistance(), vpMeSite::sqrDistance(), vpMeNurbs::supressNearPoints(), vpMeSite::track(), and vpMeSite::trackMultipleHypotheses().

◆ swap()

template<class Type >
static void vpMath::swap ( Type &  a,
Type &  b 
)
inlinestatic

Exchange two numbers.

Parameters
aFirst number to exchange.
bSecond number to exchange

Definition at line 286 of file vpMath.h.