figureone
    Preparing search index...

    A Transform is a chain or cascade of transform components, such as rotations and translations.

    The transform components cascade to form a single 3D transform matrix in homogenous coordinates - meaning the result is a 4x4 matrix. This matrix can be used to transform a point in space.

    There are several built in transform components:

    • Translation
    • Scale
    • Rotation
    • Direction transform
    • Custom (where a specific matrix can be defined)
    • Change of basis from standard basis
    • Change of basis from an initial basis

    Matrix multiplication is not commutative, and so chaining transforms is not commutative. This means the order of components is important.

    For example, if a point (1, 0) is first translated by (1, 0) and then rotated by π / 2, then it will start at (1, 0), then move to (2, 0), then rotate to (0, 2).

    In comparison if the same point is first rotated by π / 2 then translated by (1, 0) it will start at (1, 0), then rotate to (0, 1), then move to (1, 1).

    In this Transform object, the order that components are defined, is the order the resulting transform will represent.

    A transform can be created by either chaining transform component methods on an instantiated Transform object, or using an array definition of components. For example the following two transforms are the same:

    const t1 = new Transform().scale(1).translate(1, 0);
    const t2 = new Transform([['s', 1], ['t', 1, 0]]);

    See TypeParsableTransform for the different ways to define a transform.

    Index

    Constructors

    Methods

    • Query if transform has a specific component.

      Parameters

      • componentName: TypeTransformComponentName

      Returns boolean

      true if component name exists

    • Get the nth transform component index of type.

      Parameters

      • type: TypeTransformComponentName | TypeTransformComponentName[]
      • n: number = 0

        (0)

      Returns number

      index of component

    • Clip all rotation (2D, axis, x, y, z rotations) transform components within this transform chain angles between 0º-360º, -180º-180º, or not at all (null)

      Only angle values are clipped. The axis values of the axis rotation is not changed.

      Parameters

      • clipTo: "0to360" | "-180to180" | null

      Returns void

    • Return a linearly interpolated transform between this transform and delta at some percent between the two.

      For translation transform components, interpolation can either be 'linear' or 'curved'.

      Parameters

      • delta: Transform

        delta transform

      • percent: number

        percent to interpolate where 0 is this transform and 1 is delta transform

      • translationStyle: "curve" | "linear" | "curved" = 'linear'

        translation style for translation components only

      • translationOptions: OBJ_TranslationPath = {}

        translation options for translation components only

      Returns Transform

    • Retrieve the nth direction transform component.

      Parameters

      • n: number = 0

        (0)

      Returns
          | (number | "r")[]
          | (number | "d")[]
          | (number | "t")[]
          | (number | "s")[]
          | (number | "c")[]
          | (number | "b")[]
          | (number | "bb")[]

    • Retrieve the nth custom transform component.

      Parameters

      • n: number = 0

        (0)

      Returns
          | (number | "r")[]
          | (number | "d")[]
          | (number | "t")[]
          | (number | "s")[]
          | (number | "c")[]
          | (number | "b")[]
          | (number | "bb")[]

    • Retrieve the nth change of basis from standard basis transform component.

      Parameters

      • n: number = 0

        (0)

      Returns
          | (number | "r")[]
          | (number | "d")[]
          | (number | "t")[]
          | (number | "s")[]
          | (number | "c")[]
          | (number | "b")[]
          | (number | "bb")[]

    • Retrieve the nth change of basis transform component.

      Parameters

      • n: number = 0

        (0)

      Returns
          | (number | "r")[]
          | (number | "d")[]
          | (number | "t")[]
          | (number | "s")[]
          | (number | "c")[]
          | (number | "b")[]
          | (number | "bb")[]

    • Return the matrix that respresents the cascaded transform chain

      Parameters

      • precision: number | null = null

        round the matrix to some precision or null for no rounding (null)

      Returns Type3DMatrix

    • true if transformToCompare is wihtin some delta of this transform. isEqualTo rounds the values to some precision to compare values. In comparison this will directly compare the delta between values. This may be more useful than rounding when values are close to rounding thresholds.

      Parameters

      Returns boolean

    • true if all transforms within the transform chain are below the zeroThreshold

      Parameters

      • zeroThreshold: number = 0

        (0)

      Returns boolean