pwu::Transform

Utility functions for transform matrices, which are represented as a list of sixteen real values.

Summary
pwu::TransformUtility functions for transform matrices, which are represented as a list of sixteen real values.
Static Actions
identityReturn an identity transform matrix
setSet an element of a transform matrix
elementGet an element of a transform matrix
applyTransform a vector point matrix by the given transform matrix
applyToDirectionTransform a direction vector by the given transform matrix.
applyToNormalTransform a normal vector by the given transform matrix.
applyToPlaneTransform a plane by the given transform matrix.
multiplyMultiply one transform matrix by another
determinantReturn the determinant of a given transform matrix
transposeReturn the transpose of a given transform matrix
inverseReturn the inverse of a given transform matrix
translateMultiply the given transform matrix by a translation transform
translationReturn a transform matrix that is a translation of the given offset
rotateMultiply the given transform matrix by a rotation transform
rotationReturn a transform matrix that is a rotation of the given quaternion, axis angle pair, or pair of vectors representing the new X and Y directions.
scaleMultiply the given transform matrix by a scaling transform
scalingReturn a transform matrix that is a scaling of the given vector
calculatedScalingReturn a transform matrix that scales a given point from one location to another anchored at a third point
orthoCreate an orthonormal view transform matrix from a view frustum
perspectiveCreate a perspective view transform matrix from a view frustum
mirrorMultiply the given transform matrix by a mirroring transform
mirroringReturn a transform matrix that is a mirroring of the given plane
mirrorPlaneReturn a transform matrix that is a mirroring of the given plane
stretchMultiply the given transform matrix by a stretching transform.
stretchingReturn a transform matrix that is a stretching transform.

Static Actions

identity

pwu::Transform identity

Return an identity transform matrix

Parameters

none

Returns

a transform that is set to the identity matrix

set

pwu::Transform set matrix i j value

Set an element of a transform matrix

Parameters

matrixthe transform matrix
ithe i index of the element to set [0,3]
jthe j index of the element to set [0,3]
valuethe value to set

Returns

a transform matrix that is the same as the given transform matrix, except the element that has been set to the given value

element

pwu::Transform element matrix i j

Get an element of a transform matrix

Parameters

matrixthe transform matrix
ithe i index of the element to get [0,3]
jthe j index of the element to get [0,3]

Returns

the value of the element

apply

pwu::Transform apply matrix vec

Transform a vector point matrix by the given transform matrix

Parameters

matrixthe transform matrix
vecthe vector point

Returns

the transformed vector point

applyToDirection

pwu::Transform applyToDirection matrix dir

Transform a direction vector by the given transform matrix.  This differs from apply as follows.  When transforming a point by a 4x4 matrix, the point is represented by a vector with X, Y, and Z as the first 3 components and 1 as the fourth component.  This allows the point to pick up any translation component in the matrix.  This method represents the direction as a vector with 0 as the fourth component.  Since a direction can be thought of as the difference between two points, a zero fourth component is the difference between two points that have 1 as the fourth component.

Parameters

matrixthe transform matrix
dirthe direction vector

Returns

the transformed direction vector

applyToNormal

pwu::Transform applyToNormal matrix normal

Transform a normal vector by the given transform matrix.  A normal vector is transformed by multiplying the normal by the transposed inverse matrix.

Parameters

matrixthe transform matrix
normalthe normal vector

Returns

the transformed normal vector (normalized)

applyToPlane

pwu::Transform applyToPlane matrix plane

Transform a plane by the given transform matrix.

Parameters

matrixthe transform matrix
planethe plane description as returned by pwu::Plane

Returns

the transformed plane

multiply

pwu::Transform multiply matrix1 matrix2

Multiply one transform matrix by another

Parameters

matrix1the first matrix
matrix2the first matrix

Returns

the transform matrix resulting from the multiplication

determinant

pwu::Transform determinant matrix

Return the determinant of a given transform matrix

Parameters

matrixthe transform matrix

Returns

the determinant of the matrix

transpose

pwu::Transform transpose matrix

Return the transpose of a given transform matrix

Parameters

matrixthe transform matrix

Returns

the transform matrix resulting from the transposition

inverse

pwu::Transform inverse matrix

Return the inverse of a given transform matrix

Parameters

matrixthe transform matrix

Returns

the transform matrix resulting from the inversion

translate

pwu::Transform translate matrix offset

Multiply the given transform matrix by a translation transform

Parameters

matrixthe transform matrix
offsetthe translation transform offset vector

Returns

the transform matrix multiplied by the translation transform

translation

pwu::Transform translation offset

Return a transform matrix that is a translation of the given offset

Parameters

offsetthe translation transform offset

Returns

the translation transform

rotate

pwu::Transform rotate ?-anchor anchor_pt? matrix axis angle

Multiply the given transform matrix by a rotation transform

Parameters

anchor_ptthe point about which the matrix is rotated (default is the origin)
matrixthe transform matrix
axisthe rotation transform axis vector
anglethe rotation transform angle

Returns

the matrix multiplied by the rotation transform

rotation

pwu::Transform rotation ?-anchor anchor_pt? < quat | axis angle | right up >

Return a transform matrix that is a rotation of the given quaternion, axis angle pair, or pair of vectors representing the new X and Y directions.

Parameters

anchor_ptThis is the point about which the matrix is rotated (default is the origin).
quatThis argument represents the rotation quaternion.
axisThis argument is the axis of rotation and is used in conjunction with the angle argument.
angleThis argument is angle of rotation about the axis argument.
rightThis represents the direction to which the X axis is rotated by the rotation matrix.  The value is normalized before use.
upThis represents the direction to which the Y axis is rotated by the rotation matrix.  Note that it normalized and made orthogonal to the right vector.  An error is reported if it is parallel to the right vector.

Returns

This action returns a rotation matrix.

scale

pwu::Transform scale ?-anchor anchor_pt? matrix scale

Multiply the given transform matrix by a scaling transform

Parameters

anchor_ptthe point about which the matrix is scaled (default is the origin)
matrixthe transform matrix
scalethe scaling matrix vector

Returns

the matrix multiplied by the scaling matrix

scaling

pwu::Transform scaling ?-anchor anchor_pt? scale_vec

Return a transform matrix that is a scaling of the given vector

Parameters

anchor_ptthe point about which the matrix is scaled (default is the origin)
scalethe scaling vector

Returns

the scaling matrix

calculatedScaling

pwu::Transform calculatedScaling anchor start end ?tol?

Return a transform matrix that scales a given point from one location to another anchored at a third point

Parameters

anchorthe anchor for the scaling (a point at this location will not be transformed by the matrix)
starta point value representing a location before transformation
enda point value representing the start value’s location after transformation
tolif a component of the vector difference between the anchor and start point is less than the specified tolerance, the scaling factor will be set to 1 for that component (default value is zero)

Returns

the scaling matrix

ortho

pwu::Transform ortho left right bottom top near far

Create an orthonormal view transform matrix from a view frustum

Parameters

leftthe left plane constant
rightthe right plane constant
bottomthe bottom plane constant
topthe top plane constant
nearthe near plane constant
farthe far plane constant

Returns

the view transform matrix

perspective

pwu::Transform perspective left right bottom top near far

Create a perspective view transform matrix from a view frustum

Parameters

leftthe left plane constant
rightthe right plane constant
bottomthe bottom plane constant
topthe top plane constant
nearthe near plane constant
farthe far plane constant

Returns

the view transform matrix

mirror

pwu::Transform mirror matrix normal dist

Multiply the given transform matrix by a mirroring transform

Parameters

matrixthe transform matrix
normalthe normal of the mirroring plane
distthe constant value of the plane

Returns

the matrix multiplied by the mirroring matrix

mirroring

pwu::Transform mirroring normal dist

Return a transform matrix that is a mirroring of the given plane

Parameters

normalthe normal of the mirroring plane
distthe constant value of the plane

Returns

the mirroring matrix

mirrorPlane

pwu::Transform mirrorPlane plane

Return a transform matrix that is a mirroring of the given plane

Parameters

planeThe mirroring plane.

Returns

the mirroring matrix

stretch

pwu::Transform stretch matrix anchor start end

Multiply the given transform matrix by a stretching transform.  If the vector defined by the start and end points is orthogonal to the vector defined by the start and anchor points, the transform is undefined and the matrix will be set to the identity matrix.

Parameters

matrixthe transform matrix
anchorthe anchor for the stretching (a point at this location will not be transformed by the matrix)
starta point value representing a location before transformation
enda point value representing the start value’s location after transformation

Returns

the matrix multiplied by the stretching matrix

stretching

pwu::Transform stretching anchor start end

Return a transform matrix that is a stretching transform.  If the vector defined by the start and end points is orthogonal to the vector defined by the start and anchor points, the transform is undefined and the matrix will be set to the identity matrix.

Parameters

anchorthe anchor for the scaling (a point at this location will not be transformed by the matrix)
starta point value representing a location before transformation
enda point value representing the start value’s location after transformation

Returns

the stretching matrix

pwu::Transform identity
Return an identity transform matrix
pwu::Transform set matrix i j value
Set an element of a transform matrix
pwu::Transform element matrix i j
Get an element of a transform matrix
pwu::Transform apply matrix vec
Transform a vector point matrix by the given transform matrix
pwu::Transform applyToDirection matrix dir
Transform a direction vector by the given transform matrix.
pwu::Transform applyToNormal matrix normal
Transform a normal vector by the given transform matrix.
pwu::Transform applyToPlane matrix plane
Transform a plane by the given transform matrix.
pwu::Transform multiply matrix1 matrix2
Multiply one transform matrix by another
pwu::Transform determinant matrix
Return the determinant of a given transform matrix
pwu::Transform transpose matrix
Return the transpose of a given transform matrix
pwu::Transform inverse matrix
Return the inverse of a given transform matrix
pwu::Transform translate matrix offset
Multiply the given transform matrix by a translation transform
pwu::Transform translation offset
Return a transform matrix that is a translation of the given offset
pwu::Transform rotate ?-anchor anchor_pt? matrix axis angle
Multiply the given transform matrix by a rotation transform
pwu::Transform rotation ?-anchor anchor_pt? < quat | axis angle | right up >
Return a transform matrix that is a rotation of the given quaternion, axis angle pair, or pair of vectors representing the new X and Y directions.
pwu::Transform scale ?-anchor anchor_pt? matrix scale
Multiply the given transform matrix by a scaling transform
pwu::Transform scaling ?-anchor anchor_pt? scale_vec
Return a transform matrix that is a scaling of the given vector
pwu::Transform calculatedScaling anchor start end ?tol?
Return a transform matrix that scales a given point from one location to another anchored at a third point
pwu::Transform ortho left right bottom top near far
Create an orthonormal view transform matrix from a view frustum
pwu::Transform perspective left right bottom top near far
Create a perspective view transform matrix from a view frustum
pwu::Transform mirror matrix normal dist
Multiply the given transform matrix by a mirroring transform
pwu::Transform mirroring normal dist
Return a transform matrix that is a mirroring of the given plane
pwu::Transform mirrorPlane plane
Return a transform matrix that is a mirroring of the given plane
pwu::Transform stretch matrix anchor start end
Multiply the given transform matrix by a stretching transform.
pwu::Transform stretching anchor start end
Return a transform matrix that is a stretching transform.
Utility functions for planes, which are represented as a list of four real values (the A, B, C and D coeffecients).
Close