Package geomerative
Class RMatrix
- java.lang.Object
-
- geomerative.RMatrix
-
public class RMatrix extends java.lang.Object
RMatrix is a very simple interface for creating, holding 3x3 matrices with the most common 2D affine transformations such as translation, rotation, scaling and shearing. We only have access to the first to rows of the matrix the last row is considered a constant 0, 0, 1 in order to have better performance.
-
-
Constructor Summary
Constructors Constructor Description RMatrix()
Create a new identity matrix.RMatrix(float m00, float m01, float m02, float m10, float m11, float m12)
Create a new matrix given the coefficients.RMatrix(RMatrix src)
Copy a matrix.RMatrix(java.lang.String transformationString)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(float n00, float n01, float n02, float n10, float n11, float n12)
Multiply the matrix with another matrix.void
apply(RMatrix rhs)
Multiply the matrix with another matrix.void
rotate(float angle)
void
rotate(float angle, float vx, float vy)
Apply a rotation to the matrix, given an angle and optionally a rotation center.void
rotate(float angle, RPoint v)
Apply a rotation to the matrix, given an angle and optionally a rotation center.void
scale(float s)
void
scale(float sx, float sy)
void
scale(float s, float x, float y)
Apply a scale to the matrix, given scaling factors and optionally a scaling center.void
scale(float sx, float sy, float x, float y)
Apply a scale to the matrix, given scaling factors and optionally a scaling center.void
scale(float sx, float sy, RPoint p)
Apply a scale to the matrix, given scaling factors and optionally a scaling center.void
scale(float s, RPoint p)
Apply a scale to the matrix, given scaling factors and optionally a scaling center.void
shear(float shx, float shy)
Use this to apply a shearing to the matrix.void
skewX(float angle)
Use this to apply a skewing to the matrix.void
skewY(float angle)
void
translate(float tx)
void
translate(float tx, float ty)
Apply a translation to the matrix, given the coordinates.void
translate(RPoint t)
Apply a translation to the matrix, given a point.
-
-
-
Constructor Detail
-
RMatrix
public RMatrix(float m00, float m01, float m02, float m10, float m11, float m12)
Create a new matrix given the coefficients.- Parameters:
m00
- coefficient 00 of the matrixm01
- coefficient 01 of the matrixm02
- coefficient 02 of the matrixm10
- coefficient 10 of the matrixm11
- coefficient 11 of the matrixm12
- coefficient 12 of the matrix
-
RMatrix
public RMatrix()
Create a new identity matrix.
-
RMatrix
public RMatrix(RMatrix src)
Copy a matrix.- Parameters:
src
- source matrix from where to copy the matrix
-
RMatrix
public RMatrix(java.lang.String transformationString)
-
-
Method Detail
-
apply
public void apply(float n00, float n01, float n02, float n10, float n11, float n12)
Multiply the matrix with another matrix. This is mostly use to chain transformations.- Parameters:
n00
- coefficient 00 of the matrix to be appliedn01
- coefficient 01 of the matrix to be appliedn02
- coefficient 02 of the matrix to be appliedn10
- coefficient 10 of the matrix to be appliedn11
- coefficient 11 of the matrix to be appliedn12
- coefficient 12 of the matrix to be applied
-
apply
public void apply(RMatrix rhs)
Multiply the matrix with another matrix. This is mostly use to chain transformations.- Parameters:
rhs
- right hand side matrix
-
translate
public void translate(float tx, float ty)
Apply a translation to the matrix, given the coordinates.- Parameters:
tx
- x coordinate translationty
- y coordinate translation
-
translate
public void translate(float tx)
-
translate
public void translate(RPoint t)
Apply a translation to the matrix, given a point.- Parameters:
t
- vector translation
-
rotate
public void rotate(float angle, float vx, float vy)
Apply a rotation to the matrix, given an angle and optionally a rotation center.- Parameters:
angle
- the angle of rotation to be appliedvx
- the x coordinate of the center of rotationvy
- the y coordinate of the center of rotation
-
rotate
public void rotate(float angle)
-
rotate
public void rotate(float angle, RPoint v)
Apply a rotation to the matrix, given an angle and optionally a rotation center.- Parameters:
angle
- the angle of rotation to be appliedv
- the position vector of the center of rotation
-
scale
public void scale(float sx, float sy, float x, float y)
Apply a scale to the matrix, given scaling factors and optionally a scaling center.- Parameters:
sx
- the scaling coefficient over the x axissy
- the scaling coefficient over the y axisx
- x coordinate of the position vector of the center of the scalingy
- y coordinate of the position vector of the center of the scaling
-
scale
public void scale(float sx, float sy)
-
scale
public void scale(float s, float x, float y)
Apply a scale to the matrix, given scaling factors and optionally a scaling center.- Parameters:
s
- the scaling coefficient for a uniform scalingx
- x coordinate of the position vector of the center of the scalingy
- y coordinate of the position vector of the center of the scaling
-
scale
public void scale(float sx, float sy, RPoint p)
Apply a scale to the matrix, given scaling factors and optionally a scaling center.- Parameters:
sx
- the scaling coefficient over the x axissy
- the scaling coefficient over the y axisp
- the position vector of the center of the scaling
-
scale
public void scale(float s, RPoint p)
Apply a scale to the matrix, given scaling factors and optionally a scaling center.- Parameters:
s
- the scaling coefficient for a uniform scalingp
- the position vector of the center of the scaling
-
scale
public void scale(float s)
-
skewX
public void skewX(float angle)
Use this to apply a skewing to the matrix.- Parameters:
angle
- skewing angle
-
skewY
public void skewY(float angle)
-
shear
public void shear(float shx, float shy)
Use this to apply a shearing to the matrix.- Parameters:
shx
- x coordinate shearingshy
- y coordinate shearing
-
-