Sg2.0
Matrix
Packages

Matrix represents an affine transformation between two coordinate spaces in 2 dimensions. Such a transform preserves the "straightness" and "parallelness" of lines. The transform is built from a sequence of translations, scales, flips, rotations, and shears.
The transformation can be represented using matrix math on a 3x3 array. Given (x, y), the transformation (x', y') can be found by:

 [ x']   [ scaleX shearX translateX ] [ x ]   [ scaleX * x + shearX * y + translateX ]
 [ y'] = [ shearY scaleY translateY ] [ y ] = [ shearY * x + scaleY * y + translateY ]
 [ 1 ]   [ 0      0      1          ] [ 1 ]   [ 1                                    ]
 
The bottom row of the matrix is constant, so a transform can be uniquely represented (as in toString()) by "[[scaleX, shearX, translateX], [shearY, scaleY, translateY]]".

Constructors

Create a new matrix which copies the given one.
Parameters:
m: Matrix - the matrix to copy
Throws:
NullPointerException - if m is null
Create a new matrix from the given AWT AffineTransform.
Parameters:
at: Matrix - the transform to copy
Throws:
NullPointerException - if at is null
Construct a transform with the given matrix entries:
  [ scaleX shearX translateX ]
  [ shearY scaleY translateY ]
  [ 0      0      1          ]
 
Parameters:
scaleX: Number - the x scaling component
shearY: Number - the y shearing component
shearX: Number - the x shearing component
scaleY: Number - the y scaling component
translateX: Number - the x translation component
translateY: Number
Construct a matrix from a sequence of numbers. The array must have at least 4 entries, which has a translation factor of 0; or 6 entries, for specifying all parameters:
 [ values[0] values[2] (values[4]) ]
 [ values[1] values[3] (values[5]) ]
 [ 0         0         1           ]
 
Parameters:
values: Array of Number - the matrix to copy from, with at least 4 (6) entries
Throws:
NullPointerException - if values is null
ArrayIndexOutOfBoundsException - if values is too small

Properties

Read-only.
Returns:
Boolean
Returns:
Number
Returns:
Number
Returns:
Number
Returns:
Number
Read-only.
Returns:
Boolean
Returns:
Number
Returns:
Number

Functions

Returns a copy of this Matrix object.
Returns:
Object - an copy of this Matrix object.
Creates the inverse transformation of the object. If the object is not invertible (in which case isSingular() returns true), invert() returns null, otherwise the object itself is modified and a reference to it is returned.
Returns:
Matrix - the inversed matrix, or null, if the matrix is singular
Parameters:
theta: Number
centerX: Number
centerY: Number
Returns:
Parameters:
theta: Number
center: Point
Returns:
Parameters:
scaleX: Number
scaleY: Number
Returns:
Parameters:
scale: Point
Returns:
Parameters:
shearX: Number
shearY: Number
Returns:
Parameters:
x: Number
y: Number
Returns:
Parameters:
src: Point
Returns:
Concatenates the matrix with a translation matrix that translates by (x, y). The object itself is modified and a reference to it is returned.
Parameters:
x: Number
y: Number
Returns:
Matrix - the translated matrix
Parameters:
pt: Point
Returns: