Math¶
- class Math¶
Bases:
pybind11_object
Provides simple mathematics computation tools that are not available in the C mathematics library (math.h)
Methods
Overloaded function.
Overloaded function.
Computes the number of combination of p elements inside n elements.
Compute the vector of longitude / latitude (in degree) couples for maxPoints regularly spaced on a sphere, using the following paper:
Overloaded function.
Compute from a given longitude, latitude and a sphere radius the homogeneous transformation from the ENU frame to the ECEF frame:
- param enu_M:
HomogeneousMatrix expressed in ENU frame.
- param x:
x value.
Computes and returns x!
Overloaded function.
Compute transformations from the local tangent plane (e.g. NED, ECU, ...) to the ECEF frame.
Compute the mean value for a vector of double.
Compute the median value for a vector of double.
Compute the standard deviation value for a vector of double.
- param x:
x value.
Overloaded function.
Overloaded function.
Overloaded function.
- param str:
String to check.
Compute the line equation using least-squares fitting that minimizes the cost function:
Overloaded function.
Compute the transformation such that the camera located at from position looks toward to position.
Overloaded function.
Compute \((1-cos(x))/x^2\)
Overloaded function.
Overloaded function.
Compute \((1-sinc(x))/x^2\) with \(sinc(x) = sin(x) / x\) .
Compute from a given longitude, latitude and a sphere radius the homogeneous transformation from the NED frame to the ECEF frame:
- param x:
Value to test.
Overloaded function.
Round x to the nearest integer.
- param x:
Value of x.
Return the sign of x.
Overloaded function.
- return:
Square value \(x^2\) .
Inherited Methods
Operators
__doc__
__module__
Attributes
__annotations__
- __init__(*args, **kwargs)¶
- static abs(*args, **kwargs)¶
Overloaded function.
abs(x: int) -> int
- Parameters:
- x
The number.
- Returns:
The absolute value of x
abs(x: float) -> float
- Parameters:
- x
The number.
- Returns:
The absolute value of x
- static clamp(*args, **kwargs)¶
Overloaded function.
clamp(v: int, lower: int, upper: int) -> int
Clamp a value to boundaries.Throw a vpException if the value of lower is greater than upper .
- Parameters:
- v
The value to clamp.
- lower
The boundaries to clamp v to.
- upper
The boundaries to clamp v to.
clamp(v: float, lower: float, upper: float) -> float
Clamp a value to boundaries.Throw a vpException if the value of lower is greater than upper .
- Parameters:
- v
The value to clamp.
- lower
The boundaries to clamp v to.
- upper
The boundaries to clamp v to.
- static comb(n: int, p: int) float ¶
Computes the number of combination of p elements inside n elements.
- static computeRegularPointsOnSphere(maxPoints: int) list[tuple[float, float]] ¶
Compute the vector of longitude / latitude (in degree) couples for maxPoints regularly spaced on a sphere, using the following paper:
“How to generate equidistributed points on the surface of a sphere”, Markus Deserno
Following image illustrates the camera poses regularly spaced on a sphere:
<unparsed image <doxmlparser.compound.docImageType object at 0x7f422d50f430>>
- static deg(*args, **kwargs)¶
Overloaded function.
deg(rad: float) -> float
Convert an angle in radians into degrees.
- Parameters:
- rad
Angle in radians.
- Returns:
Angle converted in degrees.
deg(r: visp._visp.core.RotationVector) -> visp._visp.core.ColVector
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.
deg(r: visp._visp.core.ColVector) -> visp._visp.core.ColVector
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.
- static enu2ecef(lonDeg: float, latDeg: float, radius: float) visp._visp.core.HomogeneousMatrix ¶
Compute from a given longitude, latitude and a sphere radius the homogeneous transformation from the ENU frame to the ECEF frame:
\[\begin{split}\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} \end{split}\]<unparsed image <doxmlparser.compound.docImageType object at 0x7f422d546ad0>>
Note
See ned2ecef() , getLocalTangentPlaneTransformations()
- static enu2ned(enu_M: visp._visp.core.HomogeneousMatrix) visp._visp.core.HomogeneousMatrix ¶
- Parameters:
- enu_M: visp._visp.core.HomogeneousMatrix¶
HomogeneousMatrix expressed in ENU frame.
- Returns:
Converted homogeneous matrix in NED frame.
- static getAngleBetweenMinPiAndPi(*args, **kwargs)¶
Overloaded function.
getAngleBetweenMinPiAndPi(theta: float) -> float
Convert angle between \(-\pi\) and \(\pi\) .
- Parameters:
- theta
The input angle we want to ensure it is in the interval \([-\pi ; \pi]\) .
- Returns:
The corresponding angle in the interval \([-\pi ; \pi]\) .
getAngleBetweenMinPiAndPi(theta: float) -> float
Convert angle between \(-\pi\) and \(\pi\) .
- Parameters:
- theta
The input angle we want to ensure it is in the interval \([-\pi ; \pi]\) .
- Returns:
The corresponding angle in the interval \([-\pi ; \pi]\) .
- static getLocalTangentPlaneTransformations(lonlatVec: list[tuple[float, float]], radius: float, func: vpHomogeneousMatrix(double, double, double)) list[visp._visp.core.HomogeneousMatrix] ¶
Compute transformations from the local tangent plane (e.g. NED, ECU, …) to the ECEF frame.
Following image illustrates the camera poses sampled using longitude / latitude coordinates:
<unparsed image <doxmlparser.compound.docImageType object at 0x7f422d574a90>>
Note
See enu2ecef() , ned2ecef()
- static getStdev(v: list[float], useBesselCorrection: bool = false) float ¶
Compute the standard deviation value for a vector of double.
- static isFinite(*args, **kwargs)¶
Overloaded function.
isFinite(value: float) -> bool
- Parameters:
- value
Double number to check.
- Returns:
true if value is neither infinite nor NaN (as defined by IEEE754 standard) and false otherwise.
isFinite(value: float) -> bool
- Parameters:
- value
Float number to check.
- Returns:
true if value is neither infinite nor NaN (as defined by IEEE754 standard) and false otherwise.
- static isInf(*args, **kwargs)¶
Overloaded function.
isInf(value: float) -> bool
- Parameters:
- value
Double number to check.
- Returns:
true if value is a plus or minus infinity (as defined by IEEE754 standard) and false otherwise.
isInf(value: float) -> bool
- Parameters:
- value
Float number to check.
- Returns:
true if value is a plus or minus infinity (as defined by IEEE754 standard) and false otherwise.
- static isNaN(*args, **kwargs)¶
Overloaded function.
isNaN(value: float) -> bool
- Parameters:
- value
Double number to check.
- Returns:
true if value is Not A Number (as defined by IEEE754 standard) and false otherwise.
isNaN(value: float) -> bool
- Parameters:
- value
Float number to check.
- Returns:
true if value is Not A Number (as defined by IEEE754 standard) and false otherwise.
- static lineFitting(imPts: list[visp._visp.core.ImagePoint]) tuple[float, float, float, float] ¶
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: list[visp._visp.core.ImagePoint]¶
Image points (size >= 3).
- Returns:
A tuple containing:
The mean distance error (point-to-line distance) between the points and the fitted line.
a: a coefficient.
b: b coefficient.
c: c coefficient.
- static linspace(*args, **kwargs)¶
Overloaded function.
linspace(start_in: int, end_in: int, num_in: int) -> list[float]
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 ].
linspace(start_in: float, end_in: float, num_in: int) -> list[float]
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 ].
- static lookAt(from: visp._visp.core.ColVector, to: visp._visp.core.ColVector, tmp: visp._visp.core.ColVector) visp._visp.core.HomogeneousMatrix ¶
Compute the transformation such that the camera located at from position looks toward to position.
<unparsed image <doxmlparser.compound.docImageType object at 0x7f422d576710>>
Right-handed coordinate system for OpenGL (figure from https://learnopengl.com/Getting-started/Coordinate-Systems ):
<unparsed image <doxmlparser.compound.docImageType object at 0x7f422d576b90>>
See also:
https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/lookat-function
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml
- 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.
- static maximum(*args, **kwargs)¶
Overloaded function.
maximum(a: int, b: int) -> int
- Parameters:
- a
First number.
- b
Second number.
- Returns:
The maximum of the two numbers.
maximum(a: float, b: float) -> float
- Parameters:
- a
First number.
- b
Second number.
- Returns:
The maximum of the two numbers.
- static minimum(*args, **kwargs)¶
Overloaded function.
minimum(a: int, b: int) -> int
- Parameters:
- a
First number.
- b
Second number.
- Returns:
The minimum of the two numbers.
minimum(a: float, b: float) -> float
- Parameters:
- a
First number.
- b
Second number.
- Returns:
The minimum of the two numbers.
- static modulo(*args, **kwargs)¶
Overloaded function.
modulo(value: float, modulo: float) -> float
Gives the rest of value divided by modulo when the quotient can only be an integer.
- Parameters:
- value
The value we want to know the rest in the “modulo” operation.
- modulo
The divider.
- Returns:
float The rest as in a modulo operation.
modulo(value: float, modulo: float) -> float
Gives the rest of value divided by modulo when the quotient can only be an integer.
- Parameters:
- value
The value we want to know the rest in the “modulo” operation.
- modulo
The divider.
- Returns:
double The rest as in a modulo operation.
modulo(a: int, n: int) -> int
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.
modulo(a: int, n: int) -> int
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.
- static msinc(sinx: float, x: float) float ¶
Compute \((1-sinc(x))/x^2\) with \(sinc(x) = sin(x) / x\) .
- static ned2ecef(lonDeg: float, latDeg: float, radius: float) visp._visp.core.HomogeneousMatrix ¶
Compute from a given longitude, latitude and a sphere radius the homogeneous transformation from the NED frame to the ECEF frame:
\[\begin{split}\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} \end{split}\]<unparsed image <doxmlparser.compound.docImageType object at 0x7f422d5447c0>>
See also:
Note
See enu2ecef() , getLocalTangentPlaneTransformations()
- static rad(*args, **kwargs)¶
Overloaded function.
rad(deg: float) -> float
- Parameters:
- deg
Angle in degrees.
- Returns:
Angle converted in radians.
rad(r: visp._visp.core.ColVector) -> visp._visp.core.ColVector
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.
- static sinc(*args, **kwargs)¶
Overloaded function.
sinc(x: float) -> float
Compute sinus cardinal \(\frac{sin(x)}{x}\) .
- Parameters:
- x
Value of x.
- Returns:
Sinus cardinal.
sinc(sinx: float, x: float) -> float
Compute sinus cardinal \(\frac{sin(x)}{x}\) .
- Parameters:
- sinx
Value of sin(x).
- x
Value of x.
- Returns:
Sinus cardinal.