Foundation.Affine2

Row-major affine matrix optimised for homogenous 2D calculations and in-place operations.

m00 m01 m02
m10 m11 m12
0   0   1  <- hard-coded into all calculations

Implementation Details

Reference paths

  • '/foundation/_digest.ts'
  • '/foundation/core/math/_digest.ts'
  • '/foundation/core/math/Affine2.ts'

Extends

This type does not extend a base type.

Implements

This type implements the following interfaces:

All implementations exhibit default defined behaviors.

Storage types

Components m00 through m12 are stored internally in a 6-slot Float32Array. This should be kept in mind with respect to the precision of those values when accessing them.


Public Properties

m00: number

  • Matrix component.

m01: number

  • Matrix component.

m02: number

  • Matrix component.

m10: number

  • Matrix component.

m11: number

  • Matrix component.

m12: number

  • Matrix component.

Constructors

()

  • Default constructor.
  • Creates an identity matrix.

(m00: number, m01: number, m02: number, m10: number, m11: number, m12: number)

  • Explicitly initialize components.

Instance Methods

setIdentity(): Affine2

  • Sets the current matrix to an identity matrix.
  • Returns the current matrix for chaining.

multiply(a: Affine2): Affine2

  • Multiplies the current matrix by a such that this.multiply(a) is this X a (i.e. post-multiplication).
  • Returns the current matrix for chaining.

rotate(rads: number): Affine2

  • Input a rotation directly into the current matrix (no need to instantiate another matrix).
  • Returns the current matrix for chaining.

translate(x: number, y: number): Affine2

  • Input a translation directly into the current matrix (no need to instantiate another matrix).
  • Returns the current matrix for chaining.

preTranslate(x: number, y: number): Affine2

  • Directly add a translation into the current matrix's homogeneous translation components.
  • Returns the current matrix for chaining.

scale(x:number, y:number): Affine2

  • Input a scale directly into the current matrix (no need to instantiate another matrix).
  • Returns the current matrix for chaining.

invert(): Affine2

  • Inverts the current matrix in place.
  • Returns the current matrix for chaining.

Static Functions

determinant(a: Affine2): number

  • Returns the determinant of a.

isIdentity(a: Affine2): boolean

  • Returns true if a is an identity matrix.