ViSP  2.8.0
vpMath Class Reference

#include <vpMath.h>

Static Public Member Functions

static double deg (double rad)
 
static double rad (double deg)
 
static double sqr (double x)
 
static double fact (unsigned int x)
 
static long double comb (unsigned int n, unsigned int p)
 
static int round (const double x)
 
static int sign (double x)
 
static bool nul (double x, double s=0.001)
 
static bool equal (double x, double y, double s=0.001)
 
static bool greater (double x, double y, double s=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)
 

Detailed Description

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

Author
Eric Marchand (Eric..nosp@m.Marc.nosp@m.hand@.nosp@m.iris.nosp@m.a.fr) Irisa / Inria Rennes

Definition at line 83 of file vpMath.h.

Member Function Documentation

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

Definition at line 158 of file vpMath.h.

Referenced by vpMeNurbs::seekExtremities().

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
$ n! / ((n-p)! p!) $

Definition at line 213 of file vpMath.h.

References fact().

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

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

Compares $ | x - y | $ to $ s $.

Parameters
x: x value.
y: y value.
s: Tolerance threshold.
Returns
true if $ | x - y | < s $.

Definition at line 275 of file vpMath.h.

References nul().

Referenced by vpHomography::computeDisplacement(), and vpHomography::computeRotation().

double vpMath::fact ( unsigned int  x)
inlinestatic

Computes and returns x!

Parameters
x: parameter of factorial function.

Definition at line 199 of file vpMath.h.

Referenced by comb().

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

Compares $ x $ to $ y - s $.

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

Definition at line 287 of file vpMath.h.

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

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

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

Definition at line 331 of file vpMath.h.

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

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

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

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

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

Compares $ | x | $ to $ s $.

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

Definition at line 263 of file vpMath.h.

Referenced by equal().

static double vpMath::rad ( double  deg)
inlinestatic

Convert an angle in degrees into radian.

Parameters
deg: Angle in degrees.
Returns
Angle converted in radian.
Examples:
calibrateTsai.cpp, exponentialMap.cpp, homographyHartleyDLT2DObject.cpp, homographyHLM2DObject.cpp, homographyHLM3DObject.cpp, homographyRansac2DObject.cpp, manServo4PointsDisplay.cpp, manServoMomentsSimple.cpp, manSimu4Dots.cpp, manSimu4Points.cpp, mbtEdgeKltTracking.cpp, mbtKltTracking.cpp, moveAfma4.cpp, moveBiclops.cpp, movePtu46.cpp, photometricVisualServoing.cpp, servoAfma62DhalfCamVelocity.cpp, servoAfma6Cylinder2DCamVelocity.cpp, servoAfma6Cylinder2DCamVelocitySecondaryTask.cpp, servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp, servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp, servoAfma6Line2DCamVelocity.cpp, servoAfma6SquareLines2DCamVelocity.cpp, servoAfma6TwoLines2DCamVelocity.cpp, servoCycab.cpp, servoCycabBasic.cpp, servoMomentImage.cpp, servoMomentPoints.cpp, servoMomentPolygon.cpp, servoSimu3D_cdMc_CamVelocity.cpp, servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp, servoSimu3D_cMcd_CamVelocity.cpp, servoSimu3D_cMcd_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, servoSimuSquareLine2DCamVelocityDisplay.cpp, servoSimuThetaUCamVelocity.cpp, servoSimuViper850FourPoints2DCamVelocity.cpp, servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper850FourPointsKinect.cpp, simulateCircle2DCamVelocity.cpp, simulateFourPoints2DCartesianCamVelocity.cpp, simulateFourPoints2DPolarCamVelocity.cpp, sonarPioneerReader.cpp, testDisplacement.cpp, testFeatureSegment.cpp, testFindMatch.cpp, testKalmanAcceleration.cpp, testKalmanVelocity.cpp, testPose.cpp, testPoseFeatures.cpp, testViper850.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.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, and wireframeSimulator.cpp.

Definition at line 100 of file vpMath.h.

Referenced by vpMeEllipse::display(), vpRobotViper650::get_eJe(), vpRobotViper850::get_eJe(), vpAfma6::getInverseKinematics(), vpViper::getInverseKinematicsWrist(), vpRobotViper650::getPosition(), vpRobotViper850::getPosition(), vpRobotPioneer::getVelocity(), vpViper650::init(), vpViper850::init(), vpAfma6::init(), vpSimulatorAfma6::init(), vpSimulatorViper850::init(), vpSimulatorAfma6::initDisplay(), vpSimulatorViper850::initDisplay(), vpMbtPolygon::isVisible(), vpMbKltTracker::loadConfigFile(), vpMbEdgeTracker::loadConfigFile(), vpWireFrameSimulator::navigation(), vpSimulatorAfma6::readPosFile(), vpRobotAfma4::readPosFile(), vpRobotAfma6::readPosFile(), vpRobotPtu46::readPositionFile(), vpRobotBiclops::readPositionFile(), vpMbKltTracker::resetTracker(), vpMbEdgeTracker::resetTracker(), vpMbEdgeTracker::visibleFace(), vpMbEdgeTracker::vpMbEdgeTracker(), vpMbKltTracker::vpMbKltTracker(), vpRobotBiclops::vpRobotBiclopsSpeedControlLoop(), vpViper::vpViper(), vpViper650::vpViper650(), vpViper850::vpViper850(), and vpWireFrameSimulator::vpWireFrameSimulator().

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
$1/(1+exp(-n*((x-x0)/(x1-x0)-0.5)))$

Definition at line 363 of file vpMath.h.

int vpMath::sign ( double  x)
inlinestatic

Return the sign of x.

Returns
-1 if x is negative, +1 if positive.

Definition at line 248 of file vpMath.h.

Referenced by vpMbEdgeTracker::computeVVS(), round(), and vpMeNurbs::seekExtremities().

double vpMath::sinc ( double  x)
inlinestatic

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

Parameters
x: Value of x.
Returns
Sinus cardinal.

Definition at line 301 of file vpMath.h.

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

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

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

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

Definition at line 316 of file vpMath.h.

static double vpMath::sqr ( double  x)
inlinestatic

Compute x square value.

Returns
$ x^2 $.
Examples:
servoSimuSphere.cpp, servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp, and testRobust.cpp.

Definition at line 106 of file vpMath.h.

Referenced by vpImageFilter::coefficientGaussianDerivative(), vpHomography::computeDisplacement(), vpPose::computeResidual(), vpPose::computeResidualDementhon(), vpHomography::computeRotation(), vpCalibration::computeStdDeviation(), vpCalibration::computeStdDeviation_dist(), vpMbEdgeKltTracker::computeVVS(), vpMbEdgeTracker::computeVVS(), vpPixelMeterConversion::convertLine(), vpMeterPixelConversion::convertLine(), vpPixelMeterConversion::convertPointWithDistortion(), vpPose::coplanar(), vpFeatureBuilder::create(), vpDot2::defineDots(), vpDisplayOpenCV::displayArrow(), vpDisplayX::displayArrow(), vpDisplayGTK::displayArrow(), vpFeatureDisplay::displayEllipse(), vpCalibration::displayGrid(), vpMeSite::distance(), vpImagePoint::distance(), vpViper::getInverseKinematicsWrist(), vpHomography::HartleyNormalization(), vpMeEllipse::initTracking(), vpFeatureEllipse::interaction(), vpFeatureThetaU::interaction(), vpRotationMatrix::isARotationMatrix(), vpScale::KernelDensityGradient(), vpScale::KernelDensityGradient_EPANECHNIKOV(), vpMeLine::leastSquare(), vpMeNurbs::localReSample(), vpScale::MeanShift(), vpPose::poseRansac(), vpPose::poseVirtualVSrobust(), vpCircle::projection(), vpNurbs::removeCurveKnot(), vpMeLine::reSample(), vpMeLine::sample(), vpMeNurbs::sample(), vpMeLine::seekExtremities(), vpMeNurbs::seekExtremitiesCanny(), vpMeSite::sqrDistance(), vpImagePoint::sqrDistance(), vpMeNurbs::supressNearPoints(), vpMeSite::track(), and vpImageTools::undistort().

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