java.lang.Object
imagingbook.calibration.zhang.util.MathUtil

public abstract class MathUtil extends Object
Utility math methods used for camera calibration.
Version:
2022/12/19
  • Method Details

    • toArray

      public static double[] toArray(Pnt2d p)
    • toPnt2d

      public static Pnt2d toPnt2d(double[] xy)
    • crossProduct3x3

    • getRowPackedVector

    • fromRowPackedVector

      public static RealMatrix fromRowPackedVector(RealVector V, int rows, int columns)
    • 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

      public static double[] toHomogeneous(double[] ac)
      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 also toCartesian(double[]).
      Parameters:
      ac - a Cartesian vector
      Returns:
      an equivalent homogeneous vector
    • toCartesian

      public static double[] toCartesian(double[] ah) throws DivideByZeroException
      Converts a homogeneous vector to its equivalent Cartesian vector, which is one element shorter. See also toHomogeneous(double[]).
      Parameters:
      ah - a homogeneous vector
      Returns:
      the equivalent Cartesian vector
      Throws:
      DivideByZeroException - if the last vector element is zero
    • mean

      public static double mean(double[] x)
    • variance

      public static double variance(double[] x)
      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

      public static Quaternion toQuaternion(Rotation R)
      Converts a Rotation to a Quaternion.
      Parameters:
      R - a rotation
      Returns:
      the corresponding quaternion
    • toRotation

      public static Rotation toRotation(Quaternion q)
      Converts a Quaternion to a Rotation.
      Parameters:
      q - a quaternion
      Returns:
      the associated rotation
    • Lerp

      public static Rotation Lerp(Rotation R0, Rotation R1, double alpha)
      Linearly interpolate two 3D Rotation instances.
      Parameters:
      R0 - first rotation
      R1 - second rotation
      alpha - the blending factor in [0,1]
      Returns:
      the interpolated rotation
    • Lerp

      public static Quaternion Lerp(Quaternion Q0, Quaternion Q1, double alpha)
      Linearly interpolate two Quaternion instances.
      Parameters:
      Q0 - first quaternion
      Q1 - second quaternion
      alpha - the blending factor in [0,1]
      Returns:
      the interpolated quaternion
    • Lerp

      public static double[] Lerp(double[] t0, double[] t1, double alpha)
      Linearly interpolate two 3D translation vectors.
      Parameters:
      t0 - first translation vector
      t1 - second translation vector
      alpha - the blending factor in [0,1]
      Returns:
      the interpolated translation vector
    • inverseConditionNumber

      public static double inverseConditionNumber(double[][] A)
      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