Public Member Functions | Static Public Member Functions | Public Attributes | List of all members

3x3 matrix commonly used for pure rotations, but in general may also have scales and non-perpendicular rows and columns. More...

#include <rotmatrix.h>

Public Member Functions

void InitIdentity ()
 Initialize an identity matrix. More...
 
void Zero ()
 returns a zero matrix. More...
 
void InitFromScale (double scale)
 Initializes a uniform scaling matrix. More...
 
void InitFromScaleFactors (double xscale, double yscale, double zscale)
 Returns a scaling matrix with respective x, y, and z scaling factors. More...
 
void ScaleRows (RotMatrixCR inMatrix, double xScale, double yScale, double zScale)
 Applies scale factors to corresponding rows of the input matrix, and places the result in this instance matrix. More...
 
void ScaleColumns (RotMatrixCR in, double xs, double ys, double zs)
 Applies scale factors to corresponding columns of the input matrix, and places the result in this instance matrix. More...
 
void ScaleColumns (double xs, double ys, double zs)
 Applies scale factors to corresponding columns. More...
 
void NormalizeRowsOf (RotMatrixCR inMatrix, DVec3dR scaleVector)
 Returns a matrix whose rows are unit vectors in the same drection as corresponding rows of the input matrix. More...
 
void NormalizeColumnsOf (RotMatrixCR inMatrix, DVec3dR scaleVector)
 Returns a matrix whose rows are unit vectors in the same drection as corresponding columns of the input matrix. More...
 
void Scale (RotMatrixCR leftMatrix, double xs, double ys, double zs, RotMatrixCR rightMatrix)
 Returns a matrix formed from a scaling matrix which is multiplied on the left and/or right with other matrices. More...
 
void InitFromScaledOuterProduct (DVec3dCR vectorU, DVec3dCR vectorV, double scale)
 Returns a 'rank one' matrix defined as a scale factor times the 'vector outer product' of two vectors, i.e. More...
 
void AddScaledOuterProductInPlace (DVec3dCR vectorU, DVec3dCR vectorV, double scale)
 Accumulates a 'rank one' matrix defined as a scale factor times the 'vector outer product' of two vectors, i.e. More...
 
void ShuffleColumnsOf (RotMatrixCR inMatrix, int i0, int i1, int i2)
 Moves columns 0, 1, 2 of the input matrix into columns i0, i1, i2 of the instance. More...
 
void InitFromRowValues (double x00, double x01, double x02, double x10, double x11, double x12, double x20, double x21, double x22)
 Initializes a matrix with the 9 specified coefficients given in "row major" order. More...
 
void InitFromRowValuesXY (double x00, double x01, double x10, double x11)
 Initializes a matrix with the 4 specified coefficients in xx,xy,yx,yy positions, and 1 in zz in "row major" order. More...
 
void InitFromRowValuesXY (double const data[4])
 Initializes a matrix with 4 coefficients in xx,xy,yx,yy positions, and 1 in zz in "row major" order. More...
 
void InitFromColumnVectors (DVec3dCR vectorU, DVec3dCR vectorV, DVec3dCR vectorW)
 Returns a matrix with 3 points copied to respective columns. More...
 
void InitFromRowVectors (DVec3dCR vectorU, DVec3dCR vectorV, DVec3dCR vectorW)
 Initializes a matrix with 3 points copied to respective rows. More...
 
void InitFromVectorAndRotationAngle (DVec3dCR axis, double radians)
 Initializes a matrix representing rotation around a vector. More...
 
void InitFromAxisAndRotationAngle (int axis, double radians)
 Returns a matrix of rotation about the x,y, or z axis (indicated by axis = 0,1, or 2) by an angle in radians. More...
 
bool InitRotationFromVectorToVector (DVec3dCR startVector, DVec3dCR endVector)
 (conditionally) initialize the instance as the (smallest) rotation that moves startVector so it is in the direction of endVector. More...
 
void InitFromDirectionAndScale (DVec3dCR vector, double scale)
 Initializes a matrix which scales along a vector direction. More...
 
void InitFromPrincipleAxisRotations (RotMatrixCR inMatrix, double xrot, double yrot, double zrot)
 Returns the product {RX*RY*RZ*M} where RX, RY, and RZ are rotations (in radians) around X, Y, and Z axes, and M is the input matrix. More...
 
bool InitFrom1Vector (DVec3dCR dir, int axis, bool normalize)
 Initializes this instance matrix so that the indicated axis (axis = 0,1,or 2) is aligned with the vector dir. More...
 
void InitFrom2Vectors (DVec3dCR xVector, DVec3dCR yVector)
 Copies vectors into the x and y columns of this instance matrix and sets the z column to their cross product. More...
 
bool InitRotationFromOriginXY (DPoint3dCR origin, DPoint3dCR xPoint, DPoint3dCR yPoint)
 Set this instance matrix to be an orthogonal (rotation) matrix with column 0 in the direction from the origin to the x point, column 1 in the plane of the 3 points, directed so the Y point on the positive side, and column 2 as their cross product. More...
 
bool SquareAndNormalizeColumns (RotMatrixCR inMatrix, int primaryAxis, int secondaryAxis)
 Adjust the direction and length of columns of the input matrix to produce an instance matrix which has perpendicular, unit length columns. More...
 
bool SquareAndNormalizeColumns (RotMatrixCR inMatrix, int primaryAxis, int secondaryAxis, int preferredOrientation)
 
bool SquareAndNormalizeColumnsAnyOrder (RotMatrixCR inMatrix, int preferredOrientation)
 Returns an orthogonal matrix that preserves aligns with the columns of inMatrix. More...
 
bool SquareAndNormalizeColumnsAnyOrder (RotMatrixCR inMatrix)
 Returns an orthogonal matrix that preserves aligns with the columns of inMatrix. More...
 
void InitFrom (TransformCR transform)
 Sets this instance matrix by copying the matrix part of the trasnform. More...
 
void Copy (RotMatrixCR in)
 Sets this instance matrix by copying from the matrix parameter. More...
 
void InitProduct (RotMatrixCR rotMatrixA, RotMatrixCR rotMatrixB)
 Returns the product {A*B} of two matrices. More...
 
void InitProduct (RotMatrixCR rotMatrixA, RotMatrixCR rotMatrixB, RotMatrixCR rotMatrixC)
 Returns the product of three matrices. More...
 
void InitProduct (RotMatrixCR rotMatrixA, TransformCR transformB)
 Sets this instance to the product of matrix rotMatrixA times the matrix part of transform transformB. More...
 
void InitProduct (TransformCR transformA, RotMatrixCR rotMatrixB)
 Returns to the product of the matrix part of transform transformA times matrix rotMatrixB. More...
 
void InitProductRotMatrixTransposeRotMatrix (RotMatrixCR rotMatrixA, RotMatrixCR rotMatrixB)
 Returns the product of the transpose of rotMatrixA times rotMatrixB. More...
 
void InitProductRotMatrixRotMatrixTranspose (RotMatrixCR rotMatrixA, RotMatrixCR rotMatrixB)
 Returns the product of rotMatrixA times the transpose of rotMatrixB. More...
 
void TransposeOf (RotMatrixCR matrix)
 Initializes this instance as the transpose of a matrix. More...
 
void Transpose ()
 Transposes a matrix in place. More...
 
void SumOf (RotMatrixCR matrix0, RotMatrixCR matrix1, double scale1, RotMatrixCR matrix2, double scale2)
 Returns {Matrix0 + Matrix1*s1+Matrix2*s2}, i.e. More...
 
void Add (RotMatrixCR delta)
 Add a matrix (componentwise, in place). More...
 
void Subtract (RotMatrixCR delta)
 Subtract a matrix (componentwise, in place). More...
 
bool InverseOf (RotMatrixCR forward)
 Returns the inverse of the a matrix. More...
 
bool Invert ()
 Inverts this instance matrix in place. More...
 
void Multiply (DPoint4dP result, DPoint4dCP point, int numPoint) const
 Computes {M*P[i]} where M is this instance matrix and each P[i] is a point in the input array point. More...
 
void Multiply (DPoint2dP result, DPoint2dCP point, int numPoint) const
 Computes {M*P[i]} where M is this instance matrix and each P[i] is a point in the input array point. More...
 
void Multiply (DRange3dR outRange, DRange3dCR inRange) const
 computes the 8 corner points of the range cube defined by the two points of pRange, multiplies matrix times each point, and computes the twopoint range limits (min max) of the resulting rotated box. More...
 
void Multiply (DPoint3dR point) const
 Computes the product {M*P} where M is this instance matrix and P the input point. More...
 
void Multiply (DPoint3dR result, DPoint3dCR point) const
 Returns the product of a matrix times a point. More...
 
void MultiplyTranspose (DPoint3dR result, DPoint3dCR point) const
 Returns the product of a matrix transpose times a point. More...
 
void MultiplyComponents (DPoint3dR result, double x, double y, double z) const
 Returns the product of a matrix times a point, with the point given as separate components. More...
 
void MultiplyTranspose (DPoint3dR point) const
 Computes the product {P*M} where M is this instance matrix and P is the input point The result overwrites the previous coordinates in the point. More...
 
void MultiplyTransposeComponents (DPoint3dR result, double x, double y, double z) const
 Returns the product P = [x,y,z]*M where M is the input matrix and P is the product point. More...
 
void Multiply (DPoint3dP result, DPoint3dCP point, int numPoint) const
 Computes {M*P[i]} where M is this instance matrix and each P[i] is a point in the input array point. More...
 
void MultiplyTranspose (DPoint3dP result, DPoint3dCP point, int numPoint) const
 Computes {P[i]*M} where M is this instance matrix and each P[i] is a point in the input array point, transposed into row form. More...
 
void Multiply (bvector< DPoint3d > &outXYZ, bvector< DPoint3d > const &inXYZ) const
 Description Multiply points. (Matrix on left, point on right as column vector) More...
 
void MultiplyTranspose (bvector< DPoint3d > &outXYZ, bvector< DPoint3d > const &inXYZ) const
 Multiply the transposed matrix times points. (Tranposed matrix on left, point on right as column vector. Or (equivalent) point on left as row vector, matrix on right) More...
 
void Multiply (bvector< DPoint2d > &out, bvector< DPoint2d > const &in) const
 Description Multiply 2D points. (Matrix on left, point on right as column vector) More...
 
void Multiply (bvector< DPoint4d > &xyzwOut, bvector< DPoint4d > const &xyzwIn) const
 Multiply xyzw, with matrix w row and column 0001. More...
 
bool SolveArray (bvector< DPoint3d > &xyzOut, bvector< DPoint3d > const &xyzIn) const
 Solve M*xyzOut[i] = xyzIn[i] for array of points. More...
 
bool Solve (DPoint3dR result, DPoint3dCR point) const
 Return the product of a matrix inverse and a point. More...
 
bool SolveTranspose (DPoint3dR result, DPoint3dCR point) const
 Return the product of a matrix inverse transpose and a point. More...
 
bool SolveArray (DPoint3dP result, DPoint3dCP point, int numPoints) const
 Solves the matrix equation AX=B, where A is this instance, B is the matrix of numPoints input points and X is the matrix of numPoints output points. More...
 
void GetColumns (DVec3dR vectorU, DVec3dR vectorV, DVec3dR vectorW) const
 Copies from columns of this instance matrix to corresponding points. More...
 
void GetRows (DVec3dR vectorU, DVec3dR vectorV, DVec3dR vectorW) const
 Copies from rows of this instance matrix to corresponding points. More...
 
void GetColumn (DVec3dR vector, int col) const
 Returns a point taken from a column of a matrix. More...
 
void GetRow (DVec3dR vector, int row) const
 Returns a vector taken from a column of a matrix. More...
 
void SetColumn (DVec3dCR vector, int col)
 Set the components in a column. More...
 
void SetRow (DVec3dCR vector, int row)
 Set the components in a row. More...
 
double GetComponentByRowAndColumn (int row, int col) const
 Returns a value from a specified row and column of the matrix. More...
 
void GetRowValues (double &x00, double &x01, double &x02, double &x10, double &x11, double &x12, double &x20, double &x21, double &x22) const
 Get all contents as individual doubles, moving along rows. More...
 
void GetRowValuesXY (double data[4]) const
 Copies 4 doubles from xx,xy,yx,yy positions into an array. More...
 
double Determinant () const
 Returns the determinant of the matrix. More...
 
double ConditionNumber () const
 Computes an estimate of the condition of this instance matrix. More...
 
bool IsIdentity () const
 Tests if a matrix is the identity matrix. More...
 
bool IsDiagonal () const
 Tests if a matrix has small offdiagonal entries compared to diagonals. More...
 
bool IsUniformScale (double &maxScale) const
 Tests if a matrix has (nearly) equal diagaonal entries and (nearly) zero off diagonals. More...
 
void DiagonalSignedRange (double &minValue, double &maxValue) const
 Return the (signed) range of entries on the diagonal. More...
 
void DiagonalAbsRange (double &minValue, double &maxValue) const
 Return the (absolute value) range of entries on the diagonal. More...
 
void OffDiagonalSignedRange (double &minValue, double &maxValue) const
 Return the (signed) range of entries off the diagonal. More...
 
void OffDiagonalAbsRange (double &minValue, double &maxValue) const
 Return the (absolute value) range of entries off the diagonal. More...
 
DRange1d LowerTriangleAbsRange ()
 return the range of absolute values strictly below the diagonal. More...
 
DRange1d UpperTriangleAbsRange ()
 return the range of absolute values strictly above the diagonal. More...
 
DRange1d DiagonalAbsRange ()
 return the range of absolute values on the diagonal. More...
 
double LowerTriangleMaxAbs ()
 return the largest absolute value in the lower triangle. More...
 
double UpperTriangleMaxAbs ()
 return the largest absolute value in the upper triangle. More...
 
double DiagonalMaxAbs ()
 return the largest absolute value on the diagonal More...
 
double SumSquares () const
 Return the sum of squares of coefficients in a matrix. More...
 
double MaxAbs () const
 Find the largest absolute value of entries in the matrix. More...
 
double MaxDiff (RotMatrixCR matrix2) const
 Returns the largest absolute value difference between corresponding coefficients in Matrix1 and Matrix2. More...
 
double SumDiagonalSquares () const
 Computes the sum of the squares of the diagonal entries of this instance matrix. More...
 
double SumOffDiagonalSquares () const
 Computes the sum of the squares of the off-diagonal entries of this instance matrix. More...
 
bool IsSignedPermutation () const
 Test if this instance matrix does nothing more than exchange and possibly negate principle axes. More...
 
bool IsNearSignedPermutation (RotMatrixR result, double tolerance) const
 Test if this instance matrix does nothing more than exchange and possibly negate principle axes, within a tolerance. More...
 
bool IsRigid () const
 Test if a matrix is a rigid body rotation, i.e. More...
 
bool IsOrthogonal () const
 Test if this instance matrix is orthogonal, i.e. More...
 
bool IsOrthonormal (RotMatrixR columns, DVec3dR axisScales, double &axisRatio) const
 Test if this instance matrix has orthonormal columns, i.e. More...
 
bool IsRigidScale (RotMatrixR columns, double &scale) const
 Test if this instance matrix is composed of only rigid rotation and scaling. More...
 
bool IsNearRigidScale (RotMatrixR dest, int primaryAxis=0, double tolerance=1.0e-6) const
 Determine if a matrix is close to a pure rotate and scale. More...
 
bool IsPlanar (DVec3dCR normal) const
 Tests if this instance matrix has no effects perpendicular to any plane with the given normal. More...
 
bool IsEqual (RotMatrixCR matrix2) const
 Tests for equality between two matrices "Equality" means relative error less than 1.0e-12, in the sense that each component-wise difference is less than 1.0e-12 times the largest absolute value of the components of one matrix. More...
 
bool IsEqual (RotMatrixCR matrix2, double tolerance) const
 Tests for equality between two matrices. More...
 
int FactorRotateScaleRotate (RotMatrixR rotation1, DPoint3dR scalePoint, RotMatrixR rotation2) const
 Factor as {rotation1 * scale * rotation2}. More...
 
bool RotateAndSkewFactors (RotMatrixR rotation, RotMatrixR skewFactor, int primaryAxis, int secondaryAxis) const
 Factor as {rotation*skewFactor} where the rotation favors indicated primary and secondary axes. More...
 
bool FactorOrthogonalColumns (RotMatrixR matrixB, RotMatrixR matrixV) const
 Factor the instance as a product B*V^ where B has mutually perpendicular columns and V is orthogonal. More...
 
void InitFromQuaternion (DPoint4dCR quat)
 
void InitFromQuaternion (const double *pQuatAsDoubleArray)
 
void InitTransposedFromQuaternionWXYZ (const double *pQuatAsDoubleArray)
 Initialization, compatible with mdlRMatrix_fromQuat. More...
 
void GetQuaternion (DPoint4dR quat, bool transpose) const
 
void GetQuaternion (double *pQuatAsDoubleArray, bool transpose) const
 
double GetRotationAngleAndVector (DVec3dR axis) const
 Returns the angle of rotation of this instance and sets axis to be the normalized vector about which this instance rotates. More...
 
double ColumnXAngleXY () const
 Returns the (0 or positive) angle from (1,0) to the XY vector in the first column. More...
 
void GivensRowOp (double c, double s, int i0, int i1)
 Apply a Givens "row operation", i.e. More...
 
void GivensColumnOp (double c, double s, int i0, int i1)
 Apply a Givens "column operation", i.e. More...
 
void HyperbolicRowOp (double secant, double tangent, int i0, int i1)
 Apply a hyperbolic "row operation", i.e. More...
 
void HyperbolicColumnOp (double secant, double tangent, int i0, int i1)
 Apply a hyperbolic "column operation", i.e. More...
 

Static Public Member Functions

static RotMatrix FromIdentity ()
 Returns an identity matrix. More...
 
static RotMatrix FromScale (double scale)
 Returns a uniform scaling matrix. More...
 
static RotMatrix FromScaleFactors (double xscale, double yscale, double zscale)
 Returns a scaling matrix with respective x, y, and z scaling factors. More...
 
static RotMatrix FromScaledOuterProduct (DVec3dCR vectorU, DVec3dCR vectorV, double scale)
 Returns a 'rank one' matrix defined as a scale factor times the 'vector outer product' of two vectors, i.e. More...
 
static RotMatrix FromRowValues (double x00, double x01, double x02, double x10, double x11, double x12, double x20, double x21, double x22)
 Returns a matrix with the 9 specified coefficients given in "row major" order. More...
 
static RotMatrix FromColumnVectors (DVec3dCR vectorU, DVec3dCR vectorV, DVec3dCR vectorW)
 Returns a matrix with 3 vectors copied to respective columns. More...
 
static RotMatrix FromRowVectors (DVec3dCR vectorU, DVec3dCR vectorV, DVec3dCR vectorW)
 Returns a matrix with 3 vectors copied to respective rows. More...
 
static RotMatrix FromVectorAndRotationAngle (DVec3dCR axis, double radians)
 Returns a matrix representing rotation around a vector. More...
 
static RotMatrix FromVectorAndRotationAngle (DVec3dCR axis, double radians, RotMatrixR derivativeMatrix)
 Returns a matrix representing rotation around a vector. More...
 
static RotMatrix FromAxisAndRotationAngle (int axis, double radians)
 Returns a matrix of rotation about the x,y, or z axis (indicated by axis = 0,1, or 2) by an angle in radians. More...
 
static RotMatrix FromRotate90 (DVec3dCR axis)
 Return a matrix for retation of 90 degrees about a vector. More...
 
static RotMatrix FromDirectionAndScale (DVec3dCR vector, double scale)
 Returns a matrix which scales along a vector direction. More...
 
static RotMatrix FromPrincipleAxisRotations (RotMatrixCR inMatrix, double xrot, double yrot, double zrot)
 Returns the product {RX*RY*RZ*M} where RX, RY, and RZ are rotations (in radians) around X, Y, and Z axes, and M is the input matrix. More...
 
static RotMatrix From1Vector (DVec3dCR dir, int axis, bool normalize)
 Initializes this instance matrix so that the indicated axis (axis = 0,1,or 2) is aligned with the vector dir. More...
 
static RotMatrix From2Vectors (DVec3dCR xVector, DVec3dCR yVector)
 Returns a matrix copying vectors into the x and y columns of this instance matrix and sets the z column to their cross product. More...
 
static RotMatrix RotationFromOriginXY (DPoint3dCR origin, DPoint3dCR xPoint, DPoint3dCR yPoint)
 Set this instance matrix to be an orthogonal (rotation) matrix with column 0 in the direction from the origin to the x point, column 1 in the plane of the 3 points, directed so the Y point on the positive side, and column 2 as their cross product. More...
 
static RotMatrix From (TransformCR transform)
 Returns a matrix copying the matrix part of the trasnform. More...
 
static RotMatrix FromTransposeOf (RotMatrixCR matrix)
 Return (as function value) the transpose of a matrix. More...
 
static RotMatrix FromQuaternion (DPoint4dCR quat)
 
static RotMatrix FromQuaternion (const double *pQuatAsDoubleArray)
 

Public Attributes

double form3d [3][3]
 matrix coefficients. These are public, but direct use of the arrays is discouraged. More...
 

Detailed Description

3x3 matrix commonly used for pure rotations, but in general may also have scales and non-perpendicular rows and columns.

Member Function Documentation

void Add ( RotMatrixCR  delta)

Add a matrix (componentwise, in place).

Parameters
[in]deltaThe matrix to add
void AddScaledOuterProductInPlace ( DVec3dCR  vectorU,
DVec3dCR  vectorV,
double  scale 
)

Accumulates a 'rank one' matrix defined as a scale factor times the 'vector outer product' of two vectors, i.e.

as the matrix {s*U*V^T}

Parameters
[in]vectorUThe column vector U
[in]vectorVThe row vector V
[in]scaleThe scale factor
double ColumnXAngleXY ( ) const

Returns the (0 or positive) angle from (1,0) to the XY vector in the first column.

Returns
rotation angle (in radians) between 0 and 2Pi
double ConditionNumber ( ) const

Computes an estimate of the condition of this instance matrix.

Values near 0 are bad.

Returns
estimated condition number.
void Copy ( RotMatrixCR  in)

Sets this instance matrix by copying from the matrix parameter.

Parameters
[in]inThe source matrix
double Determinant ( ) const

Returns the determinant of the matrix.

Returns
determinant of the matrix.
void DiagonalAbsRange ( double &  minValue,
double &  maxValue 
) const

Return the (absolute value) range of entries on the diagonal.

Parameters
[out]minValuesmallest absolute value
[out]maxValuelargest absolute value
DRange1d DiagonalAbsRange ( )

return the range of absolute values on the diagonal.

double DiagonalMaxAbs ( )

return the largest absolute value on the diagonal

void DiagonalSignedRange ( double &  minValue,
double &  maxValue 
) const

Return the (signed) range of entries on the diagonal.

Parameters
[out]minValuesmallest signed value
[out]maxValuelargest signed value
bool FactorOrthogonalColumns ( RotMatrixR  matrixB,
RotMatrixR  matrixV 
) const

Factor the instance as a product B*V^ where B has mutually perpendicular columns and V is orthogonal.

Parameters
[out]matrixBorthogonal columns
[out]matrixVtranspose of right factor. (I.e. B = A*V)
int FactorRotateScaleRotate ( RotMatrixR  rotation1,
DPoint3dR  scalePoint,
RotMatrixR  rotation2 
) const

Factor as {rotation1 * scale * rotation2}.

Returns
number of nonzero scales (independent columns).
Parameters
[out]rotation1pure rotation
[out]scalePointscale factors, largest first.
[out]rotation2pure rotation
static RotMatrix From ( TransformCR  transform)
static

Returns a matrix copying the matrix part of the trasnform.

Parameters
[in]transformThe transformation whose matrix part is returned
static RotMatrix From1Vector ( DVec3dCR  dir,
int  axis,
bool  normalize 
)
static

Initializes this instance matrix so that the indicated axis (axis = 0,1,or 2) is aligned with the vector dir.

The normalize flag selects between normalized axes (all matrix columns of unit length) and unnormalized axes (all matrix columns of same length as the dir vector).

Parameters
[in]dirThe fixed direction vector
[in]axisThe axis column to be aligned with direction
[in]normalizetrue to have normalized columns
Returns
true if the direction vector is nonzero.
static RotMatrix From2Vectors ( DVec3dCR  xVector,
DVec3dCR  yVector 
)
static

Returns a matrix copying vectors into the x and y columns of this instance matrix and sets the z column to their cross product.

Use squareAndNormalizeColumns to force these (possibly skewed and scaled) coordinate axes to be perpendicular

Parameters
[in]xVectorThe vector to place in column 0
[in]yVectorThe vector to place in column 1
static RotMatrix FromAxisAndRotationAngle ( int  axis,
double  radians 
)
static

Returns a matrix of rotation about the x,y, or z axis (indicated by axis = 0,1, or 2) by an angle in radians.

Parameters
[in]axisThe axis index 0=x, 1=y, 2=z
[in]radiansThe rotation angle in radians
static RotMatrix FromColumnVectors ( DVec3dCR  vectorU,
DVec3dCR  vectorV,
DVec3dCR  vectorW 
)
static

Returns a matrix with 3 vectors copied to respective columns.

Parameters
[in]vectorUThe vector to insert in column 0
[in]vectorVThe vector to insert in column 1
[in]vectorWThe vector to insert in column 2
static RotMatrix FromDirectionAndScale ( DVec3dCR  vector,
double  scale 
)
static

Returns a matrix which scales along a vector direction.

Parameters
[in]vectorThe scaling direction
[in]scaleThe scale factor
static RotMatrix FromIdentity ( )
static

Returns an identity matrix.

static RotMatrix FromPrincipleAxisRotations ( RotMatrixCR  inMatrix,
double  xrot,
double  yrot,
double  zrot 
)
static

Returns the product {RX*RY*RZ*M} where RX, RY, and RZ are rotations (in radians) around X, Y, and Z axes, and M is the input matrix.

Parameters
[in]inMatrixThe prior matrix
[in]xrotThe x axis rotation
[in]yrotThe y axis rotation
[in]zrotThe z axis rotation
static RotMatrix FromQuaternion ( DPoint4dCR  quat)
static
Parameters
[in]quatThe quaternion, stored as (xyzw)
static RotMatrix FromQuaternion ( const double *  pQuatAsDoubleArray)
static
Parameters
[in]pQuatAsDoubleArrayThe quaternion, stored as (w,x,y,z) in an array of doubles.
static RotMatrix FromRotate90 ( DVec3dCR  axis)
static

Return a matrix for retation of 90 degrees about a vector.

static RotMatrix FromRowValues ( double  x00,
double  x01,
double  x02,
double  x10,
double  x11,
double  x12,
double  x20,
double  x21,
double  x22 
)
static

Returns a matrix with the 9 specified coefficients given in "row major" order.

Parameters
[in]x00The 00 entry
[in]x01The 01 entry
[in]x02The 02 entry
[in]x10The 10 entry
[in]x11The 11 entry
[in]x12The 12 entry
[in]x20The 20 entry
[in]x21The 21 entry
[in]x22The 22 entry
static RotMatrix FromRowVectors ( DVec3dCR  vectorU,
DVec3dCR  vectorV,
DVec3dCR  vectorW 
)
static

Returns a matrix with 3 vectors copied to respective rows.

Parameters
[in]vectorUThe vector to insert in row 0
[in]vectorVThe vector to insert in row 1
[in]vectorWThe vector to insert in row 2
static RotMatrix FromScale ( double  scale)
static

Returns a uniform scaling matrix.

Parameters
[in]scaleThe scale factor.
static RotMatrix FromScaledOuterProduct ( DVec3dCR  vectorU,
DVec3dCR  vectorV,
double  scale 
)
static

Returns a 'rank one' matrix defined as a scale factor times the 'vector outer product' of two vectors, i.e.

as the matrix {s*U*V^T}

Parameters
[in]vectorUThe column vector U
[in]vectorVThe row vector V
[in]scaleThe scale factor
static RotMatrix FromScaleFactors ( double  xscale,
double  yscale,
double  zscale 
)
static

Returns a scaling matrix with respective x, y, and z scaling factors.

Parameters
[in]xscaleThe x direction scale factor (00 diagonal)
[in]yscaleThe y direction scale factor (11 diagonal)
[in]zscaleThe z direction scale factor (22 diagonal)
static RotMatrix FromTransposeOf ( RotMatrixCR  matrix)
static

Return (as function value) the transpose of a matrix.

Parameters
[in]matrixThe input matrix
static RotMatrix FromVectorAndRotationAngle ( DVec3dCR  axis,
double  radians 
)
static

Returns a matrix representing rotation around a vector.

Parameters
[in]axisThe axis of rotation
[in]radiansThe rotation angle
static RotMatrix FromVectorAndRotationAngle ( DVec3dCR  axis,
double  radians,
RotMatrixR  derivativeMatrix 
)
static

Returns a matrix representing rotation around a vector.

Also returns its derivatives with respect to the angle.

Parameters
[in]axisThe axis of rotation
[in]radiansThe rotation angle
[out]derivativeMatrixderivative of returned matrix.
void GetColumn ( DVec3dR  vector,
int  col 
) const

Returns a point taken from a column of a matrix.

Parameters
[out]vectorfilled vector
[in]colThe index of column to extract. Column indices are 0, 1, 2.
void GetColumns ( DVec3dR  vectorU,
DVec3dR  vectorV,
DVec3dR  vectorW 
) const

Copies from columns of this instance matrix to corresponding points.

Parameters
[out]vectorUfirst column
[out]vectorVsecond column
[out]vectorWthird column
double GetComponentByRowAndColumn ( int  row,
int  col 
) const

Returns a value from a specified row and column of the matrix.

Parameters
[in]rowThe index of row to read. Row indices are 0, 1, 2.
[in]colThe index of column to read. Column indices are 0, 1, 2.
void GetQuaternion ( DPoint4dR  quat,
bool  transpose 
) const
Parameters
[out]quatquaternion, stored as xyzw
[in]transposetrue if matrix is stored transposed
void GetQuaternion ( double *  pQuatAsDoubleArray,
bool  transpose 
) const
Parameters
[out]pQuatAsDoubleArrayquaternion, stored as (w,x,y,z) in an array of doubles.
[in]transposetrue if matrix is stored transposed
double GetRotationAngleAndVector ( DVec3dR  axis) const

Returns the angle of rotation of this instance and sets axis to be the normalized vector about which this instance rotates.

NOTE: this instance is assumed to be a (rigid body, i.e. orthogonal) rotation matrix. Since negating both angle and axis produces an identical rotation, calculations are simplified by assuming (and returning) the angle in [0,Pi].

Parameters
[out]axisnormalized axis of rotation
Returns
rotation angle (in radians) between 0 and Pi, inclusive
void GetRow ( DVec3dR  vector,
int  row 
) const

Returns a vector taken from a column of a matrix.

Parameters
[out]vectorfilled vector
[in]rowThe index of row to extract. Row indices are 0, 1, and 2.
void GetRows ( DVec3dR  vectorU,
DVec3dR  vectorV,
DVec3dR  vectorW 
) const

Copies from rows of this instance matrix to corresponding points.

Parameters
[out]vectorUfirst row
[out]vectorVsecond row
[out]vectorWthird row
void GetRowValues ( double &  x00,
double &  x01,
double &  x02,
double &  x10,
double &  x11,
double &  x12,
double &  x20,
double &  x21,
double &  x22 
) const

Get all contents as individual doubles, moving along rows.

void GetRowValuesXY ( double  data[4]) const

Copies 4 doubles from xx,xy,yx,yy positions into an array.

Parameters
[out]datareturned data – first 2 entries in row 0, then first 2 in row 1.
void GivensColumnOp ( double  c,
double  s,
int  i0,
int  i1 
)

Apply a Givens "column operation", i.e.

post-multiply by a Givens rotation matrix. The Givens matrix is an identity except for the 4 rotational entries, viz R(i0,i0)=R(i1,i1)=c R(i0,i1)=-s R(i1,i0)=s

Parameters
[in]cThe cosine of givens rotation.
[in]sThe sine of givens rotation.
[in]i0The index of the first affected row.
[in]i1The index of the second affected row.
void GivensRowOp ( double  c,
double  s,
int  i0,
int  i1 
)

Apply a Givens "row operation", i.e.

pre-multiply by a Givens rotation matrix. The Givens matrix is an identity except for the 4 rotational entries, viz R(i0,i0)=R(i1,i1)=c R(i0,i1)=s R(i1,i0)=-s

Parameters
[in]cThe cosine of givens rotation.
[in]sThe sine of givens rotation.
[in]i0The index of the first affected row.
[in]i1The index of the second affected row.
void HyperbolicColumnOp ( double  secant,
double  tangent,
int  i0,
int  i1 
)

Apply a hyperbolic "column operation", i.e.

pre-multiply by a hyperbolic reflection matrix The matrix is an identity except for the 4 entries R(i0,i0)=R(i1,i1)=secant R(i0,i1)=R(i1,i0)=tangent

Parameters
[in]secantThe cosine of reflection.
[in]tangentThe sine of reflection.
[in]i0The index of the first affected row.
[in]i1The index of the second affected row.
void HyperbolicRowOp ( double  secant,
double  tangent,
int  i0,
int  i1 
)

Apply a hyperbolic "row operation", i.e.

pre-multiply by a hyperbolic reflection matrix The matrix is an identity except for the 4 entries R(i0,i0)=R(i1,i1)=secant R(i0,i1)=R(i1,i0)=tangent

Parameters
[in]secantThe cosine of reflection.
[in]tangentThe sine of reflection.
[in]i0The index of the first affected row.
[in]i1The index of the second affected row.
void InitFrom ( TransformCR  transform)

Sets this instance matrix by copying the matrix part of the trasnform.

Parameters
[in]transformThe transformation whose matrix part is returned
bool InitFrom1Vector ( DVec3dCR  dir,
int  axis,
bool  normalize 
)

Initializes this instance matrix so that the indicated axis (axis = 0,1,or 2) is aligned with the vector dir.

The normalize flag selects between normalized axes (all matrix columns of unit length) and unnormalized axes (all matrix columns of same length as the dir vector).

Parameters
[in]dirThe fixed direction vector
[in]axisThe axis column to be aligned with direction
[in]normalizetrue to have normalized columns
Returns
true if the direction vector is nonzero.
void InitFrom2Vectors ( DVec3dCR  xVector,
DVec3dCR  yVector 
)

Copies vectors into the x and y columns of this instance matrix and sets the z column to their cross product.

Use squareAndNormalizeColumns to force these (possibly skewed and scaled) coordinate axes to be perpendicular

Parameters
[in]xVectorThe vector to place in column 0
[in]yVectorThe vector to place in column 1
void InitFromAxisAndRotationAngle ( int  axis,
double  radians 
)

Returns a matrix of rotation about the x,y, or z axis (indicated by axis = 0,1, or 2) by an angle in radians.

Parameters
[in]axisThe axis index 0=x, 1=y, 2=z
[in]radiansThe rotation angle in radians
void InitFromColumnVectors ( DVec3dCR  vectorU,
DVec3dCR  vectorV,
DVec3dCR  vectorW 
)

Returns a matrix with 3 points copied to respective columns.

Parameters
[in]vectorUThe vector to insert in column 0
[in]vectorVThe vector to insert in column 1
[in]vectorWThe vector to insert in column 2
void InitFromDirectionAndScale ( DVec3dCR  vector,
double  scale 
)

Initializes a matrix which scales along a vector direction.

Parameters
[in]vectorThe scaling direction
[in]scaleThe scale factor
void InitFromPrincipleAxisRotations ( RotMatrixCR  inMatrix,
double  xrot,
double  yrot,
double  zrot 
)

Returns the product {RX*RY*RZ*M} where RX, RY, and RZ are rotations (in radians) around X, Y, and Z axes, and M is the input matrix.

Parameters
[in]inMatrixThe prior matrix
[in]xrotThe x axis rotation
[in]yrotThe y axis rotation
[in]zrotThe z axis rotation
void InitFromQuaternion ( DPoint4dCR  quat)
Parameters
[in]quatThe quaternion, stored as (xyzw)
void InitFromQuaternion ( const double *  pQuatAsDoubleArray)
Parameters
[in]pQuatAsDoubleArrayThe quaternion, stored as (w,x,y,z) in an array of doubles.
void InitFromRowValues ( double  x00,
double  x01,
double  x02,
double  x10,
double  x11,
double  x12,
double  x20,
double  x21,
double  x22 
)

Initializes a matrix with the 9 specified coefficients given in "row major" order.

Parameters
[in]x00The 00 entry
[in]x01The 01 entry
[in]x02The 02 entry
[in]x10The 10 entry
[in]x11The 11 entry
[in]x12The 12 entry
[in]x20The 20 entry
[in]x21The 21 entry
[in]x22The 22 entry
void InitFromRowValuesXY ( double  x00,
double  x01,
double  x10,
double  x11 
)

Initializes a matrix with the 4 specified coefficients in xx,xy,yx,yy positions, and 1 in zz in "row major" order.

Parameters
[in]x00The 00 entry
[in]x01The 01 entry
[in]x10The 10 entry
[in]x11The 11 entry
void InitFromRowValuesXY ( double const  data[4])

Initializes a matrix with 4 coefficients in xx,xy,yx,yy positions, and 1 in zz in "row major" order.

Parameters
[in]datamatrix entries in order xx,xy,yx,yy
void InitFromRowVectors ( DVec3dCR  vectorU,
DVec3dCR  vectorV,
DVec3dCR  vectorW 
)

Initializes a matrix with 3 points copied to respective rows.

Parameters
[in]vectorUThe vector to insert in row 0
[in]vectorVThe vector to insert in row 1
[in]vectorWThe vector to insert in row 2
void InitFromScale ( double  scale)

Initializes a uniform scaling matrix.

Parameters
[in]scaleThe scale factor.
void InitFromScaledOuterProduct ( DVec3dCR  vectorU,
DVec3dCR  vectorV,
double  scale 
)

Returns a 'rank one' matrix defined as a scale factor times the 'vector outer product' of two vectors, i.e.

as the matrix {s*U*V^T}

Parameters
[in]vectorUThe column vector U
[in]vectorVThe row vector V
[in]scaleThe scale factor
void InitFromScaleFactors ( double  xscale,
double  yscale,
double  zscale 
)

Returns a scaling matrix with respective x, y, and z scaling factors.

Parameters
[in]xscaleThe x direction scale factor
[in]yscaleThe y direction scale factor
[in]zscaleThe z direction scale factor
void InitFromVectorAndRotationAngle ( DVec3dCR  axis,
double  radians 
)

Initializes a matrix representing rotation around a vector.

Parameters
[in]axisThe axis of rotation
[in]radiansThe rotation angle
void InitIdentity ( )

Initialize an identity matrix.

void InitProduct ( RotMatrixCR  rotMatrixA,
RotMatrixCR  rotMatrixB 
)

Returns the product {A*B} of two matrices.

Parameters
[in]rotMatrixAThe first factor
[in]rotMatrixBThe second factor
void InitProduct ( RotMatrixCR  rotMatrixA,
RotMatrixCR  rotMatrixB,
RotMatrixCR  rotMatrixC 
)

Returns the product of three matrices.

Parameters
[in]rotMatrixAThe first factor
[in]rotMatrixBThe second factor
[in]rotMatrixCThe third factor
void InitProduct ( RotMatrixCR  rotMatrixA,
TransformCR  transformB 
)

Sets this instance to the product of matrix rotMatrixA times the matrix part of transform transformB.

In this 'post multiplication' the matrix part of transformB multiplies rotMatrixA ON THE RIGHT and the translation part of transformB is ignored.

Parameters
[in]rotMatrixAThe first factor (matrix)
[in]transformBThe second factor (transform)
void InitProduct ( TransformCR  transformA,
RotMatrixCR  rotMatrixB 
)

Returns to the product of the matrix part of transform transformA times matrix rotMatrixB.

In this 'pre multiplication' the matrix part of transformA multiplies rotMatrixB ON THE LEFT and the translation part of transformA is ignored.

Parameters
[in]transformAThe first factor (transform)
[in]rotMatrixBThe second factor (matrix)
void InitProductRotMatrixRotMatrixTranspose ( RotMatrixCR  rotMatrixA,
RotMatrixCR  rotMatrixB 
)

Returns the product of rotMatrixA times the transpose of rotMatrixB.

Parameters
[in]rotMatrixAThe first factor
[in]rotMatrixBThe second factor (to be transposed)
void InitProductRotMatrixTransposeRotMatrix ( RotMatrixCR  rotMatrixA,
RotMatrixCR  rotMatrixB 
)

Returns the product of the transpose of rotMatrixA times rotMatrixB.

Parameters
[in]rotMatrixAThe first factor (to be transposed)
[in]rotMatrixBThe second factor
bool InitRotationFromOriginXY ( DPoint3dCR  origin,
DPoint3dCR  xPoint,
DPoint3dCR  yPoint 
)

Set this instance matrix to be an orthogonal (rotation) matrix with column 0 in the direction from the origin to the x point, column 1 in the plane of the 3 points, directed so the Y point on the positive side, and column 2 as their cross product.

Parameters
[in]originThe reference point
[in]xPointThe x axis target point
[in]yPointThe 3rd point defining xy plane.
bool InitRotationFromVectorToVector ( DVec3dCR  startVector,
DVec3dCR  endVector 
)

(conditionally) initialize the instance as the (smallest) rotation that moves startVector so it is in the direction of endVector.

In the normal case where the vectors are not parallel or antiparallel, this is a rotation around their cross product.

Returns
false if one or both are zero vectors.
Remarks
if the vectors are direction opposite, the rotation is around an arbitrarily
Parameters
[in]startVectorstarting vector
[in]endVectorending vector.
void InitTransposedFromQuaternionWXYZ ( const double *  pQuatAsDoubleArray)

Initialization, compatible with mdlRMatrix_fromQuat.

Parameters
[in]pQuatAsDoubleArrayThe quaternion, stored as (w,x,y,z) in an array of doubles.
bool InverseOf ( RotMatrixCR  forward)

Returns the inverse of the a matrix.

Parameters
[in]forwardThe input matrix
Returns
true if the matrix is invertible.
bool Invert ( )

Inverts this instance matrix in place.

Returns
true if the matrix is invertible.
bool IsDiagonal ( ) const

Tests if a matrix has small offdiagonal entries compared to diagonals.

The specific test condition is that the largest off diagonal absolute value is less than a tight tolerance fraction times the largest diagonal entry.

Returns
true if matrix is approximately diagonal
bool IsEqual ( RotMatrixCR  matrix2) const

Tests for equality between two matrices "Equality" means relative error less than 1.0e-12, in the sense that each component-wise difference is less than 1.0e-12 times the largest absolute value of the components of one matrix.

Parameters
[in]matrix2The second matrix
Returns
true if the matrices are identical.
bool IsEqual ( RotMatrixCR  matrix2,
double  tolerance 
) const

Tests for equality between two matrices.

Parameters
[in]matrix2The second matrix
[in]toleranceThe relative error tolerance. Absolute tolerance is this (relative) tolerance times the largest absolute value in Matrix1.
Returns
true if the matrices are identical within tolerance.
bool IsIdentity ( ) const

Tests if a matrix is the identity matrix.

Returns
true if matrix is approximately an identity.
bool IsNearRigidScale ( RotMatrixR  dest,
int  primaryAxis = 0,
double  tolerance = 1.0e-6 
) const

Determine if a matrix is close to a pure rotate and scale.

If source is not near rigid, return false and copy to the output. If near an identity return identity. If nearly perpendicular with scales other than 1, clean preserving the length and direction of the primary axis. This is intended to be used with a crude (e.g. 1.0e-6) reltol to identify old DGN file matrices that are "dirty" by modern standards but were meant to be identity, rotation, or scaled rotations in the UOR era.

Parameters
[in]destresult matrix
[in]primaryAxisaxis whose orientation and direction is preserved.
[in]tolerancerelative tolerance for recognizing near-perpendicular conditions.
bool IsNearSignedPermutation ( RotMatrixR  result,
double  tolerance 
) const

Test if this instance matrix does nothing more than exchange and possibly negate principle axes, within a tolerance.

Parameters
[out]resultthe nearby permutation, or the orignal matrix if none near.
[in]tolerancetolerance for comparison to the permutation
Returns
true if the matrix is a near permutation of the principle axes.
bool IsOrthogonal ( ) const

Test if this instance matrix is orthogonal, i.e.

its transpose is its inverse. This class of matrices includes both rigid body rotations and reflections.

Returns
true if the matrix is orthogonal.
bool IsOrthonormal ( RotMatrixR  columns,
DVec3dR  axisScales,
double &  axisRatio 
) const

Test if this instance matrix has orthonormal columns, i.e.

its columns are all perpendicular to one another.

Parameters
[out]columnsmatrix containing the unit vectors along the columns.
[out]axisScalespoint whose x, y, and z components are the magnitudes of the original columns.
[out]axisRatiosmallest axis length divided by largest.
Returns
true if the matrix is orthonormal.
bool IsPlanar ( DVec3dCR  normal) const

Tests if this instance matrix has no effects perpendicular to any plane with the given normal.

This will be true if the matrix represents a combination of (a) scaling perpencicular to the normal and (b) rotation around the normal.

Parameters
[in]normalThe plane normal
Returns
true if the matrix has no effects perpendicular to any plane with the given normal.
bool IsRigid ( ) const

Test if a matrix is a rigid body rotation, i.e.

its transpose is its inverse and it has a positive determinant.

Returns
true if the matrix is a rigid body rotation.
bool IsRigidScale ( RotMatrixR  columns,
double &  scale 
) const

Test if this instance matrix is composed of only rigid rotation and scaling.

Parameters
[out]columnsmatrix containing the unit vectors along the columns.
[out]scalelargest axis scale factor. If function value is true, the min scale is the same. Use areColumnsOrthonormal to get separate column scales.
Returns
true if the matrix is orthonormal.
bool IsSignedPermutation ( ) const

Test if this instance matrix does nothing more than exchange and possibly negate principle axes.

Returns
true if the matrix is a permutation of the principle axes.
bool IsUniformScale ( double &  maxScale) const

Tests if a matrix has (nearly) equal diagaonal entries and (nearly) zero off diagonals.

Tests use a tight relative tolerance.

Parameters
[out]maxScalethe largest diagaonal entry
Returns
true if matrix is approximately diagonal
DRange1d LowerTriangleAbsRange ( )

return the range of absolute values strictly below the diagonal.

double LowerTriangleMaxAbs ( )

return the largest absolute value in the lower triangle.

double MaxAbs ( ) const

Find the largest absolute value of entries in the matrix.

Returns
largest absolute value in matrix
double MaxDiff ( RotMatrixCR  matrix2) const

Returns the largest absolute value difference between corresponding coefficients in Matrix1 and Matrix2.

Parameters
[in]matrix2The matrix to compare to
Returns
largest absolute difference between the two matrices.
void Multiply ( DPoint4dP  result,
DPoint4dCP  point,
int  numPoint 
) const

Computes {M*P[i]} where M is this instance matrix and each P[i] is a point in the input array point.

Each result is placed in the corresponding entry in the output array result. The same array may be named for the input and output arrays.

Parameters
[out]resultoutput points
[in]pointThe input points
[in]numPointThe number of points
void Multiply ( DPoint2dP  result,
DPoint2dCP  point,
int  numPoint 
) const

Computes {M*P[i]} where M is this instance matrix and each P[i] is a point in the input array point.

Each result is placed in the corresponding entry in the output array result. The same array may be named for the input and output arrays.

Parameters
[out]resultoutput points
[in]pointThe input points
[in]numPointThe number of points
void Multiply ( DRange3dR  outRange,
DRange3dCR  inRange 
) const

computes the 8 corner points of the range cube defined by the two points of pRange, multiplies matrix times each point, and computes the twopoint range limits (min max) of the resulting rotated box.

Note that the volume of the rotated box is generally larger than that of the input because the postrotation minmax operation expands the box. Ranges that are null as defined by inRange->isNull are left unchanged.

Parameters
[out]outRangerange of transformed cube
[in]inRangeAny two corners of original cube
void Multiply ( DPoint3dR  point) const

Computes the product {M*P} where M is this instance matrix and P the input point.

The result overwrites the previous coordinates in point.

Parameters
[in,out]pointThe point to be updated
void Multiply ( DPoint3dR  result,
DPoint3dCR  point 
) const

Returns the product of a matrix times a point.

Parameters
[out]resultresult of the multiplication.
[in]pointThe known point.
void Multiply ( DPoint3dP  result,
DPoint3dCP  point,
int  numPoint 
) const

Computes {M*P[i]} where M is this instance matrix and each P[i] is a point in the input array point.

Each result is placed in the corresponding entry in the output array result. The same array may be named for the input and output arrays.

Parameters
[out]resultoutput points
[in]pointThe input points
[in]numPointThe number of points
void Multiply ( bvector< DPoint3d > &  outXYZ,
bvector< DPoint3d > const &  inXYZ 
) const

Description Multiply points. (Matrix on left, point on right as column vector)

Parameters
[in]outXYZtransformed coordinates.
[in]inXYZinput coordinates
void Multiply ( bvector< DPoint2d > &  out,
bvector< DPoint2d > const &  in 
) const

Description Multiply 2D points. (Matrix on left, point on right as column vector)

Parameters
[in]outtransformed coordinates. z row of matrix ignored.
[in]ininput coordinates. z=0 implied for multiplication.
void Multiply ( bvector< DPoint4d > &  xyzwOut,
bvector< DPoint4d > const &  xyzwIn 
) const

Multiply xyzw, with matrix w row and column 0001.

Parameters
[in]xyzwOuttransformed coordinates.
[in]xyzwIninput coordinates.
void MultiplyComponents ( DPoint3dR  result,
double  x,
double  y,
double  z 
) const

Returns the product of a matrix times a point, with the point given as separate components.

Parameters
[out]resultresult of multiplication
[in]xThe x component of input point
[in]yThe y component of input point
[in]zThe z component of input point
void MultiplyTranspose ( DPoint3dR  result,
DPoint3dCR  point 
) const

Returns the product of a matrix transpose times a point.

Parameters
[out]resultresult of the multiplication.
[in]pointThe known point.
void MultiplyTranspose ( DPoint3dR  point) const

Computes the product {P*M} where M is this instance matrix and P is the input point The result overwrites the previous coordinates in the point.

Parameters
[in,out]pointThe point to be multiplied
void MultiplyTranspose ( DPoint3dP  result,
DPoint3dCP  point,
int  numPoint 
) const

Computes {P[i]*M} where M is this instance matrix and each P[i] is a point in the input array point, transposed into row form.

(Equivalently, multiply M^*p[i], where M^ indicates transpose.) Each result is placed in the corresponding entry in the output array result. The same array may be named for the input and output arrays.

Parameters
[out]resultoutput points
[in]pointThe input points
[in]numPointThe number of points
void MultiplyTranspose ( bvector< DPoint3d > &  outXYZ,
bvector< DPoint3d > const &  inXYZ 
) const

Multiply the transposed matrix times points. (Tranposed matrix on left, point on right as column vector. Or (equivalent) point on left as row vector, matrix on right)

Parameters
[in]outXYZtransformed coordinates.
[in]inXYZinput coordinates
void MultiplyTransposeComponents ( DPoint3dR  result,
double  x,
double  y,
double  z 
) const

Returns the product P = [x,y,z]*M where M is the input matrix and P is the product point.

Parameters
[out]resultproduct point
[in]xThe x component
[in]yThe y component
[in]zThe z component
void NormalizeColumnsOf ( RotMatrixCR  inMatrix,
DVec3dR  scaleVector 
)

Returns a matrix whose rows are unit vectors in the same drection as corresponding columns of the input matrix.

Also (optionally) stores the original column magnitudes as components of the point.

Parameters
[in]inMatrixThe input matrix
[out]scaleVectorlength of original columns
void NormalizeRowsOf ( RotMatrixCR  inMatrix,
DVec3dR  scaleVector 
)

Returns a matrix whose rows are unit vectors in the same drection as corresponding rows of the input matrix.

Also (optionally) stores the original row magnitudes as components of the point.

Parameters
[in]inMatrixThe input matrix
[out]scaleVectorlength of original rows
void OffDiagonalAbsRange ( double &  minValue,
double &  maxValue 
) const

Return the (absolute value) range of entries off the diagonal.

Parameters
[out]minValuesmallest absolute value
[out]maxValuelargest absolute value
void OffDiagonalSignedRange ( double &  minValue,
double &  maxValue 
) const

Return the (signed) range of entries off the diagonal.

Parameters
[out]minValuesmallest signed value
[out]maxValuelargest signed value
bool RotateAndSkewFactors ( RotMatrixR  rotation,
RotMatrixR  skewFactor,
int  primaryAxis,
int  secondaryAxis 
) const

Factor as {rotation*skewFactor} where the rotation favors indicated primary and secondary axes.

Parameters
[out]rotationthe (orthogonal, right handed) rotation.
[out]skewFactorthe scale and skew parts.
[in]primaryAxisselects column whose direction is preserved.
[in]secondaryAxisselects columns that defines plane (with primaryAxis)
Returns
true if primary and secondary are independent.
static RotMatrix RotationFromOriginXY ( DPoint3dCR  origin,
DPoint3dCR  xPoint,
DPoint3dCR  yPoint 
)
static

Set this instance matrix to be an orthogonal (rotation) matrix with column 0 in the direction from the origin to the x point, column 1 in the plane of the 3 points, directed so the Y point on the positive side, and column 2 as their cross product.

Parameters
[in]originThe reference point
[in]xPointThe x axis target point
[in]yPointThe 3rd point defining xy plane.
void Scale ( RotMatrixCR  leftMatrix,
double  xs,
double  ys,
double  zs,
RotMatrixCR  rightMatrix 
)

Returns a matrix formed from a scaling matrix which is multiplied on the left and/or right with other matrices.

That is, form LeftMatrix * ScaleMatrix * RightMatrix where the ScaleMatrix is constructed from the given scale factors.

Parameters
[in]leftMatrixThe matrix on left of product
[in]xsThe x scale factor
[in]ysThe y scale factor
[in]zsThe z scale factor
[in]rightMatrixThe matrix on right of product
void ScaleColumns ( RotMatrixCR  in,
double  xs,
double  ys,
double  zs 
)

Applies scale factors to corresponding columns of the input matrix, and places the result in this instance matrix.

Parameters
[in]inThe initial matrix
[in]xsThe scale factor for column 0
[in]ysThe scale factor for column 1
[in]zsThe scale factor for column 2
void ScaleColumns ( double  xs,
double  ys,
double  zs 
)

Applies scale factors to corresponding columns.

Parameters
[in]xsThe scale factor for column 0
[in]ysThe scale factor for column 1
[in]zsThe scale factor for column 2
void ScaleRows ( RotMatrixCR  inMatrix,
double  xScale,
double  yScale,
double  zScale 
)

Applies scale factors to corresponding rows of the input matrix, and places the result in this instance matrix.

Parameters
[in]inMatrixThe initial matrix
[in]xScaleThe scale factor for row 0
[in]yScaleThe scale factor for row 1
[in]zScaleThe scale factor for row 2
void SetColumn ( DVec3dCR  vector,
int  col 
)

Set the components in a column.

Parameters
[in]vectornew values
[in]colThe index of column to change. Column indices are 0, 1, 2.
void SetRow ( DVec3dCR  vector,
int  row 
)

Set the components in a row.

Parameters
[in]vectornew values
[in]rowThe index of row to change. Row indices are 0, 1, 2.
void ShuffleColumnsOf ( RotMatrixCR  inMatrix,
int  i0,
int  i1,
int  i2 
)

Moves columns 0, 1, 2 of the input matrix into columns i0, i1, i2 of the instance.

Parameters
[in]inMatrixThe input matrix
[in]i0The column to receive input column 0
[in]i1The column to receive input column 1
[in]i2The column to receive input column 2
bool Solve ( DPoint3dR  result,
DPoint3dCR  point 
) const

Return the product of a matrix inverse and a point.

Parameters
[out]resultthe unknown point
[in]pointThe The known point
Returns
false if this instance is singular.
bool SolveArray ( bvector< DPoint3d > &  xyzOut,
bvector< DPoint3d > const &  xyzIn 
) const

Solve M*xyzOut[i] = xyzIn[i] for array of points.

(Equivalent to multiplying by the matrix inverse)

Parameters
[in]xyzOutsolution coordinates
[in]xyzIninput coordinates.
bool SolveArray ( DPoint3dP  result,
DPoint3dCP  point,
int  numPoints 
) const

Solves the matrix equation AX=B, where A is this instance, B is the matrix of numPoints input points and X is the matrix of numPoints output points.

point and result may have identical addresses.

Parameters
[out]resultcolumn points of solution matrix to system
[in]pointThe column points of constant matrix of system
[in]numPointsThe number of input/output points
Returns
false if this instance is singular.
bool SolveTranspose ( DPoint3dR  result,
DPoint3dCR  point 
) const

Return the product of a matrix inverse transpose and a point.

Parameters
[out]resultresult of the multiplication
[in]pointThe known point multipled by the matrix inverse.
Returns
false if this instance is singular.
bool SquareAndNormalizeColumns ( RotMatrixCR  inMatrix,
int  primaryAxis,
int  secondaryAxis 
)

Adjust the direction and length of columns of the input matrix to produce an instance matrix which has perpendicular, unit length columns.

The column whose index is primaryAxis (i.e. 0,1,2 for x,y,z axis of coordinate frame) is normalized to unit length in its current direction. The column whose index is secondaryAxis is unit length and perpendicular to the primaryAxis column, and lies in the same plane as that defined by the original primary and secondary columns. To preserve X axis and XY plane, call with axis id's 0 and 1. To preserve Z axis and ZX plane, call with axis id's 2 and 0. inMatrix and pMatrix may be the same address.

Parameters
[in]inMatrixThe input matrix
[in]primaryAxisThe axis id (0, 1, 2) which is to be normalized but left in its current direction
[in]secondaryAxisThe axis id (0, 1, 2) which is to be kept within the plane of the primary and secondary axis.
Returns
false if primaryAxis and secondaryAxis are the same, or either axis has zero length
bool SquareAndNormalizeColumns ( RotMatrixCR  inMatrix,
int  primaryAxis,
int  secondaryAxis,
int  preferredOrientation 
)
bool SquareAndNormalizeColumnsAnyOrder ( RotMatrixCR  inMatrix,
int  preferredOrientation 
)

Returns an orthogonal matrix that preserves aligns with the columns of inMatrix.

This is done by trying various combinations of primary and secondary axes until one succeeds in squareAndNormalizeColumns.

Parameters
[in]inMatrixThe input matrix
[in]preferredOrientation
  • 1 for right handed system
  • -1 for left handed system
  • 0 to match orientation of input (but default to right handed if input is singular)
bool SquareAndNormalizeColumnsAnyOrder ( RotMatrixCR  inMatrix)

Returns an orthogonal matrix that preserves aligns with the columns of inMatrix.

This is done by trying various combinations of primary and secondary axes until one succeeds in squareAndNormalizeColumns.

Parameters
[in]inMatrixThe input matrix
void Subtract ( RotMatrixCR  delta)

Subtract a matrix (componentwise, in place).

Parameters
[in]deltaThe matrix to subtract
double SumDiagonalSquares ( ) const

Computes the sum of the squares of the diagonal entries of this instance matrix.

Returns
Sum of squares of diagonal entries
void SumOf ( RotMatrixCR  matrix0,
RotMatrixCR  matrix1,
double  scale1,
RotMatrixCR  matrix2,
double  scale2 
)

Returns {Matrix0 + Matrix1*s1+Matrix2*s2}, i.e.

the sum of matrix M0, matrix M1 multiplied by scale s1, and matrix M2 multiplied by scale s2. Any combination of the matrix pointers may have identical addresses.

Parameters
[in]matrix0The matrix0 of formula
[in]matrix1The matrix1 of formula
[in]scale1The scale factor to apply to Matrix1
[in]matrix2The matrix2 of formula
[in]scale2The scale factor to apply to Matrix2
double SumOffDiagonalSquares ( ) const

Computes the sum of the squares of the off-diagonal entries of this instance matrix.

Returns
sum of square of off-diagonal entries of the matrix.
double SumSquares ( ) const

Return the sum of squares of coefficients in a matrix.

Returns
Sum of squares of all entries in matrix
void Transpose ( )

Transposes a matrix in place.

void TransposeOf ( RotMatrixCR  matrix)

Initializes this instance as the transpose of a matrix.

Parameters
[in]matrixThe input matrix
DRange1d UpperTriangleAbsRange ( )

return the range of absolute values strictly above the diagonal.

double UpperTriangleMaxAbs ( )

return the largest absolute value in the upper triangle.

void Zero ( )

returns a zero matrix.

Member Data Documentation

double form3d[3][3]

matrix coefficients. These are public, but direct use of the arrays is discouraged.


The documentation for this struct was generated from the following file:

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.