Discover Learn Reference Get OpenPLX Search Contact

Math

AffineTransform

AffineTransform:
    .doc: """
A transform that can represent any combination of translation, rotation, scale, and skew

The final transformation first applies scale, then skew, then rotation and finally translation

Typically, skew is defined as a 3x3 skew matrix where the off-diagonal elements each define
the skew factor for an axis pair. This definition over-parameterizes the transform when combined
with rotation and scale so instead, the upper triangular portion of the skew matrix is used.
i.e. a skew of (kx,ky,kz) results in the following skew matrix:
| 1 kz ky |
| 0 1  kx |
| 0 0  1  |

from_axes - Returns a transform that 1: rotates from a pair (main = Z, normal = X) to a new pair (new_Z, new_X), and 2: translates to position.
            Observe that new_X must not be parallell to new_Z in order for the result to be correct.
            If new_X is not orthogonal to new_Z, new_X will be projected onto the plane orthogonal to new_Z.
"""
    position is Vec3
    rotation is Quat
    scale is Vec3:
        x: 1
        y: 1
        z: 1
    skew is Vec3

    static fn create() -> AffineTransform
    static fn from(p: Vec3, r: Quat) -> AffineTransform
    static fn from_trs_skew(p: Vec3, r: Quat, s: Vec3, skew: Vec3) -> AffineTransform
    static fn from_axes(new_Z: Vec3, new_X: Vec3, position: Vec3) -> AffineTransform
    static fn inverse_of(p: Vec3, r: Quat) -> AffineTransform

    fn inverse() -> AffineTransform
    fn to_matrix4x4() -> Matrix4x4
    fn is_rigid() -> Bool
    fn transform_vec3_point(in: Vec3) -> Vec3
    fn transform_vec3_vector(in: Vec3) -> Vec3

operator *(lhs: AffineTransform, rhs: AffineTransform) -> AffineTransform

OpenPLX is a work in progress. This draft version will evolve with user feedback and experience. We welcome your input and collaboration.
X