|
TinyLine v2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.tinyline.tiny2d.TinyMatrix
The TinyMatrix class represents a 2D affine transformation matrix. By modifying a TinyMatrix, objects can be scaled, rotated, translated, or transformed. TinyMatrix is represented by a transformation matrix written as:
[ a b 0 ] [ c d 0 ] [ tx ty 1 ]Here tx and ty are single fixed point numbers and a,b,c,d are double fixed point numbers.
The transformations could be specified as combinations of those listed below:
[1 0 0 1 tx ty],
where tx and ty are the distances to translate coordinates in X and Y.
[sx 0 0 sy 0 0].
One unit in the X and Y directions in the new coordinate system equals
sx and sy units in the previous coordinate system.
[cos(a) sin(a) -sin(a) cos(a) 0 0],
which has the effect of rotating the coordinate system axes by angle a.
[1 0 tan(a) 1 0 0],
which has the effect of skewing X
coordinates by angle a.
[1 tan(a) 0 1 0 0],
which has the effect of skewing Y
coordinates by angle a.
If several transformations are applied, the order is important. In general, trnasformations should be done in the following order: translate, rotate, scale.
Coordinate trnasformations could be expressed as:
[ a b 0 ]
[x' y' 1 ] = [x y 1] [ c d 0 ]
[ tx ty 1 ]
By carring out the multiplication:
x' = ax + cy + tx;
y' = bx + dy + ty;
If a series of transformations is carried out, the transformatios can be multiplied together to produce a single equivalent transformation.
| Field Summary | |
int |
a
The X coordinate scaling element of the 3x3 matrix. |
int |
angle
A convenience attribute for TRANSFORM_ROTATE, TRANSFORM_SKEWX and TRANSFORM_SKEWY. |
int |
b
The X coordinate shearing element of the 3x3 matrix. |
int |
c
The Y coordinate shearing element of the 3x3 matrix. |
int |
d
The Y coordinate scaling element of the 3x3 matrix. |
int |
rotateOriginX
The rotate is about the point with rotateOriginX X coordinate. |
int |
rotateOriginY
The rotate is about the point with rotateOriginY Y coordinate. |
static byte |
TRANSFORM_MATRIX
A 'matrix(...)' transformation type |
static byte |
TRANSFORM_ROTATE
A 'rotate(...)' transformation type |
static byte |
TRANSFORM_SCALE
A 'scale(...)' transformation type |
static byte |
TRANSFORM_SKEWX
A 'skewX(...)' transformation type |
static byte |
TRANSFORM_SKEWY
A 'skewY(...)' transformation type |
static byte |
TRANSFORM_TRANSLATE
A 'translate(...)' transformation type |
static byte |
TRANSFORM_UNKNOWN
A transformation type is not one of predefined types. |
int |
tx
The X coordinate of the translation element of the 3x3 matrix. |
int |
ty
The Y coordinate of the translation element of the 3x3 matrix. |
byte |
type
The transformation type of the value as specified by one of the constants specified. |
| Constructor Summary | |
TinyMatrix()
Constructs a new TinyMatrix representing the Identity transformation |
|
TinyMatrix(TinyMatrix src)
Constructs a new TinyMatrix that is a copy of the specified TinyMatrix object. |
|
| Method Summary | |
void |
concatenate(TinyMatrix matrix1)
Concatenates an TinyMatrix matrix1 to this TinyMatrix . |
void |
copy(TinyMatrix src)
Copyies TinyMatrix src to this TinyMatrix . |
TinyMatrix |
inverse()
Returns an TinyMatrix object representing the
inverse transformation. |
void |
preConcatenate(TinyMatrix matrix)
Concatenates an TinyMatrix matrix to this TinyMatrix . |
void |
reset()
Sets this TinyMatrix object to the Identity transformation |
void |
rotate(int theta,
int cx,
int cy)
Sets this transform to a rotation transformation that rotates coordinates around an anchor point. |
void |
scale(int sx,
int sy)
Sets this transform matrix to a scaling transformation. |
void |
skew(int alpha,
int betta)
Sets this transform to a skew transformation. |
void |
transform(TinyPoint point)
Transforms the specified point |
void |
transformToDev(TinyPoint point,
TinyPoint point1)
Transforms the specified point to DEVICE SPACE and stores the result in point1. |
TinyRect |
transformToDev(TinyRect rect)
Transforms the specified TinyRect rect to DEVICE SPACE. |
void |
translate(int tx,
int ty)
Sets this transform matrix to a translating transformation. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final byte TRANSFORM_UNKNOWN
public static final byte TRANSFORM_MATRIX
public static final byte TRANSFORM_TRANSLATE
public static final byte TRANSFORM_SCALE
public static final byte TRANSFORM_ROTATE
public static final byte TRANSFORM_SKEWX
public static final byte TRANSFORM_SKEWY
public byte type
public int angle
public int rotateOriginX
public int rotateOriginY
public int a
public int b
public int c
public int d
public int tx
public int ty
| Constructor Detail |
public TinyMatrix()
public TinyMatrix(TinyMatrix src)
src - the TinyMatrix object to copy| Method Detail |
public final void reset()
public final void concatenate(TinyMatrix matrix1)
[this] = [this] x [matrix]
matrix1 - the TinyMatrix object.public final void copy(TinyMatrix src)
[this] = [src]
src - the TinyMatrix object.public final void preConcatenate(TinyMatrix matrix)
[this] = [matrix] x [this]
matrix - The TinyMatrix object.public final TinyMatrix inverse()
TinyMatrix object representing the
inverse transformation.
TinyMatrix object representing the
inverse transformation.
public final void translate(int tx,
int ty)
[ 1 0 0 1 tx ty ]
tx - the distance along the x-axis in FIXED POINT precisionty - the distance along the y-axis in FIXED POINT precision
public final void scale(int sx,
int sy)
[ sx 0 0 sy 0 0 ]
sx - the factor along the x-axis in DOUBLE FIXED
POINT precisionsy - the factor along the y-axis in DOUBLE FIXED
POINT precision
public final void rotate(int theta,
int cx,
int cy)
[ cos(theta) sin(theta) -sin(theta) cos(theta) x-x*cos+y*sin y-x*sin-y*cos ]
Rotating the coordinate system axes by degrees counterclockwise.
theta - the angle of rotation in degrees
public void skew(int alpha,
int betta)
[ 1 tan(alpha) tan(betta) 1 0 0 1 ]
alpha - (in degrees) skews the x-axis by an angle alphabetta - (in degrees) skews the y-axis by an angle bettapublic final void transform(TinyPoint point)
point - the specified point to be transformed
public final void transformToDev(TinyPoint point,
TinyPoint point1)
point - the specified point to be transformedpoint1 - the specified point that stores the result.public final TinyRect transformToDev(TinyRect rect)
rect - the specified TinyRect rect to be transformed
|
TinyLine v2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||