pwu:: Transform

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

Summary
Utility functions for transform matrices, which are represented as a list of sixteen real values.
Return an identity transform matrix
Set an element of a transform matrix
Get an element of a transform matrix
Transform a vector point matrix by the given transform matrix
Multiply one transform matrix by another
Return the determinant of a given transform matrix
Return the transpose of a given transform matrix
Return the inverse of a given transform matrix
Multiply the given transform matrix by a translation transform
Return a transform matrix that is a translation of the given offset
Multiply the given transform matrix by a rotation transform
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.
Multiply the given transform matrix by a scaling transform
Return a transform matrix that is a scaling of the given vector
Return a transform matrix that scales a given point from one location to another anchored at a third point
Create an orthonormal view transform matrix from a view frustum
Create a perspective view transform matrix from a view frustum
Multiply the given transform matrix by a mirroring transform
Return a transform matrix that is a mirroring of the given plane
Return a transform matrix that is a mirroring of the given plane
Multiply the given transform matrix by a stretching transform.
Return 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
jthe j index of the element to set
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
jthe j index of the element to get

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

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

matrixthetransform 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 conjuction 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

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 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 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.