Class SbMatrixd

java.lang.Object
com.openinventor.inventor.SbBasic
com.openinventor.inventor.SbMatrixd

public class SbMatrixd extends SbBasic
4x4 matrix class (double precision). 4x4 double precision matrix class/datatype. Although Open Inventor fields store only single precision values, for certain applications it is useful and convenient to be able to store and manipulate double precision values, for example, double precision coordinate data or values that will be used for further computation.

See SbMatrix for discussion of storage layout and usage of matrices.

SbMatrix, SbMatrix3, SbRotation, SbRotationd, SbVec2d, SbVec2f, SbVec2i32, SbVec2s, SbVec3d, SbVec3f, SbVec3i32, SbVec3s, SbVec4b, SbVec4d, SbVec4f, SbVec4i32, SbVec4s, SbVec4ub, SbVec4ui32, SbVec4us

  • Field Details

    • array

      public final double[] array
  • Constructor Details

    • SbMatrixd

      public SbMatrixd(double[] components)
    • SbMatrixd

      public SbMatrixd(double c0, double c1, double c2, double c3, double c4, double c5, double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, double c14, double c15)
    • SbMatrixd

      public SbMatrixd(SbMatrixd copyFrom)
    • SbMatrixd

      public SbMatrixd()
  • Method Details

    • setValue

      public void setValue(SbMatrixd copyFrom)
    • getValue

      public double[] getValue()
    • setValue

      public SbMatrixd setValue(double[] components, int startIndex)
    • setValue

      public SbMatrixd setValue(double[] components)
    • setValue

      public SbMatrixd setValue(double c0, double c1, double c2, double c3, double c4, double c5, double c6, double c7, double c8, double c9, double c10, double c11, double c12, double c13, double c14, double c15)
    • getValueAt

      public double getValueAt(int index)
    • setValueAt

      public void setValueAt(int index, double value)
    • setTransform

      public void setTransform(SbVec3d t, SbRotationd r, SbVec3d s)
      Composes the matrix based on a translation, rotation, and scale. A scale orientation value of (0,0,0,1) is used. The center point for scaling and rotation is (0,0,0).
    • toArray

      public static SbMatrixd[] toArray(long nativeArray, long length)
    • isInvertible

      public boolean isInvertible()
      Returns true if the matrix is invertible.
    • equals

      public boolean equals(SbMatrixd m, double tolerance)
      Equality comparison within given tolerance, for each component.
    • times

      public SbMatrixd times(SbMatrixd m2)
      Multiplies two matrices, returning a matrix result.
    • multiply

      public void multiply(SbMatrixd m)
      Post-multiplies the matrix by the given matrix (equivalent to multRight() method). Matrix is replaced by the resulting matrix.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • identity

      public static SbMatrixd identity()
      Returns an identity matrix.
    • factor

      public SbMatrixd.Factorization factor()
      Factors a matrix m into 5 pieces: m = r s r^ u t, where r^ means transpose of r, and r and u are rotations, s is a scale, and t is a translation. Any projection information is returned in proj.
    • setScale

      public void setScale(double s)
      Sets matrix to scale by given uniform factor.
    • det4

      public double det4()
      Returns determinant of entire matrix.
    • inverse

      public SbMatrixd inverse()
      Returns inverse of matrix. Results are undefined for singular matrices. Uses LU decomposition.
      Matrix is not modified.
    • scale

      public void scale(SbVec3d scaleFactor)
      Scales this matrice by the given vector.
    • translate

      public void translate(SbVec3d translation)
      Translates this matrice by the given vector.
    • setRotate

      public void setRotate(SbRotationd q)
      Sets matrix to rotate by given rotation.
    • det3

      public double det3()
      Returns determinant of upper-left 3x3 submatrix.
    • decompose

      public SbMatrixd.Decomposition decompose(SbVec3d center)
      Decomposes the matrix into a translation, rotation, scale, and scale orientation. Any projection information is discarded. The decomposition depends upon choice of center point for rotation and scaling, which is optional as the last parameter. Note that if the center is 0, decompose() is the same as factor() where t is translation, u is rotation, s is scaleFactor, and r is scaleOrientation.
    • setTransform

      public void setTransform(SbVec3d t, SbRotationd r, SbVec3d s, SbRotationd so)
      Composes the matrix based on a translation, rotation, scale, and orientation for scale. The scaleOrientation chooses the primary axes for the scale. The center point for scaling and rotation is (0,0,0).
    • setTransform

      public void setTransform(SbVec3d translation, SbRotationd rotation, SbVec3d scaleFactor, SbRotationd scaleOrientation, SbVec3d center)
      Composes the matrix based on a translation, rotation, scale, orientation for scale, and center. The scaleOrientation chooses the primary axes for the scale. The center is the center point for scaling and rotation.
    • setTranslate

      public void setTranslate(SbVec3d t)
      Sets matrix to translate by given vector.
    • setScale

      public void setScale(SbVec3d s)
      Sets matrix to scale by given vector.
    • det3

      public double det3(int r1, int r2, int r3, int c1, int c2, int c3)
      Returns determinant of 3x3 submatrix composed of given row and column indices (0-3 for each).
    • decompose

      public SbMatrixd.Decomposition decompose()
      Return translation, rotation, scale, and scale orientation components of the matrix.
    • multVec4Matrix

      public SbVec4d multVec4Matrix(SbVec3d src)
      Pre-multiplies matrix by the given row vector, giving vector result in homogeneous coordinates. Use this method to transform a point (position vector).
      Use multDirMatrix() to transform a normal (direction vector).

      Parameters:
      src - the source vector to transform

      dst - the destination vector to retrieve the result
    • multVecMatrix

      public SbVec3d multVecMatrix(SbVec3d src)
      Pre-multiplies matrix by the given row vector, giving a 3D vector result. The intermediate homogeneous (vec4) value is converted to 3D by dividing the X, Y and Z components by W.

      Use this method to transform a point (position vector).
      Use multDirMatrix() to transform a normal (direction vector).

    • multDirMatrix

      public SbVec3d multDirMatrix(SbVec3d src)
      Pre-multiplies the matrix by the given row vector, giving vector result. src is assumed to be a direction vector, so translation part of matrix is ignored.

      Note: If you need to transform surface points and normal vectors by a matrix, call multVecMatrix() for the points and call multDirMatrix() for the normals. Generally normals should be transformed by the inverse transpose of the matrix. However note that the inverse transpose is equal to the original matrix if the matrix is orthonormal, i.e. purely rotational with no scaling or shearing.

    • times

      public SbVec4d times(SbVec4d v)
      Multiply matrix by given vector. Return m * v
    • multLineMatrix

      public SbLined multLineMatrix(SbLined src)
      Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of the matrix.
    • multMatrixVec

      public SbVec3d multMatrixVec(SbVec3d src)
      Post-multiplies matrix by given column vector, giving a 3D vector result. The intermediate homogeneous (vec4) value is converted to 3D by dividing the X, Y and Z components by W.
    • makeIdentity

      public void makeIdentity()
      Sets matrix to be identity.
    • setValue

      public void setValue(SbMatrix m)
      Sets values from a single precision matrix.
    • multLeft

      public SbMatrixd multLeft(SbMatrixd m)
      Pre-multiplies the matrix by given matrix. Matrix is replaced by the result.
    • multRight

      public SbMatrixd multRight(SbMatrixd m)
      Post-multiplies the matrix by given matrix. Matrix is replaced by the result.
    • transpose

      public SbMatrixd transpose()
      Returns transpose of matrix. Matrix is not modified.