PCL
Mathematical Functions

Classes

class  pcl::Fact< T >
 Factorial function. More...
 
class  pcl::Pow10I< T >
 Exponential function 10**n, n being a signed integer. More...
 
class  pcl::Pow2I< T >
 Exponential function 2**n, n being a signed integer. More...
 

Functions

float pcl::Abs (float x) noexcept
 
template<typename T >
constexpr T pcl::Angle (int d, int m, T s) noexcept
 
template<typename T >
constexpr T pcl::Angle (int d, T m) noexcept
 
template<typename T >
constexpr T pcl::ArcCos (T x) noexcept
 
template<typename T >
constexpr T pcl::ArcCosh (T x) noexcept
 
template<typename T >
constexpr T pcl::ArcHav (T x) noexcept
 
template<typename T >
constexpr T pcl::ArcSin (T x) noexcept
 
template<typename T >
constexpr T pcl::ArcSinh (T x) noexcept
 
template<typename T >
constexpr T pcl::ArcTan (T x) noexcept
 
template<typename T >
constexpr T pcl::ArcTan (T y, T x) noexcept
 
template<typename T >
pcl::ArcTan2Pi (T y, T x) noexcept
 
template<typename T >
constexpr T pcl::ArcTanh (T x) noexcept
 
template<typename T >
constexpr T pcl::AsRad (T x) noexcept
 
void PCL_FUNC pcl::CalendarTimeToJD (int &jdi, double &jdf, int year, int month, int day, double dayf=0) noexcept
 
double pcl::CalendarTimeToJD (int year, int month, int day, double dayf=0) noexcept
 
template<typename T >
constexpr T pcl::Ceil (T x) noexcept
 
template<typename T >
constexpr T pcl::Cos (T x) noexcept
 
template<typename T >
constexpr T pcl::Cosh (T x) noexcept
 
template<typename T >
constexpr T pcl::Cotan (T x) noexcept
 
template<typename S1 , typename S2 , typename S3 , typename D >
void pcl::DecimalToSexagesimal (int &sign, S1 &s1, S2 &s2, S3 &s3, const D &d) noexcept
 
template<typename T >
constexpr T pcl::Deg (T x) noexcept
 
template<typename T >
constexpr T pcl::Erf (T x) noexcept
 
template<typename T >
constexpr T pcl::ErfInv (T x) noexcept
 
template<typename T >
constexpr T pcl::Exp (T x) noexcept
 
double pcl::Factorial (int n) noexcept
 
template<typename T >
constexpr T pcl::Floor (T x) noexcept
 
template<typename T >
constexpr T pcl::Frac (T x) noexcept
 
template<typename T >
void pcl::Frexp (T x, T &m, int &p) noexcept
 
template<typename T >
constexpr T pcl::Hav (T x) noexcept
 
void pcl::JDToCalendarTime (int &year, int &month, int &day, double &dayf, double jd) noexcept
 
void PCL_FUNC pcl::JDToCalendarTime (int &year, int &month, int &day, double &dayf, int jdi, double jdf) noexcept
 
template<typename T >
pcl::L1Norm (const T *i, const T *j) noexcept
 
template<typename T >
pcl::L2Norm (const T *i, const T *j) noexcept
 
template<typename T >
constexpr T pcl::Ldexp (T m, int p) noexcept
 
template<typename T >
constexpr T pcl::Ln (T x) noexcept
 
constexpr long double pcl::Ln2 () noexcept
 
double pcl::LnFactorial (int n) noexcept
 
template<typename T >
constexpr T pcl::Log (T x) noexcept
 
constexpr long double pcl::Log2 () noexcept
 
template<typename T >
constexpr T pcl::Log2 (T x) noexcept
 
constexpr long double pcl::Log2e () noexcept
 
constexpr long double pcl::Log2T () noexcept
 
template<typename T >
constexpr T pcl::LogN (T n, T x) noexcept
 
template<typename T >
constexpr T pcl::MasRad (T x) noexcept
 
template<typename T >
constexpr T pcl::MinRad (T x) noexcept
 
template<typename T >
constexpr T pcl::Mod (T x, T y) noexcept
 
template<typename T >
constexpr T pcl::Mod2Pi (T x) noexcept
 
template<typename T >
constexpr T pcl::ModPi (T x) noexcept
 
template<typename T >
pcl::Norm (const T *i, const T *j) noexcept
 
template<typename T , typename P >
pcl::Norm (const T *i, const T *j, const P &p) noexcept
 
template<typename T >
constexpr T pcl::Norm2Pi (T x) noexcept
 
constexpr long double pcl::Pi () noexcept
 
template<typename T , typename C >
pcl::Poly (T x, C c, int n) noexcept
 
template<typename T >
pcl::Poly (T x, std::initializer_list< T > c) noexcept
 
template<typename T >
constexpr T pcl::Pow (T x, T y) noexcept
 
template<typename T >
pcl::Pow10 (T x) noexcept
 
template<typename T >
constexpr T pcl::Pow2 (T x) noexcept
 
template<typename T >
pcl::PowI (T x, int n) noexcept
 
template<typename T >
pcl::PowI10 (T x) noexcept
 
template<typename T >
pcl::PowI12 (T x) noexcept
 
template<typename T >
pcl::PowI4 (T x) noexcept
 
template<typename T >
pcl::PowI6 (T x) noexcept
 
template<typename T >
pcl::PowI8 (T x) noexcept
 
template<typename T >
constexpr T pcl::Rad (T x) noexcept
 
template<typename T >
constexpr T pcl::RadMin (T x) noexcept
 
template<typename T >
constexpr T pcl::RadSec (T x) noexcept
 
template<typename T1 , typename T2 >
void pcl::Rotate (int &x, int &y, T1 sa, T1 ca, T2 xc, T2 yc) noexcept
 
template<typename T1 , typename T2 >
void pcl::Rotate (int64 &x, int64 &y, T1 sa, T1 ca, T2 xc, T2 yc) noexcept
 
template<typename T1 , typename T2 >
void pcl::Rotate (long &x, long &y, T1 sa, T1 ca, T2 xc, T2 yc) noexcept
 
template<typename T , typename T1 , typename T2 >
void pcl::Rotate (T &x, T &y, T1 a, T2 xc, T2 yc) noexcept
 
template<typename T , typename T1 , typename T2 >
void pcl::Rotate (T &x, T &y, T1 sa, T1 ca, T2 xc, T2 yc) noexcept
 
template<typename T >
pcl::RotL (T x, uint32 n) noexcept
 
template<typename T >
pcl::RotR (T x, uint32 n) noexcept
 
double pcl::Round (double x) noexcept
 
float pcl::Round (float x) noexcept
 
long double pcl::Round (long double x) noexcept
 
template<typename T >
pcl::Round (T x, int n) noexcept
 
template<typename T >
int pcl::RoundI (T x) noexcept
 
template<typename T >
int pcl::RoundInt (T x) noexcept
 
int64 pcl::RoundInt64 (double x) noexcept
 
int64 pcl::RoundInt64Arithmetic (double x) noexcept
 
template<typename T >
int pcl::RoundIntArithmetic (T x) noexcept
 
template<typename T >
int pcl::RoundIntBanker (T x) noexcept
 
template<typename T >
constexpr T pcl::SecRad (T x) noexcept
 
template<typename S1 , typename S2 , typename S3 >
double pcl::SexagesimalToDecimal (int sign, const S1 &s1, const S2 &s2=S2(0), const S3 &s3=S3(0)) noexcept
 
template<typename T >
constexpr int pcl::Sign (T x) noexcept
 
template<typename T >
constexpr char pcl::SignChar (T x) noexcept
 
template<typename T >
constexpr T pcl::Sin (T x) noexcept
 
template<typename T >
void pcl::SinCos (T x, T &sx, T &cx) noexcept
 
template<typename T >
constexpr T pcl::Sinh (T x) noexcept
 
template<typename T >
void pcl::Split (T x, T &i, T &f) noexcept
 
template<typename T >
constexpr T pcl::Sqrt (T x) noexcept
 
template<typename T >
constexpr T pcl::Tan (T x) noexcept
 
template<typename T >
constexpr T pcl::Tanh (T x) noexcept
 
template<typename T >
pcl::Trunc (T x) noexcept
 
template<typename T >
int pcl::TruncI (T x) noexcept
 
template<typename T >
int64 pcl::TruncI64 (T x) noexcept
 
template<typename T >
int pcl::TruncInt (T x) noexcept
 
template<typename T >
int64 pcl::TruncInt64 (T x) noexcept
 
constexpr long double pcl::TwoPi () noexcept
 
template<typename T >
constexpr T pcl::UasRad (T x) noexcept
 

Detailed Description

Function Documentation

◆ Abs()

float pcl::Abs ( float  x)
inlinenoexcept

Absolute value of x.

Definition at line 320 of file Math.h.

◆ Angle() [1/2]

template<typename T >
constexpr T pcl::Angle ( int  d,
int  m,
s 
)
inlineconstexprnoexcept

Merges a complex angle given by degrees, arcminutes and arcseconds into single degrees.

Definition at line 491 of file Math.h.

◆ Angle() [2/2]

template<typename T >
constexpr T pcl::Angle ( int  d,
m 
)
inlineconstexprnoexcept

Merges a complex angle given by degrees and arcminutes into single degrees.

Definition at line 481 of file Math.h.

◆ ArcCos()

template<typename T >
constexpr T pcl::ArcCos ( x)
inlineconstexprnoexcept

Inverse cosine function (arccosine).

Definition at line 502 of file Math.h.

Referenced by pcl::ProjectionBase::DistanceFast().

◆ ArcCosh()

template<typename T >
constexpr T pcl::ArcCosh ( x)
inlineconstexprnoexcept

Inverse hyperbolic cosine function.

ArcCosh( x ) = 2*Ln( Sqrt( (x + 1)/2 ) + Sqrt( (x - 1)/2 ) )

Definition at line 1845 of file Math.h.

◆ ArcHav()

template<typename T >
constexpr T pcl::ArcHav ( x)
inlineconstexprnoexcept

Inverse haversine (archaversine) function:

ArcHav( x ) = 2*ArcSin( Sqrt( x ) )

The haversine is useful to work with tiny angles.

Definition at line 1883 of file Math.h.

◆ ArcSin()

template<typename T >
constexpr T pcl::ArcSin ( x)
inlineconstexprnoexcept

Inverse sine function (arcsine).

Definition at line 514 of file Math.h.

◆ ArcSinh()

template<typename T >
constexpr T pcl::ArcSinh ( x)
inlineconstexprnoexcept

Inverse hyperbolic sine function.

ArcSinh( x ) = Ln( x + Sqrt( 1 + x**2 ) )

Definition at line 1827 of file Math.h.

◆ ArcTan() [1/2]

template<typename T >
constexpr T pcl::ArcTan ( x)
inlineconstexprnoexcept

Inverse tangent function (arctangent).

Definition at line 526 of file Math.h.

Referenced by pcl::GenericVector< bool >::Angle3D(), and pcl::ZenithalProjectionBase::Unproject().

◆ ArcTan() [2/2]

template<typename T >
constexpr T pcl::ArcTan ( y,
x 
)
inlineconstexprnoexcept

Arctangent of y/x, result in the proper quadrant.

Definition at line 537 of file Math.h.

◆ ArcTan2Pi()

template<typename T >
T pcl::ArcTan2Pi ( y,
x 
)
inlinenoexcept

Arctangent of y/x, proper quadrant, result in the interval [0,2pi).

Definition at line 548 of file Math.h.

◆ ArcTanh()

template<typename T >
constexpr T pcl::ArcTanh ( x)
inlineconstexprnoexcept

Inverse hyperbolic tangent function.

ArcTanh( x ) = (Ln( 1 + x ) - Ln( 1 - x ))/2

Definition at line 1863 of file Math.h.

◆ AsRad()

template<typename T >
constexpr T pcl::AsRad ( x)
inlineconstexprnoexcept

Conversion from arcseconds to radians (a synonym for SecRad()).

Definition at line 1947 of file Math.h.

Referenced by pcl::Position::EpsA().

◆ CalendarTimeToJD() [1/2]

void PCL_FUNC pcl::CalendarTimeToJD ( int &  jdi,
double &  jdf,
int  year,
int  month,
int  day,
double  dayf = 0 
)
noexcept

Computes the Julian date (JD) corresponding to a time point expressed as a date and a day fraction, providing the result by its separate integer and fractional parts.

Parameters
[out]jdiOn output, the integer part of the resulting JD.
[out]jdfOn output, the fractional part of the resulting JD.
yearThe year of the date. Positive and negative years are supported. Years are counted arithmetically: the year zero is the year before the year +1, that is, what historians call the year 1 B.C.
monthThe month of the date. Usually in the [1,12] range but can be any integer number.
dayThe day of the date. Usually in the [1,31] range but can be any integer number.
dayfThe day fraction. The default value is zero, which computes the JD at zero hours. Usually in the [0,1) range but can be any real number.

This routine, as well as JDToCalendarTime(), implement modified versions of the original algorithms due to Jean Meeus. Our modifications allow for negative Julian dates, which extends the range of allowed dates to the past considerably. We developed these modifications in the context of large-scale solar system ephemeris calculations.

The computed value is the JD corresponding to the specified date and day fraction, which is equal to the sum of the jdi and jdf variables.

References

Meeus, Jean (1991), Astronomical Algorithms, Willmann-Bell, Inc., chapter 7.

Referenced by pcl::CalendarTimeToJD(), and pcl::TimePoint::TimePoint().

◆ CalendarTimeToJD() [2/2]

double pcl::CalendarTimeToJD ( int  year,
int  month,
int  day,
double  dayf = 0 
)
inlinenoexcept

Computes the Julian date (JD) corresponding to a time point expressed as a date and a day fraction.

Parameters
yearThe year of the date. Positive and negative years are supported. Years are counted arithmetically: the year zero is the year before the year +1, that is, what historians call the year 1 B.C.
monthThe month of the date. Usually in the [1,12] range but can be any integer number.
dayThe day of the date. Usually in the [1,31] range but can be any integer number.
dayfThe day fraction. The default value is zero, which computes the JD at zero hours. Usually in the [0,1) range but can be any real number.

This routine, as well as JDToCalendarTime(), implement modified versions of the original algorithms due to Jean Meeus. Our modifications allow for negative Julian dates, which extends the range of allowed dates to the past considerably. We developed these modifications in the context of large-scale solar system ephemeris calculations.

The returned value is the JD corresponding to the specified date and day fraction.

Because of the numerical precision of the double type (IEEE 64-bit floating point), this routine can return JD values accurate only to within one millisecond.

References

Meeus, Jean (1991), Astronomical Algorithms, Willmann-Bell, Inc., chapter 7.

Definition at line 2428 of file Math.h.

References pcl::CalendarTimeToJD().

◆ Ceil()

template<typename T >
constexpr T pcl::Ceil ( x)
inlineconstexprnoexcept

The ceil function: lowest integer >= x.

Definition at line 562 of file Math.h.

◆ Cos()

template<typename T >
constexpr T pcl::Cos ( x)
inlineconstexprnoexcept

Cosine function.

Definition at line 573 of file Math.h.

◆ Cosh()

template<typename T >
constexpr T pcl::Cosh ( x)
inlineconstexprnoexcept

Hyperbolic Cosine function.

Definition at line 584 of file Math.h.

◆ Cotan()

template<typename T >
constexpr T pcl::Cotan ( x)
inlineconstexprnoexcept

Cotangent of x, equal to Cos(x)/Sin(x) or 1/Tan(x).

Definition at line 595 of file Math.h.

◆ DecimalToSexagesimal()

template<typename S1 , typename S2 , typename S3 , typename D >
void pcl::DecimalToSexagesimal ( int &  sign,
S1 &  s1,
S2 &  s2,
S3 &  s3,
const D &  d 
)
inlinenoexcept

Conversion of a decimal scalar d to the equivalent sexagesimal decimal components sign, s1, s2 and s3, such that:

d = sign * (s1 + (s2 + s3/60)/60)

with the following constraints:

sign = -1 iff d < 0
sign = +1 iff d ≥ 0
0 ≤ s1
0 ≤ s2 < 60
0 ≤ s3 < 60

Definition at line 2525 of file Math.h.

◆ Deg()

◆ Erf()

template<typename T >
constexpr T pcl::Erf ( x)
inlineconstexprnoexcept

The error function: erf( x ).

Definition at line 4599 of file Math.h.

◆ ErfInv()

template<typename T >
constexpr T pcl::ErfInv ( x)
inlineconstexprnoexcept

The inverse error function: erf^-1( x ).

Code adapted from erfinv implementation by Lakshay Garg:

https://github.com/lakshayg/erfinv

Copyright (c) 2017-2019 Lakshay Garg Licensed under MIT license.

Definition at line 4616 of file Math.h.

◆ Exp()

template<typename T >
constexpr T pcl::Exp ( x)
inlineconstexprnoexcept

The exponential function e**x.

Definition at line 617 of file Math.h.

◆ Factorial()

double pcl::Factorial ( int  n)
inlinenoexcept

The factorial of n ≥ 0.

A static lookup table is used to speed up for n <= 127.

Definition at line 712 of file Math.h.

◆ Floor()

template<typename T >
constexpr T pcl::Floor ( x)
inlineconstexprnoexcept

The floor function: highest integer <= x.

Definition at line 628 of file Math.h.

◆ Frac()

template<typename T >
constexpr T pcl::Frac ( x)
inlineconstexprnoexcept

Fractional part of x. The returned value is within (-1,+1), and has the same sign as x.

Definition at line 640 of file Math.h.

Referenced by pcl::TimePoint::GetCalendarTime(), pcl::JDToCalendarTime(), and pcl::TimePoint::TimePoint().

◆ Frexp()

template<typename T >
void pcl::Frexp ( x,
T &  m,
int &  p 
)
inlinenoexcept

Calculates base-2 mantissa and exponent. The arguments m and p receive the values of the base-2 mantissa and exponent, respectively, such that: 0.5 <= m < 1.0, x = m * 2**p

Definition at line 653 of file Math.h.

◆ Hav()

template<typename T >
constexpr T pcl::Hav ( x)
inlineconstexprnoexcept

Haversine function:

Hav( x ) = (1 - Cos( x ))/2

The haversine is useful to work with tiny angles.

Definition at line 669 of file Math.h.

◆ JDToCalendarTime() [1/2]

void pcl::JDToCalendarTime ( int &  year,
int &  month,
int &  day,
double &  dayf,
double  jd 
)
inlinenoexcept

Computes the date and day fraction corresponding to a time point expressed as a Julian date (JD).

Parameters
[out]yearOn output, this variable receives the year of the resulting date.
[out]monthOn output, this variable receives the month of the resulting date in the range [1,12].
[out]dayOn output, this variable receives the day of the resulting date in the range [1,31]. Different month day counts and leap years are taken into account, so the returned day corresponds to an existing calendar date.
[out]dayfOn output, this variable receives the day fraction for the specified time point, in the [0,1) range.
jdThe input time point as a Julian date.

Because of the numerical precision of the double type (IEEE 64-bit floating point), this routine can handle JD values accurate only to within one millisecond.

For more information about the implemented algorithms and references, see the documentation for CalendarTimeToJD().

Definition at line 2497 of file Math.h.

References pcl::Frac(), pcl::JDToCalendarTime(), and pcl::TruncInt().

◆ JDToCalendarTime() [2/2]

void PCL_FUNC pcl::JDToCalendarTime ( int &  year,
int &  month,
int &  day,
double &  dayf,
int  jdi,
double  jdf 
)
noexcept

Computes the date and day fraction corresponding to a time point expressed as a Julian date (JD), specified by its separate integer and fractional parts.

Parameters
[out]yearOn output, this variable receives the year of the resulting date.
[out]monthOn output, this variable receives the month of the resulting date in the range [1,12].
[out]dayOn output, this variable receives the day of the resulting date in the range [1,31]. Different month day counts and leap years are taken into account, so the returned day corresponds to an existing calendar date.
[out]dayfOn output, this variable receives the day fraction for the specified time point, in the [0,1) range.
jdiThe integer part of the input Julian date.
jdfThe fractional part of the input Julian date.

The input time point must be equal to the sum of jdi and jdf.

For more information about the implemented algorithms and references, see the documentation for CalendarTimeToJD().

Referenced by pcl::TimePoint::Day(), pcl::TimePoint::DayFraction(), pcl::TimePoint::GetCalendarTime(), pcl::JDToCalendarTime(), pcl::TimePoint::Month(), and pcl::TimePoint::Year().

◆ L1Norm()

template<typename T >
T pcl::L1Norm ( const T *  i,
const T *  j 
)
inlinenoexcept

Computes the L1 norm (or Manhattan norm) of the elements in the sequence [i,j). The L1 norm is the sum of the absolute values of the elements.

Definition at line 2194 of file Math.h.

Referenced by pcl::GenericVector< bool >::L1Norm().

◆ L2Norm()

template<typename T >
T pcl::L2Norm ( const T *  i,
const T *  j 
)
inlinenoexcept

Computes the L2 norm (or Euclidean norm) of the elements in the sequence [i,j). The L2 norm is the square root of the sum of squared elements.

Definition at line 2253 of file Math.h.

Referenced by pcl::GenericVector< bool >::L2Norm(), and pcl::GenericVector< bool >::Norm().

◆ Ldexp()

template<typename T >
constexpr T pcl::Ldexp ( m,
int  p 
)
inlineconstexprnoexcept

Calculates m * 2**p.

Definition at line 680 of file Math.h.

◆ Ln()

template<typename T >
constexpr T pcl::Ln ( x)
inlineconstexprnoexcept

Natural (base e) logarithm of x.

Definition at line 691 of file Math.h.

◆ Ln2()

constexpr long double pcl::Ln2 ( )
inlineconstexprnoexcept

Natural (base e) logarithm of two.

Definition at line 799 of file Math.h.

◆ LnFactorial()

double pcl::LnFactorial ( int  n)
inlinenoexcept

The natural logarithm of the factorial of n ≥ 0.

For n <= 127 computes the natural logarithm of the factorial function directly. For n > 127 computes a series approximation, so that the function won't overflow even for very large arguments.

Definition at line 732 of file Math.h.

References pcl::Ln().

◆ Log()

template<typename T >
constexpr T pcl::Log ( x)
inlineconstexprnoexcept

Base 10 Logarithm of x.

Definition at line 810 of file Math.h.

◆ Log2() [1/2]

constexpr long double pcl::Log2 ( )
inlineconstexprnoexcept

Base 10 Logarithm of two.

Definition at line 822 of file Math.h.

◆ Log2() [2/2]

template<typename T >
constexpr T pcl::Log2 ( x)
inlineconstexprnoexcept

Base 2 Logarithm of x.

Definition at line 835 of file Math.h.

◆ Log2e()

constexpr long double pcl::Log2e ( )
inlineconstexprnoexcept

Base 2 Logarithm of e.

Definition at line 849 of file Math.h.

◆ Log2T()

constexpr long double pcl::Log2T ( )
inlineconstexprnoexcept

Base 2 Logarithm of ten.

Definition at line 862 of file Math.h.

◆ LogN()

template<typename T >
constexpr T pcl::LogN ( n,
x 
)
inlineconstexprnoexcept

Base n logarithm of x.

Definition at line 875 of file Math.h.

◆ MasRad()

template<typename T >
constexpr T pcl::MasRad ( x)
inlineconstexprnoexcept

Conversion from milliarcseconds (mas) to radians.

Definition at line 1958 of file Math.h.

◆ MinRad()

template<typename T >
constexpr T pcl::MinRad ( x)
inlineconstexprnoexcept

Conversion from arcminutes to radians.

Definition at line 1927 of file Math.h.

◆ Mod()

template<typename T >
constexpr T pcl::Mod ( x,
y 
)
inlineconstexprnoexcept

Remainder of x/y.

Definition at line 887 of file Math.h.

◆ Mod2Pi()

template<typename T >
constexpr T pcl::Mod2Pi ( x)
inlineconstexprnoexcept

An angle in radians reduced to the (-2pi,+2pi) range, that is, the remainder of x/(2*pi).

Definition at line 1993 of file Math.h.

◆ ModPi()

template<typename T >
constexpr T pcl::ModPi ( x)
inlineconstexprnoexcept

An angle in radians reduced to the [-pi,+pi] range.

Definition at line 1980 of file Math.h.

◆ Norm() [1/2]

template<typename T >
T pcl::Norm ( const T *  i,
const T *  j 
)
inlinenoexcept

Computes the L2 norm (or Euclidean norm) of the elements in the sequence [i,j). This function is a synonym for L2Norm().

Definition at line 2303 of file Math.h.

◆ Norm() [2/2]

template<typename T , typename P >
T pcl::Norm ( const T *  i,
const T *  j,
const P &  p 
)
inlinenoexcept

Computes the norm of the elements in the sequence [i,j). For any real p > 0, the norm N is given by:

N = sum( abs( x )^p )^(1/p)

for all x in [i,j).

See also
L1Norm(), L2Norm()

Definition at line 2135 of file Math.h.

Referenced by pcl::GenericVector< bool >::Norm().

◆ Norm2Pi()

template<typename T >
constexpr T pcl::Norm2Pi ( x)
inlineconstexprnoexcept

An angle in radians normalized to the [0,2pi) range.

Definition at line 2004 of file Math.h.

◆ Pi()

constexpr long double pcl::Pi ( )
inlineconstexprnoexcept

The pi constant: 3.141592...

Definition at line 461 of file Math.h.

◆ Poly() [1/2]

template<typename T , typename C >
T pcl::Poly ( x,
c,
int  n 
)
inlinenoexcept

Horner's algorithm to evaluate the polynomial function with the specified array c of n + 1 coefficients:

y = c[0] + c[1]*x + c[2]*x**2 + ... + c[n]*x**n

The array c of coefficients must provide contiguous storage for at least n + 1 values of type T. The degree n must be >= 0; otherwise this function invokes undefined behavior.

Definition at line 908 of file Math.h.

Referenced by pcl::Position::EpsA().

◆ Poly() [2/2]

template<typename T >
T pcl::Poly ( x,
std::initializer_list< T >  c 
)
inlinenoexcept

Horner's algorithm to evaluate the polynomial function:

y = c[0] + c[1]*x + c[2]*x**2 + ... + c[n]*x**n

The specified coefficients initializer list c must not be empty; otherwise this function invokes undefined behavior.

Definition at line 932 of file Math.h.

◆ Pow()

template<typename T >
constexpr T pcl::Pow ( x,
y 
)
inlineconstexprnoexcept

General power function: x raised to y.

When you know some of the arguments in advance, faster alternatives are:

  • Use Pow10I<T>()( y ) when x == 10 and y is an integer
  • Use PowI( x, y ) when x != 10 and y is an integer
  • Use Pow10( y ) when x == 10 and y is not an integer

Otherwise, you can also use: Pow2( y*Log2( x ) )

Definition at line 1251 of file Math.h.

◆ Pow10()

template<typename T >
T pcl::Pow10 ( x)
inlinenoexcept

The exponential function 10**x.

Definition at line 1312 of file Math.h.

◆ Pow2()

template<typename T >
constexpr T pcl::Pow2 ( x)
inlineconstexprnoexcept

The exponential function 2**x.

Definition at line 1717 of file Math.h.

Referenced by pcl::PSFData::FWHM(), and pcl::MoffatFilter::FWHMx().

◆ PowI()

template<typename T >
T pcl::PowI ( x,
int  n 
)
inlinenoexcept

The exponential function x**n, where n is a signed integer.

Definition at line 1755 of file Math.h.

◆ PowI10()

template<typename T >
T pcl::PowI10 ( x)
inlinenoexcept

Returns x raised to the 10th power.

Definition at line 1804 of file Math.h.

◆ PowI12()

template<typename T >
T pcl::PowI12 ( x)
inlinenoexcept

Returns x raised to the 12th power.

Definition at line 1813 of file Math.h.

◆ PowI4()

template<typename T >
T pcl::PowI4 ( x)
inlinenoexcept

Returns x raised to the 4th power.

Definition at line 1777 of file Math.h.

◆ PowI6()

template<typename T >
T pcl::PowI6 ( x)
inlinenoexcept

Returns x raised to the 6th power.

Definition at line 1786 of file Math.h.

◆ PowI8()

template<typename T >
T pcl::PowI8 ( x)
inlinenoexcept

Returns x raised to the 8th power.

Definition at line 1795 of file Math.h.

◆ Rad()

template<typename T >
constexpr T pcl::Rad ( x)
inlineconstexprnoexcept

◆ RadMin()

template<typename T >
constexpr T pcl::RadMin ( x)
inlineconstexprnoexcept

Conversion from radians to arcminutes.

Definition at line 1905 of file Math.h.

◆ RadSec()

template<typename T >
constexpr T pcl::RadSec ( x)
inlineconstexprnoexcept

Conversion from radians to arcseconds.

Definition at line 1916 of file Math.h.

◆ Rotate() [1/5]

template<typename T1 , typename T2 >
void pcl::Rotate ( int &  x,
int &  y,
T1  sa,
T1  ca,
T2  xc,
T2  yc 
)
inlinenoexcept

Rotates a point on the plane.

This is a template instantiation of Rotate( T&, T&, T1, T1, T2, T2 ) for the int type.

Rotated coordinates are rounded to the nearest integers.

Definition at line 2043 of file Math.h.

References pcl::RoundInt().

◆ Rotate() [2/5]

template<typename T1 , typename T2 >
void pcl::Rotate ( int64 x,
int64 y,
T1  sa,
T1  ca,
T2  xc,
T2  yc 
)
inlinenoexcept

Rotates a point on the plane.

This is a template instantiation of Rotate( T&, T&, T1, T1, T2, T2 ) for the int64 type.

Rotated coordinates are rounded to the nearest integers.

Definition at line 2081 of file Math.h.

References pcl::RoundInt64().

◆ Rotate() [3/5]

template<typename T1 , typename T2 >
void pcl::Rotate ( long &  x,
long &  y,
T1  sa,
T1  ca,
T2  xc,
T2  yc 
)
inlinenoexcept

Rotates a point on the plane.

This is a template instantiation of Rotate( T&, T&, T1, T1, T2, T2 ) for the long type.

Rotated coordinates are rounded to the nearest integers.

Definition at line 2062 of file Math.h.

References pcl::RoundInt().

◆ Rotate() [4/5]

template<typename T , typename T1 , typename T2 >
void pcl::Rotate ( T &  x,
T &  y,
T1  a,
T2  xc,
T2  yc 
)
inlinenoexcept

Rotates a point on the plane.

Parameters
[out]x,yPoint coordinates. On output, these variables will receive the corresponding rotated coordinates.
aRotation angle in radians.
xc,ycCoordinates of the center of rotation.

Instantiations for integer types round rotated coordinated to the nearest integers.

Definition at line 2105 of file Math.h.

◆ Rotate() [5/5]

template<typename T , typename T1 , typename T2 >
void pcl::Rotate ( T &  x,
T &  y,
T1  sa,
T1  ca,
T2  xc,
T2  yc 
)
inlinenoexcept

Rotates a point on the plane.

Parameters
[out]x,yPoint coordinates. On output, these variables will receive the corresponding rotated coordinates.
sa,caSine and cosine of the rotation angle.
xc,ycCoordinates of the center of rotation.

Definition at line 2024 of file Math.h.

Referenced by pcl::GenericPoint< T >::Rotate(), pcl::Rotate(), pcl::Array< GaiaStarData >::Rotate(), and pcl::GenericRectangle< T >::Rotate().

◆ RotL()

template<typename T >
T pcl::RotL ( x,
uint32  n 
)
inlinenoexcept

Bitwise rotate left function: Rotates x to the left by n bits.

The template argument T must be an unsigned arithmetic type (uint8, uint16, uint32 or uint64). The bit count n must be smaller than the number of bits required to store an instance of T; for example, if T is uint32, n must be in the range [0,31].

Definition at line 1330 of file Math.h.

Referenced by pcl::BigToLittleEndian(), pcl::XoShiRo256ss::UI64(), and pcl::XoRoShiRo1024ss::UI64().

◆ RotR()

template<typename T >
T pcl::RotR ( x,
uint32  n 
)
inlinenoexcept

Bitwise rotate right function: Rotates x to the right by n bits.

The template argument T must be an unsigned arithmetic type (uint8, uint16, uint32 or uint64). The bit count n must be smaller than the number of bits required to store an instance of T; for example, if T is uint32, n must be in the range [0,31].

Definition at line 1351 of file Math.h.

Referenced by pcl::BigToLittleEndian().

◆ Round() [1/4]

double pcl::Round ( double  x)
inlinenoexcept

Round function: x rounded to the nearest integer (double precision version).

Note
This is a performance-critical routine. It has been implemented using high-performance, low-level techniques that may include inline assembly code and/or compiler intrinsic functions.

Definition at line 1373 of file Math.h.

◆ Round() [2/4]

float pcl::Round ( float  x)
inlinenoexcept

Round function: x rounded to the nearest integer (single precision version).

Note
This is a performance-critical routine. It has been implemented using high-performance, low-level techniques that may include inline assembly code and/or compiler intrinsic functions.

Definition at line 1406 of file Math.h.

◆ Round() [3/4]

long double pcl::Round ( long double  x)
inlinenoexcept

Round function: x rounded to the nearest integer (long double version).

Note
This is a performance-critical routine. It has been implemented using high-performance, low-level techniques that may include inline assembly code and/or compiler intrinsic functions.

Definition at line 1439 of file Math.h.

◆ Round() [4/4]

template<typename T >
T pcl::Round ( x,
int  n 
)
inlinenoexcept

General rounding function: x rounded to n fractional digits.

Definition at line 1705 of file Math.h.

◆ RoundI()

template<typename T >
int pcl::RoundI ( x)
inlinenoexcept

RoundI function: Rounds x to the nearest integer and converts the result to a 32-bit signed integer.

Deprecated:
Use RoundInt() in newly produced code.

Definition at line 1544 of file Math.h.

◆ RoundInt()

template<typename T >
int pcl::RoundInt ( x)
inlinenoexcept

RoundInt function: Rounds x to the nearest integer and converts the result to a 32-bit signed integer.

This function follows the Banker's rounding rule: a perfect half is always rounded to the nearest even digit. Some examples:

RoundInt( 0.5 ) -> 0
RoundInt( 1.5 ) -> 2
RoundInt( 2.5 ) -> 2
RoundInt( 3.5 ) -> 4

By contrast, arithmetic rounding rounds a perfect half to the nearest digit, either odd or even. For example:

RoundIntArithmetic( 0.5 ) -> 1
RoundIntArithmetic( 1.5 ) -> 2
RoundIntArithmetic( 2.5 ) -> 3
RoundIntArithmetic( 3.5 ) -> 4

Banker's rounding (also known as Gaussian rounding) is statistically more accurate than the usual arithmetic rounding, but it causes aliasing problems in some specific algorithms that depend critically on uniform rounding, such as nearest neighbor upsampling.

Note
This is a performance-critical routine. It has been implemented using high-performance, low-level techniques that may include inline assembly code and/or compiler intrinsic functions.
See also
RoundIntArithmetic(), RoundIntBanker()

Definition at line 1503 of file Math.h.

Referenced by pcl::Histogram::HistogramLevel(), pcl::Sizer::LogicalPixelsToPhysical(), pcl::Control::LogicalPixelsToPhysical(), pcl::Control::LogicalPixelsToResource(), pcl::Sizer::PhysicalPixelsToLogical(), pcl::Control::PhysicalPixelsToLogical(), pcl::Histogram::Resample(), pcl::Control::ResourcePixelsToLogical(), pcl::Rotate(), pcl::GenericPoint< T >::RoundedToInt(), pcl::GenericRectangle< T >::RoundedToInt(), pcl::Control::ScaledCursorHotSpot(), pcl::UInt20PixelTraits::ToSample(), pcl::UInt24PixelTraits::ToSample(), pcl::UIResourceScalingIndex(), pcl::UIScaled(), and pcl::UIUnscaled().

◆ RoundInt64()

int64 pcl::RoundInt64 ( double  x)
inlinenoexcept

RoundInt64 function: Rounds x to the nearest integer and converts the result to a 64-bit signed integer.

Since the default IEEE 754 rounding mode follows Banker's rounding rule, this is what you should expect when calling this function. See the documentation for RoundInt() for more information on rounding modes.

Note
This is a performance-critical routine. It has been implemented using high-performance, low-level techniques that may include inline assembly code and/or compiler intrinsic functions.

Definition at line 1620 of file Math.h.

References pcl::Round().

Referenced by pcl::Rotate(), and pcl::RoundI64().

◆ RoundInt64Arithmetic()

int64 pcl::RoundInt64Arithmetic ( double  x)
inlinenoexcept

Rounds x to the nearest integer using the arithmetic rounding rule, and converts the result to a 64-bit signed integer.

Arithmetic rounding rounds a perfect half to the nearest digit, either odd or even. For example:

RoundIntArithmetic( 0.5 ) -> 1
RoundIntArithmetic( 1.5 ) -> 2
RoundIntArithmetic( 2.5 ) -> 3
RoundIntArithmetic( 3.5 ) -> 4

See the RoundInt() function for more information on rounding rules.

Note
This is a performance-critical routine. It has been implemented using high-performance, low-level techniques that may include inline assembly code and/or compiler intrinsic functions.
See also
RoundInt(), RoundIntBanker()

Definition at line 1683 of file Math.h.

References pcl::TruncInt64().

◆ RoundIntArithmetic()

template<typename T >
int pcl::RoundIntArithmetic ( x)
inlinenoexcept

Rounds x to the nearest integer using the arithmetic rounding rule, and converts the result to a 32-bit signed integer.

Arithmetic rounding rounds a perfect half to the nearest digit, either odd or even. For example:

RoundIntArithmetic( 0.5 ) -> 1
RoundIntArithmetic( 1.5 ) -> 2
RoundIntArithmetic( 2.5 ) -> 3
RoundIntArithmetic( 3.5 ) -> 4

See the RoundInt() function for more information on rounding rules.

Note
This is a performance-critical routine. It has been implemented using high-performance, low-level techniques that may include inline assembly code and/or compiler intrinsic functions.
See also
RoundInt(), RoundIntBanker()

Definition at line 1586 of file Math.h.

◆ RoundIntBanker()

template<typename T >
int pcl::RoundIntBanker ( x)
inlinenoexcept

Rounds x to the nearest integer using the Banker's rounding rule, and converts the result to a 32-bit signed integer.

This function is a convenience synonym for RoundInt().

Definition at line 1557 of file Math.h.

◆ SecRad()

template<typename T >
constexpr T pcl::SecRad ( x)
inlineconstexprnoexcept

Conversion from arcseconds to radians.

Definition at line 1938 of file Math.h.

◆ SexagesimalToDecimal()

template<typename S1 , typename S2 , typename S3 >
double pcl::SexagesimalToDecimal ( int  sign,
const S1 &  s1,
const S2 &  s2 = S2( 0 ),
const S3 &  s3 = S3( 0 ) 
)
inlinenoexcept

Conversion of the sexagesimal decimal components sign, s1, s2 and s3 to their equivalent decimal scalar. The returned value is equal to:

((sign < 0) ? -1 : +1)*(Abs( s1 ) + (s2 + s3/60)/60);

Definition at line 2547 of file Math.h.

References pcl::Abs().

◆ Sign()

template<typename T >
constexpr int pcl::Sign ( x)
inlineconstexprnoexcept

Sign function:

-1 if x ≤ 0
 0 if x = 0
+1 if x ≥ 0

Definition at line 951 of file Math.h.

◆ SignChar()

template<typename T >
constexpr char pcl::SignChar ( x)
inlineconstexprnoexcept

Sign character:

'-' if x ≤ 0
' ' if x = 0
'+' if x ≥ 0

Definition at line 969 of file Math.h.

◆ Sin()

template<typename T >
constexpr T pcl::Sin ( x)
inlineconstexprnoexcept

Sine function

Definition at line 980 of file Math.h.

◆ SinCos()

template<typename T >
void pcl::SinCos ( x,
T &  sx,
T &  cx 
)
inlinenoexcept

Sine and cosine of x.

The arguments sx and cx will receive, respectively, the values of the sine and cosine of x.

If supported by the underlying standard math library, this function is roughly twice as fast as calling Sin() and Cos() separately. For code that spend a significant amount of time calculating sines and cosines, this optimization is critical.

Definition at line 1030 of file Math.h.

Referenced by pcl::ProjectionBase::Distance(), pcl::ProjectionBase::DistanceFast(), pcl::Position::EclipticToEquatorial(), pcl::Position::EquatorialToEcliptic(), pcl::GenericVector< bool >::FromSpherical(), pcl::GnomonicProjection::GnomonicProjection(), pcl::ZenithalProjectionBase::Project(), pcl::GenericRectangle< T >::Rotate(), pcl::GenericMatrix< coefficient >::RotateX(), pcl::GenericMatrix< coefficient >::RotateY(), pcl::GenericMatrix< coefficient >::RotateZ(), pcl::GenericMatrix< coefficient >::RotationX(), pcl::GenericMatrix< coefficient >::RotationY(), and pcl::GenericMatrix< coefficient >::RotationZ().

◆ Sinh()

template<typename T >
constexpr T pcl::Sinh ( x)
inlineconstexprnoexcept

Hyperbolic Sine function.

Definition at line 991 of file Math.h.

◆ Split()

template<typename T >
void pcl::Split ( x,
T &  i,
T &  f 
)
inlinenoexcept

Integer and fractional parts of x.

The arguments i and f receive, respectively, the integer (truncated) part and the fractional part of x. It holds that x = i + f, i.e. both i and f have the same sign as x.

Definition at line 1051 of file Math.h.

◆ Sqrt()

template<typename T >
constexpr T pcl::Sqrt ( x)
inlineconstexprnoexcept

Square root function.

Definition at line 1062 of file Math.h.

◆ Tan()

template<typename T >
constexpr T pcl::Tan ( x)
inlineconstexprnoexcept

Tangent function.

Definition at line 1073 of file Math.h.

◆ Tanh()

template<typename T >
constexpr T pcl::Tanh ( x)
inlineconstexprnoexcept

Hyperbolic Tangent function.

Definition at line 1084 of file Math.h.

◆ Trunc()

template<typename T >
T pcl::Trunc ( x)
inlinenoexcept

◆ TruncI()

template<typename T >
int pcl::TruncI ( x)
inlinenoexcept

TruncI function: Truncated integer part of x as a 32-bit signed integer. to a 32-bit signed integer.

Deprecated:
Use TruncInt() in newly produced code.

Definition at line 1154 of file Math.h.

◆ TruncI64()

template<typename T >
int64 pcl::TruncI64 ( x)
inlinenoexcept

TruncI64 function: Truncated integer part of x as a 64-bit signed integer.

Deprecated:
Use TruncInt64() in newly produced code.

Definition at line 1231 of file Math.h.

◆ TruncInt()

template<typename T >
int pcl::TruncInt ( x)
inlinenoexcept

TruncInt function: Truncated integer part of x as a 32-bit signed integer.

Note
This is a performance-critical routine. It has been implemented using high-performance, low-level techniques that may include inline assembly code and/or compiler intrinsic functions.

Definition at line 1132 of file Math.h.

Referenced by pcl::JPLEphemeris::DENumber(), pcl::TimePoint::GetCalendarTime(), pcl::JDToCalendarTime(), pcl::JPLEphemeris::LENumber(), pcl::TimePoint::TimePoint(), pcl::GenericPoint< T >::TruncatedToInt(), and pcl::GenericRectangle< T >::TruncatedToInt().

◆ TruncInt64()

template<typename T >
int64 pcl::TruncInt64 ( x)
inlinenoexcept

TruncInt64 function: Truncated integer part of x as a 64-bit signed integer.

Note
This is a performance-critical routine. It has been implemented using high-performance, low-level techniques that may include inline assembly code and/or compiler intrinsic functions.

Definition at line 1209 of file Math.h.

Referenced by pcl::RoundInt64Arithmetic().

◆ TwoPi()

constexpr long double pcl::TwoPi ( )
inlineconstexprnoexcept

Twice the pi constant: 0.6283185...

Definition at line 470 of file Math.h.

Referenced by pcl::GenericVector< bool >::ToSpherical2Pi().

◆ UasRad()

template<typename T >
constexpr T pcl::UasRad ( x)
inlineconstexprnoexcept

Conversion from microarcseconds (uas) to radians.

Definition at line 1969 of file Math.h.