java.lang.Object
imagingbook.calibration.zhang.util.MathUtil
Utility math methods used for camera calibration.
- Version:
- 2022/12/19
-
Method Summary
Modifier and TypeMethodDescriptionstatic RealVector
static RealMatrix
fromRowPackedVector
(RealVector V, int rows, int columns) static RealVector
static double
inverseConditionNumber
(double[][] A) Calculates the 'inverse condition number' (RCOND() in Matlab) of the given matrix (0,...,1, ideally close to 1).static double[]
Lerp
(double[] t0, double[] t1, double alpha) Linearly interpolate two 3D translation vectors.static Quaternion
Lerp
(Quaternion Q0, Quaternion Q1, double alpha) Linearly interpolate twoQuaternion
instances.static Rotation
Linearly interpolate two 3DRotation
instances.static double
mean
(double[] x) static RealVector
Finds a nontrivial solution (x) to the homogeneous linear system A .static double[]
static double[]
toCartesian
(double[] ah) Converts a homogeneous vector to its equivalent Cartesian vector, which is one element shorter.static double[]
toHomogeneous
(double[] ac) Converts a Cartesian vector to an equivalent homogeneous vector by attaching an additional 1-element.static Pnt2d
toPnt2d
(double[] xy) static Quaternion
Converts aRotation
to aQuaternion
.static Rotation
Converts aQuaternion
to aRotation
.static double
variance
(double[] x) Returns the variance of the specified values.
-
Method Details
-
toArray
-
toPnt2d
-
crossProduct3x3
-
getRowPackedVector
-
fromRowPackedVector
-
solveHomogeneousSystem
Finds a nontrivial solution (x) to the homogeneous linear system A . x = 0 by singular-value decomposition. If A has more rows than columns, the system of equations is overdetermined. In this case the returned solution minimizes the residual ||A . x|| in the least-squares sense.- Parameters:
A
- the original matrix.- Returns:
- the solution vector x.
-
toHomogeneous
Converts a Cartesian vector to an equivalent homogeneous vector by attaching an additional 1-element. The resulting homogeneous vector is one element longer than the specified Cartesian vector. See alsotoCartesian(double[])
.- Parameters:
ac
- a Cartesian vector- Returns:
- an equivalent homogeneous vector
-
toCartesian
Converts a homogeneous vector to its equivalent Cartesian vector, which is one element shorter. See alsotoHomogeneous(double[])
.- Parameters:
ah
- a homogeneous vector- Returns:
- the equivalent Cartesian vector
- Throws:
DivideByZeroException
- if the last vector element is zero
-
mean
-
variance
Returns the variance of the specified values.- Parameters:
x
- a sequence of real values- Returns:
- the variance of the values in x (sigma^2)
-
toQuaternion
Converts aRotation
to aQuaternion
.- Parameters:
R
- a rotation- Returns:
- the corresponding quaternion
-
toRotation
Converts aQuaternion
to aRotation
.- Parameters:
q
- a quaternion- Returns:
- the associated rotation
-
Lerp
Linearly interpolate two 3DRotation
instances.- Parameters:
R0
- first rotationR1
- second rotationalpha
- the blending factor in [0,1]- Returns:
- the interpolated rotation
-
Lerp
Linearly interpolate twoQuaternion
instances.- Parameters:
Q0
- first quaternionQ1
- second quaternionalpha
- the blending factor in [0,1]- Returns:
- the interpolated quaternion
-
Lerp
Linearly interpolate two 3D translation vectors.- Parameters:
t0
- first translation vectort1
- second translation vectoralpha
- the blending factor in [0,1]- Returns:
- the interpolated translation vector
-
inverseConditionNumber
Calculates the 'inverse condition number' (RCOND() in Matlab) of the given matrix (0,...,1, ideally close to 1).- Parameters:
A
- the matrix- Returns:
- the inverse condition number
-