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

#include <visp3/core/vpMath.h>

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 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, vpHomogeneousMatrix(*toECEF)(double lonDeg, double latDeg, double radius))
 
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
tutorial-ibvs-4pts-json.cpp.

Definition at line 108 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
testImageWarp.cpp.

Definition at line 267 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 216 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 389 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
testMathUtils.cpp.

Definition at line 572 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 708 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 690 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, mbot-apriltag-2D-half-vs.cpp, mbot-apriltag-ibvs.cpp, mbot-apriltag-pbvs.cpp, moveBiclops.cpp, movePioneer.cpp, servoAfma6AprilTagPBVS.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 117 of file vpMath.h.

Referenced by vpPose::calculArbreDementhon(), vpHandEyeCalibration::calibrate(), vpMbTracker::computeCurrentProjectionError(), vpMbGenericTracker::computeCurrentProjectionError(), vpMbGenericTracker::computeProjectionError(), vpMbEdgeTracker::computeProjectionError(), computeRegularPointsOnSphere(), deg(), vpAfma6::getInverseKinematics(), vpMeEllipse::leastSquareRobust(), vpMbDepthDenseTracker::loadConfigFile(), vpMbDepthNormalTracker::loadConfigFile(), vpMbEdgeKltTracker::loadConfigFile(), vpMbEdgeTracker::loadConfigFile(), vpMbKltTracker::loadConfigFile(), vpMeEllipse::plugHoles(), vpPose::poseDementhonNonPlan(), vpPose::poseDementhonPlan(), vpPoseVector::print(), vpFeatureSegment::print(), vpMeEllipse::printParameters(), vpServoData::save(), vpRobotAfma4::savePosFile(), vpRobotAfma6::savePosFile(), vpRobotFranka::savePosFile(), vpRobotUniversalRobots::savePosFile(), vpRobotViper650::savePosFile(), vpRobotViper850::savePosFile(), vpSimulatorAfma6::savePosFile(), vpSimulatorViper850::savePosFile(), vpRobotFlirPtu::setJointVelocity(), vpRobotKinova::setJointVelocity(), vpRobotViper650::setPosition(), vpRobotViper850::setPosition(), vpRobotFlirPtu::setPosition(), vpRobotKinova::setPosition(), vpRobotPioneer::setVelocity(), vpMeEllipse::track(), vpSimulatorAfma6::updateArticularPosition(), vpSimulatorViper850::updateArticularPosition(), 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
testMathUtils.cpp.

Definition at line 536 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.

Definition at line 737 of file vpMath.cpp.

◆ equal()

◆ fact()

double vpMath::fact ( unsigned int  x)
inlinestatic

Computes and returns x!

Parameters
x: parameter of factorial function.

Definition at line 374 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 155 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]$.

Definition at line 137 of file vpMath.h.

◆ getLocalTangentPlaneTransformations()

std::vector< vpHomogeneousMatrix > vpMath::getLocalTangentPlaneTransformations ( const std::vector< std::pair< double, double > > &  lonlatVec,
double  radius,
vpHomogeneousMatrix(*)(double lonDeg, double latDeg, double radius)  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
testMathUtils.cpp.

Definition at line 623 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 458 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 178 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 197 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 137 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 158 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 93 of file vpMath.cpp.

Referenced by vpKeyPoint::compute3DForPointsOnCylinders(), vpMbtDistanceKltCylinder::computeInteractionMatrixAndResidu(), vpComedi::getPhyData(), vpMbtDistanceKltCylinder::init(), 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 114 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 215 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
testLineFitting.cpp.

Definition at line 382 of file vpMath.cpp.

References vpException::dimensionError, vpMatrix::eigenValues(), vpImagePoint::get_u(), and vpImagePoint::get_v().

◆ 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
testMathUtils.cpp.

Definition at line 330 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
testMathUtils.cpp.

Definition at line 658 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-cosx)/x^2 $

Definition at line 233 of file vpMath.cpp.

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

◆ minimum()

◆ modulo() [1/3]

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 190 of file vpMath.h.

◆ modulo() [2/3]

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.

Definition at line 175 of file vpMath.h.

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

◆ modulo() [3/3]

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 435 of file vpMath.cpp.

◆ msinc()

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

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

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

Definition at line 249 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
testMathUtils.cpp.

Definition at line 475 of file vpMath.cpp.

References rad().

◆ nul()

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

Compares $ | x | $ to threshold.

Parameters
x: Value to test.
threshold: Tolerance threshold
Returns
true if $ | x | <$ threshold.

Definition at line 440 of file vpMath.h.

Referenced by vpPose::computeRansacIterations(), equal(), vpQuaternionVector::inverse(), vpHomogeneousMatrix::isAnHomogeneousMatrix(), vpQuaternionVector::normalize(), vpQuaternionVector::operator/(), and vpImageTools::warpImage().

◆ 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 723 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, 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, photometricVisualServoing.cpp, photometricVisualServoingWithoutVpServo.cpp, servoAfma62DhalfCamVelocity.cpp, servoAfma6AprilTagIBVS.cpp, servoAfma6AprilTagPBVS.cpp, servoAfma6Cylinder2DCamVelocity.cpp, servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp, servoAfma6FourPoints2DCamVelocityLs_cur.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, testDisplacement.cpp, testFeatureSegment.cpp, testFindMatch.cpp, testFrankaJointVelocity-2.cpp, testFrankaJointVelocity-3.cpp, testFrankaJointVelocity.cpp, testFrankaJointVelocityLimits.cpp, testGenericTracker.cpp, testGenericTrackerDepth.cpp, testImageWarp.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, testPoseVector.cpp, testQuaternion2.cpp, testRobotBebop2.cpp, testRobotFlirPtu.cpp, testRobotViper650-frames.cpp, testRobotViper850-frames.cpp, testRotation2.cpp, testUniversalRobotsJointPosition.cpp, testUniversalRobotsJointVelocity.cpp, testViper650.cpp, testViper850.cpp, testVirtuoseWithGlove.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, and wireframeSimulator.cpp.

Definition at line 127 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(), vpSimulatorViper850::init(), vpAfma6::init(), vpSimulatorAfma6::init(), vpViper650::init(), vpViper850::init(), vpSimulatorAfma6::initDisplay(), vpSimulatorViper850::initDisplay(), vpMbtPolygon::isVisible(), vpMbTracker::loadCAOModel(), vpMbDepthDenseTracker::loadConfigFile(), vpMbDepthNormalTracker::loadConfigFile(), vpMbEdgeKltTracker::loadConfigFile(), vpMbEdgeTracker::loadConfigFile(), vpMbKltTracker::loadConfigFile(), vpWireFrameSimulator::navigation(), ned2ecef(), rad(), vpRobotAfma4::readPosFile(), vpRobotAfma6::readPosFile(), vpRobotFranka::readPosFile(), vpRobotUniversalRobots::readPosFile(), vpSimulatorAfma6::readPosFile(), vpMbDepthDenseTracker::resetTracker(), vpMbDepthNormalTracker::resetTracker(), vpMbEdgeTracker::resetTracker(), vpMbGenericTracker::resetTracker(), vpMbKltTracker::resetTracker(), vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(), vpRobotPololuPtu::vpRobotPololuPtu(), vpSickLDMRS::vpSickLDMRS(), 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 302 of file vpMath.h.

◆ saturate() [2/37]

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

Definition at line 483 of file vpMath.h.

◆ saturate() [3/37]

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

Definition at line 567 of file vpMath.h.

◆ saturate() [4/37]

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

Definition at line 308 of file vpMath.h.

◆ saturate() [5/37]

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

Definition at line 522 of file vpMath.h.

References round().

◆ saturate() [6/37]

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

Definition at line 560 of file vpMath.h.

References round().

◆ saturate() [7/37]

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

Definition at line 601 of file vpMath.h.

References round().

◆ saturate() [8/37]

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

Definition at line 625 of file vpMath.h.

References round().

◆ saturate() [9/37]

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

Definition at line 637 of file vpMath.h.

References round().

◆ saturate() [10/37]

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

Definition at line 650 of file vpMath.h.

References round().

◆ saturate() [11/37]

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

Definition at line 307 of file vpMath.h.

◆ saturate() [12/37]

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

Definition at line 516 of file vpMath.h.

References round().

◆ saturate() [13/37]

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

Definition at line 554 of file vpMath.h.

References round().

◆ saturate() [14/37]

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

Definition at line 595 of file vpMath.h.

References round().

◆ saturate() [15/37]

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

Definition at line 620 of file vpMath.h.

References round().

◆ saturate() [16/37]

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

Definition at line 632 of file vpMath.h.

References round().

◆ saturate() [17/37]

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

Definition at line 645 of file vpMath.h.

References round().

◆ saturate() [18/37]

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

Definition at line 306 of file vpMath.h.

◆ saturate() [19/37]

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

Definition at line 501 of file vpMath.h.

◆ saturate() [20/37]

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

Definition at line 539 of file vpMath.h.

◆ saturate() [21/37]

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

Definition at line 585 of file vpMath.h.

◆ saturate() [22/37]

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

Definition at line 612 of file vpMath.h.

◆ saturate() [23/37]

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

Definition at line 304 of file vpMath.h.

◆ saturate() [24/37]

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

Definition at line 506 of file vpMath.h.

◆ saturate() [25/37]

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

Definition at line 544 of file vpMath.h.

◆ saturate() [26/37]

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

Definition at line 580 of file vpMath.h.

◆ saturate() [27/37]

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

Definition at line 301 of file vpMath.h.

◆ saturate() [28/37]

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

Definition at line 529 of file vpMath.h.

◆ saturate() [29/37]

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

Definition at line 511 of file vpMath.h.

◆ saturate() [30/37]

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

Definition at line 549 of file vpMath.h.

◆ saturate() [31/37]

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

Definition at line 590 of file vpMath.h.

◆ saturate() [32/37]

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

Definition at line 616 of file vpMath.h.

◆ saturate() [33/37]

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

Definition at line 303 of file vpMath.h.

◆ saturate() [34/37]

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

Definition at line 496 of file vpMath.h.

◆ saturate() [35/37]

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

Definition at line 534 of file vpMath.h.

◆ saturate() [36/37]

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

Definition at line 608 of file vpMath.h.

◆ saturate() [37/37]

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

Definition at line 305 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 471 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 422 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 279 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 264 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
servoPololuPtuPoint2DJointVelocity.cpp, servoSimuSphere.cpp, servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp, testColorConversion.cpp, testRobust.cpp, and tutorial-klt-tracker-with-reinit.cpp.

Definition at line 201 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(), vpMbEdgeKltTracker::computeVVS(), vpMbGenericTracker::computeVVS(), vpMbEdgeTracker::computeVVSInit(), vpMeterPixelConversion::convertEllipse(), vpMeterPixelConversion::convertLine(), vpPixelMeterConversion::convertLine(), vpPose::coplanar(), vpFeatureBuilder::create(), vpDot2::defineDots(), vpDisplayGTK::displayArrow(), vpDisplayOpenCV::displayArrow(), vpDisplayX::displayArrow(), vpDisplayOpenCV::displayDotLine(), 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 vpImageTools::undistort().

◆ 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 284 of file vpMath.h.