mathue
    Preparing search index...

    Class Matrix3

    3x3 matrix class. It looks column-major order. And post multiplied.

    Implements

    Index

    Properties

    order: 3
    const m = Matrix3.identity();
    console.log(m.order); // 3
    elements: Float32Array
    const m = Matrix3.identity();
    console.log(m.elements);
    // [ 1, 0, 0,
    // 0, 1, 0,
    // 0, 0, 1 ]

    Constructors

    • Creates a new 3x3 matrix with the specified elements.
      The internal data is stored in column-major order in a Float32Array.

      The parameters e(column)(row) correspond to this following matrix positions: \

      | e00 e10 e20 |
      | e01 e11 e21 |
      | e02 e12 e22 |

      The elements array stores each column sequentialy:
      [e00, e01, e02, e10, e11, e12, e20, e21, e22]

      Parameters

      • e00: number

        element in column 0, row 0

      • e01: number

        element in column 0, row 1

      • e02: number

        element in column 0, row 2

      • e10: number

        element in column 1, row 0

      • e11: number

        element in column 1, row 1

      • e12: number

        element in column 1, row 2

      • e20: number

        element in column 2, row 0

      • e21: number

        element in column 2, row 1

      • e22: number

        element in column 2, row 2

      Returns Matrix3

      const m = new Matrix3(0, 1, 2, 3, 4, 5, 6, 7, 8);
      console.log(m.elements);
      // [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]

    Factory Methods

    • Creates a identity matrix instance

      Returns Matrix3

      new identity matrix instance

      const m = Matrix3.identity();
      console.log(m.elements);
      // [ 1, 0, 0,
      // 0, 1, 0,
      // 0, 0, 1 ]
    • Creates a new zero matrix instance

      Returns Matrix3

      new zero matrix instance

      const m = Matrix3.zero();
      console.log(m.elements);
      // [ 0, 0, 0,
      // 0, 0, 0,
      // 0, 0, 0 ]

    Methods

    • Creates new instance has same elements (pure)

      Returns Matrix3

      new cloned matrix instance

      const m = Matrix3.identity();
      const c = m.clone();
      console.log(c.elements);
      // [ 1, 0, 0,
      // 0, 1, 0,
      // 0, 0, 1 ]
    • Sets all elements (mutates this)

      Parameters

      • e00: number

        element in column 0, row 0

      • e01: number

        element in column 0, row 1

      • e02: number

        element in column 0, row 2

      • e10: number

        element in column 1, row 0

      • e11: number

        element in column 1, row 1

      • e12: number

        element in column 1, row 2

      • e20: number

        element in column 2, row 0

      • e21: number

        element in column 2, row 1

      • e22: number

        element in column 2, row 2

      Returns Matrix3

      this instance, for method chaining

      const m = Matrix3.zero();
      m.set(0, 1, 2, 3, 4, 5, 6, 7, 8);
      console.log(m.elements);
      // [ 0, 1, 2,
      // 3, 4, 5,
      // 6, 7, 8 ]
    • Copies all elements from other matrix (mutates this)

      Parameters

      Returns void

      this instance, for method chaining

      const m = Matrix3.zero();
      const i = Matrix3.identity();
      m.set(i);
      console.log(m.elements);
      // [ 1, 0, 0,
      // 0, 1, 0,
      // 0, 0, 1 ]
    • Sets identity matrix (mutates this)

      Returns Matrix3

      this instance, for method chaining

      const m = Matrix4.zero();
      m.setIdentity();
      console.log(m.elements);
      // [ 1, 0, 0,
      // 0, 1, 0,
      // 0, 0, 1 ]
    • Adds by other matrix (mutates this)

      Parameters

      Returns Matrix3

      this instance, for method chaining

      const m1 = Matrix3.zero();
      const m2 = Matrix3.identity();
      m1.add(m2);
      console.log(m1.elements);
      // [ 1, 0, 0,
      // 0, 1, 0,
      // 0, 0, 1 ]
    • Subtracts by other matrix (mutates this)

      Parameters

      Returns Matrix3

      this instance, for method chaining

      const m1 = Matrix3.zero();
      const m2 = Matrix3.identity();
      m1.subtract(m2);
      console.log(m1.lements);
      // [ -1, 0, 0,
      // 0, -1, 0,
      // 0, 0, -1 ]
    • Multiplies all elements by scalar (mutates this)

      Parameters

      • scalar: number

      Returns Matrix3

      this instance, for method chaining

      const m = Matrix3.identity();
      m.multiplyScalar(2);
      console.log(m.elements);
      // [ 2, 0, 0,
      // 0, 2, 0,
      // 0, 0, 2 ]
    • Divides all elements by scalar (mutates this)

      Parameters

      • scalar: number

      Returns Matrix3

      this instance, for method chaining

      const m = Matrix3.identity();
      m.divideScalar(2);
      console.log(m.elements);
      // [ 0.5, 0, 0,
      // 0, 0.5, 0,
      // 0, 0, 0.5 ]
    • Multiplies this matrix by other matrix (mutates this)

      Parameters

      Returns Matrix3

      this instance, for method chaining

      const m1 = Matrix3.identity();
      const m2 = Matrix3.zero();
      m1.multiply(m2);
      console.log(m.elements);
      // [ 0, 0, 0,
      // 0, 0, 0,
      // 0, 0, 0 ]
    • Calculates determinant of this matrix (pure)

      Returns number

      determinant of this matrix