Utility functions for transform matrices, which are represented as a list of sixteen real values.
pwu:: | Utility functions for transform matrices, which are represented as a list of sixteen real values. |
Static Actions | |
identity | Return an identity transform matrix |
set | Set an element of a transform matrix |
element | Get an element of a transform matrix |
apply | Transform a vector point matrix by the given transform matrix |
applyToDirection | Transform a direction vector by the given transform matrix. |
applyToNormal | Transform a normal vector by the given transform matrix. |
applyToPlane | Transform a plane by the given transform matrix. |
multiply | Multiply one transform matrix by another |
determinant | Return the determinant of a given transform matrix |
transpose | Return the transpose of a given transform matrix |
inverse | Return the inverse of a given transform matrix |
translate | Multiply the given transform matrix by a translation transform |
translation | Return a transform matrix that is a translation of the given offset |
rotate | Multiply the given transform matrix by a rotation transform |
rotation | 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. |
scale | Multiply the given transform matrix by a scaling transform |
scaling | Return a transform matrix that is a scaling of the given vector |
calculatedScaling | Return a transform matrix that scales a given point from one location to another anchored at a third point |
ortho | Create an orthonormal view transform matrix from a view frustum |
perspective | Create a perspective view transform matrix from a view frustum |
mirror | Multiply the given transform matrix by a mirroring transform |
mirroring | Return a transform matrix that is a mirroring of the given plane |
mirrorPlane | Return a transform matrix that is a mirroring of the given plane |
stretch | Multiply the given transform matrix by a stretching transform. |
stretching | Return a transform matrix that is a stretching transform. |
pwu::Transform set matrix i j value
Set an element of a transform matrix
matrix | the transform matrix |
i | the i index of the element to set [0,3] |
j | the j index of the element to set [0,3] |
value | the value to set |
a transform matrix that is the same as the given transform matrix, except the element that has been set to the given value
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.
matrix | the transform matrix |
dir | the direction vector |
the transformed direction vector
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.
matrix | the transform matrix |
normal | the normal vector |
the transformed normal vector (normalized)
pwu::Transform applyToPlane matrix plane
Transform a plane by the given transform matrix.
matrix | the transform matrix |
plane | the plane description as returned by pwu::Plane |
the transformed plane
pwu::Transform rotate ?-anchor anchor_pt? matrix axis angle
Multiply the given transform matrix by a rotation transform
anchor_pt | the point about which the matrix is rotated (default is the origin) |
matrix | the transform matrix |
axis | the rotation transform axis vector |
angle | the rotation transform angle |
the matrix multiplied by the 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.
anchor_pt | This is the point about which the matrix is rotated (default is the origin). |
quat | This argument represents the rotation quaternion. |
axis | This argument is the axis of rotation and is used in conjunction with the angle argument. |
angle | This argument is angle of rotation about the axis argument. |
right | This represents the direction to which the X axis is rotated by the rotation matrix. The value is normalized before use. |
up | This 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. |
This action returns a rotation matrix.
pwu::Transform scale ?-anchor anchor_pt? matrix scale
Multiply the given transform matrix by a scaling transform
anchor_pt | the point about which the matrix is scaled (default is the origin) |
matrix | the transform matrix |
scale | the scaling matrix vector |
the matrix multiplied by the scaling matrix
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
anchor | the anchor for the scaling (a point at this location will not be transformed by the matrix) |
start | a point value representing a location before transformation |
end | a point value representing the start value’s location after transformation |
tol | if 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) |
the scaling matrix
pwu::Transform ortho left right bottom top near far
Create an orthonormal view transform matrix from a view frustum
left | the left plane constant |
right | the right plane constant |
bottom | the bottom plane constant |
top | the top plane constant |
near | the near plane constant |
far | the far plane constant |
the view transform matrix
pwu::Transform perspective left right bottom top near far
Create a perspective view transform matrix from a view frustum
left | the left plane constant |
right | the right plane constant |
bottom | the bottom plane constant |
top | the top plane constant |
near | the near plane constant |
far | the far plane constant |
the view transform matrix
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.
matrix | the transform matrix |
anchor | the anchor for the stretching (a point at this location will not be transformed by the matrix) |
start | a point value representing a location before transformation |
end | a point value representing the start value’s location after transformation |
the matrix multiplied by the stretching matrix
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.
anchor | the anchor for the scaling (a point at this location will not be transformed by the matrix) |
start | a point value representing a location before transformation |
end | a point value representing the start value’s location after transformation |
the stretching matrix
Return an identity transform matrix
pwu::Transform identity
Set an element of a transform matrix
pwu::Transform set matrix i j value
Get an element of a transform matrix
pwu::Transform element matrix i j
Transform a vector point matrix by the given transform matrix
pwu::Transform apply matrix vec
Transform a direction vector by the given transform matrix.
pwu::Transform applyToDirection matrix dir
Transform a normal vector by the given transform matrix.
pwu::Transform applyToNormal matrix normal
Transform a plane by the given transform matrix.
pwu::Transform applyToPlane matrix plane
Multiply one transform matrix by another
pwu::Transform multiply matrix1 matrix2
Return the determinant of a given transform matrix
pwu::Transform determinant matrix
Return the transpose of a given transform matrix
pwu::Transform transpose matrix
Return the inverse of a given transform matrix
pwu::Transform inverse matrix
Multiply the given transform matrix by a translation transform
pwu::Transform translate matrix offset
Return a transform matrix that is a translation of the given offset
pwu::Transform translation offset
Multiply the given transform matrix by a rotation transform
pwu::Transform rotate ?-anchor anchor_pt? matrix axis angle
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 rotation ?-anchor anchor_pt? < quat | axis angle | right up >
Multiply the given transform matrix by a scaling transform
pwu::Transform scale ?-anchor anchor_pt? matrix scale
Return a transform matrix that is a scaling of the given vector
pwu::Transform scaling ?-anchor anchor_pt? scale_vec
Return a transform matrix that scales a given point from one location to another anchored at a third point
pwu::Transform calculatedScaling anchor start end ?tol?
Create an orthonormal view transform matrix from a view frustum
pwu::Transform ortho left right bottom top near far
Create a perspective view transform matrix from a view frustum
pwu::Transform perspective left right bottom top near far
Multiply the given transform matrix by a mirroring transform
pwu::Transform mirror matrix normal dist
Return a transform matrix that is a mirroring of the given plane
pwu::Transform mirroring normal dist
Return a transform matrix that is a mirroring of the given plane
pwu::Transform mirrorPlane plane
Multiply the given transform matrix by a stretching transform.
pwu::Transform stretch matrix anchor start end
Return a transform matrix that is a stretching transform.
pwu::Transform stretching anchor start end