API Docs for: 0.2.0
Show:

Q.Matrix2D Class

Extends Q.Class
Defined in: lib/quintus.js:1906
Module: Quintus

A 2D matrix class, optimized for 2D points, where the last row of the matrix will always be 0,0,1

Do not call new Q.Matrix2D - use the provided Q.matrix2D factory function for GC happiness

 var matrix = Q.matrix2d();

Good Docs here: https://github.com/heygrady/transform/wiki/calculating-2d-matrices

Used internally by Quintus for all transforms / collision detection. Most of the methods modify the matrix they are called upon and are chainable.

Methods

clone

(
  • matrix
)
chainable

Defined in lib/quintus.js:1968

multiply two matrices (leaving the result in this)

a b = [ [ a11b11 + a12b21 ], [ a11b12 + a12b22 ], [ a11b31 + a12b32 + a13 ] , [ a21b11 + a22b21 ], [ a21b12 + a22b22 ], [ a21b31 + a22*b32 + a23 ] ]

Parameters:

clone

(
  • matrix
)
chainable

Defined in lib/quintus.js:1952

Clone another matrix into this one

Parameters:

extend

(
  • className
  • properties
  • [classMethods]
)

Inherited from Q.Class: lib/quintus.js:693

Create a new Class that inherits from this class

Parameters:

  • className String
  • properties Object
    • hash of properties (init will be the constructor)
  • [classMethods] Object optional
    • optional class methods to add to the class

identity

() chainable

Defined in lib/quintus.js:1938

Turn this matrix into the identity

isA

(
  • className
)

Inherited from Q.Class: lib/quintus.js:683

See if a object is a specific class

Parameters:

  • className String
    • class to check against

release

()

Defined in lib/quintus.js:2152

Release this Matrix to be reused

rotate

(
  • radians
)
chainable

Defined in lib/quintus.js:1996

Multiply this matrix by a rotation matrix rotated radians radians

Parameters:

  • radians Float
    • angle to rotate by

rotateDeg

(
  • degrees
)
chainable

Defined in lib/quintus.js:2022

Helper method to rotate by a set number of degrees (calls rotate internally)

Parameters:

  • degrees Float

scale

(
  • sx
  • [sy]
)
chainable

Defined in lib/quintus.js:2036

Multiply this matrix by a scaling matrix scaling sx and sy

Parameters:

  • sx Float
    • scale in x dimension (scaling is uniform unless sy is provided)
  • [sy] Float optional
    • scale in the y dimension

setContextTransform

(
  • ctx
)

Defined in lib/quintus.js:2163

Set the complete transform on a Canvas 2D context

Parameters:

  • ctx Context2D
    • 2D canvs context

transform

(
  • x
  • y
)

Defined in lib/quintus.js:2075

Transform x and y coordinates by this matrix Memory Hoggy version, returns a new Array

Parameters:

  • x Float
  • y Float

transformArr

(
  • inArr
  • outArr
)
Object

Defined in lib/quintus.js:2106

Transform an array with an x and y elements by this Matrix and put the result in the outArr

Parameters:

  • inArr Array
    • input array
  • outArr Array
    • output array

Returns:

Object:

obj

transformPt

(
  • obj
)
Object

Defined in lib/quintus.js:2090

Transform an object with an x and y property by this Matrix

Parameters:

  • obj Object

Returns:

Object:

obj

transformX

(
  • x
  • y
)
Float

Defined in lib/quintus.js:2126

Return just the x coordinate transformed by this Matrix

Parameters:

  • x Float
  • y Float

Returns:

Float:

x transformed

transformY

(
  • x
  • y
)
Float

Defined in lib/quintus.js:2139

Return just the y coordinate transformed by this Matrix

Parameters:

  • x Float
  • y Float

Returns:

Float:

y transformed

translate

(
  • tx
  • ty
)
chainable

Defined in lib/quintus.js:2057

Multiply this matrix by a translation matrix translate by tx and ty

Parameters:

  • tx Float
  • ty Float