java.lang.Object
imagingbook.calibration.zhang.util.MathUtil
Utility math methods used for camera calibration.
- Version:
- 2022/12/19
-
Method Summary
Modifier and TypeMethodDescriptionstatic RealVectorstatic RealMatrixfromRowPackedVector(RealVector V, int rows, int columns) static RealVectorstatic doubleinverseConditionNumber(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 QuaternionLerp(Quaternion Q0, Quaternion Q1, double alpha) Linearly interpolate twoQuaternioninstances.static RotationLinearly interpolate two 3DRotationinstances.static doublemean(double[] x) static RealVectorFinds a nontrivial solution (x) to the homogeneous linear system A . x = 0 by singular-value decomposition.static double[]toArray(imagingbook.common.geometry.basic.Pnt2d p) 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 imagingbook.common.geometry.basic.Pnt2dtoPnt2d(double[] xy) static QuaternionConverts aRotationto aQuaternion.static RotationConverts aQuaternionto aRotation.static doublevariance(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
public static double[] toCartesian(double[] ah) throws imagingbook.common.math.exception.DivideByZeroException 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:
imagingbook.common.math.exception.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 aRotationto aQuaternion.- Parameters:
R- a rotation- Returns:
- the corresponding quaternion
-
toRotation
Converts aQuaternionto aRotation.- Parameters:
q- a quaternion- Returns:
- the associated rotation
-
Lerp
Linearly interpolate two 3DRotationinstances.- Parameters:
R0- first rotationR1- second rotationalpha- the blending factor in [0,1]- Returns:
- the interpolated rotation
-
Lerp
Linearly interpolate twoQuaternioninstances.- 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
-