|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.paulhertz.geom.Matrix3
public class Matrix3
Maintains a 3 x 3 matrix for accumulating affine transforms (translate, scale, rotate, shear). The matrix is used as a CTM or current transformation matrix for 2D graphics state. Also provides static utility methods for operations with 3 x 3 matrices. Parts of Matrix3 are adapted from the 2d and 3d Vector C Library by Andrew Glassner from "Graphics Gems", Academic Press, 1990. See http://www.graphicsgems.org/.
| Constructor Summary | |
|---|---|
Matrix3()
instantiates this Matrix3 as a unit matrix, i.e.: |
|
Matrix3(double[][] element)
instantiates a Matrix3 from a 3 x 3 array of doubles |
|
Matrix3(Matrix3 matx)
instantiates a Matrix3 from the element array of another matrix3 |
|
| Method Summary | |
|---|---|
static double[][] |
copyMatrix3(double[][] min,
double[][] mout)
Copies one matrix to another matrix. |
static Matrix3 |
copyMatrix3(Matrix3 min,
Matrix3 mout)
Copies one matrix to another matrix. |
double[][] |
getCTM()
Returns a copy of the internal matrix of this Matrix3. |
double[][] |
getElements()
Returns a copy of the internal matrix of this Matrix3 as a 3x3 array. |
void |
initCTM()
Sets the internal matrix of this CTM to the unit matrix. |
static double[][] |
initMatrix3(double[][] anyM3)
Initializes a matrix (3x3 array) to the unit matrix. |
static Matrix3 |
initMatrix3(Matrix3 anyM3)
Initializes a matrix (Matrix3) to the unit matrix. |
void |
initMatxGlobals()
High level method to initialize internal matrix to unit matrix. |
boolean |
isNormalCTM()
Checks whether the internal matrix of this Matrix3 is normal, sets gIsNormal. |
static boolean |
isNormalMatrix3(double[][] anyM3)
Checks whether a matrix is normal (column 3 is 0 0 1). |
static boolean |
isNormalMatrix3(Matrix3 anyM3)
Checks whether a matrix is normal (column 3 is 0 0 1). |
static double[][] |
matrixMultiply(double[][] a,
double[][] b,
double[][] c)
Multiplies together matrices a and b, returns the result in c. |
static Matrix3 |
matrixMultiply(Matrix3 a,
Matrix3 b,
Matrix3 c)
Multiplies together matrices a and b, returns the result in c. |
void |
multiplyInRotation()
Low level method to concatenate rotation operation gAng into internal matrix. |
void |
multiplyInScale()
Low level method to concatenate scaling operations gSX and gSY into internal matrix. |
void |
multiplyInShear()
Low level method to concatenate shearing operations gShX and gShY into internal matrix. |
void |
multiplyInTranslation()
Low level method to concatenate translation operations gTX and gTY into internal matrix. |
Point2D.Double |
multiplyPointByNormalCTM(double x,
double y,
Point2D.Double pout)
Multiplies point (x, y) by the internal matrix of this Matrix3, returns result in pout. |
Point2D.Double |
multiplyPointByNormalCTM(Point2D.Double pin,
Point2D.Double pout)
Multiplies point pin by the internal matrix of this Matrix3, returns result in pout. |
static Point2D.Double |
multiplyPointByNormalMatrix3(double x,
double y,
Point2D.Double pout,
double[][] anyM3)
Multiplies a point by a normal matrix. |
static Point2D.Double |
multiplyPointByNormalMatrix3(double x,
double y,
Point2D.Double pout,
Matrix3 anyM3)
Multiplies a point by a normal matrix. |
static Point2D.Double |
multiplyPointByNormalMatrix3(Point2D.Double pin,
Point2D.Double pout,
double[][] anyM3)
Multiplies a point by a normal matrix. |
static Point2D.Double |
multiplyPointByNormalMatrix3(Point2D.Double pin,
Point2D.Double pout,
Matrix3 anyM3)
Multiplies a point by a normal matrix. |
Point2D.Double |
multiplyPointByProjCTM(double x,
double y,
Point2D.Double pout)
Multiplies point (x, y) by the internal matrix of this Matrix3, returns result in pout. |
Point2D.Double |
multiplyPointByProjCTM(Point2D.Double pin,
Point2D.Double pout)
Multiplies point pin by the internal matrix of this Matrix3, returns result in pout. |
static Point2D.Double |
multiplyPointByProjMatrix3(double x,
double y,
Point2D.Double pout,
double[][] anyM3)
Multiplies a point by a projective matrix. |
static Point2D.Double |
multiplyPointByProjMatrix3(double x,
double y,
Point2D.Double pout,
Matrix3 anyM3)
Multiplies a point by a projective matrix. |
static Point2D.Double |
multiplyPointByProjMatrix3(Point2D.Double pin,
Point2D.Double pout,
double[][] anyM3)
Multiplies a point by a projective matrix. |
static Point2D.Double |
multiplyPointByProjMatrix3(Point2D.Double pin,
Point2D.Double pout,
Matrix3 anyM3)
Multiplies a point by a projective matrix. |
void |
reflectCTM(boolean reflectHorizontal)
Concatenates a reflection on the x- or y-axis into the internal matrix of this Matrix3. |
void |
reflectCTM(boolean reflectHorizontal,
double xTrans,
double yTrans)
High-level method to concatenate a translation followed by a reflection on the x- or y-axis into the internal matrix of this Matrix3. |
static double[][] |
reflectMatrix3(boolean reflectHorizontal,
double[][] anyM3)
Reflects a matrix about the horizontal or vertical axis. |
static Matrix3 |
reflectMatrix3(boolean reflectHorizontal,
Matrix3 anyM3)
Reflects a matrix about the horizontal or vertical axis. |
void |
rotateCTM(double angle)
High level method to concatenate rotation by angle radians into the internal matrix of this Matrix3. |
static double[][] |
rotateMatrix3(double angle,
double[][] anyM3)
Concatenates a rotation into a matrix. |
static Matrix3 |
rotateMatrix3(double angle,
Matrix3 anyM3)
Concatenates a rotation into a matrix. |
void |
scaleCTM(double xScale,
double yScale)
High level method to concatenate scaling in x and y into the internal matrix of this Matrix3. |
static double[][] |
scaleMatrix3(double xScale,
double yScale,
double[][] anyM3)
Concatenates scaling on x and y axis into a matrix. |
static Matrix3 |
scaleMatrix3(double xScale,
double yScale,
Matrix3 anyM3)
Concatenates scaling on x and y axis into a matrix. |
void |
setCTM(double[][] elems)
Copies the values in the 3x3 array elems to the internal matrix of this Matrix3. |
void |
setCTM(double a,
double b,
double c,
double d,
double tx,
double ty)
Sets the values of first two columns of matrix elems. |
void |
setCTM(Matrix3 newCTM)
Copies the internal matrix of newCTM to the internal matrix of this Matrix3. |
void |
setRotation(double theta)
Low level method to set gAng, used internally. |
void |
setScale(double xScale,
double yScale)
Low level method to set gSX and gSY, used internally. |
void |
setShear(double xShear,
double yShear)
Low level method to set gShX and gShY, used internally. |
void |
setTranslation(double xTrans,
double yTrans)
Low level method to set gTX and gTY, used internally. |
void |
shearCTM(double xShear,
double yShear)
Concatenates a shear on the x and y axes into the internal matrix of this Matrix3. |
static double[][] |
shearMatrix3(double shX,
double shY,
double[][] anyM3)
Shears a matrix. |
static Matrix3 |
shearMatrix3(double shX,
double shY,
Matrix3 anyM3)
Shears a matrix. |
ArrayList<Point2D.Double> |
transformList(ArrayList<Point2D.Double> pts)
Transforms a list of points by current transformation matrix. |
void |
translateCTM(double xTrans,
double yTrans)
High level method to concatenate translation in x and y into the internal matrix of this Matrix3. |
static double[][] |
translateMatrix3(double xTrans,
double yTrans,
double[][] anyM3)
Concatenates translations on x and y axis into a matrix. |
static Matrix3 |
translateMatrix3(double xTrans,
double yTrans,
Matrix3 anyM3)
Concatenates translations on x and y axis into a matrix. |
static double[][] |
transposeMatrix3(double[][] a,
double[][] b)
Transposes matrix a, returns the result in matrix b. |
static Matrix3 |
transposeMatrix3(Matrix3 a,
Matrix3 b)
Transposes matrix a, returns the result in matrix b. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Matrix3(double[][] element)
element - a 3 x 3 array of doublespublic Matrix3(Matrix3 matx)
matx - a Matrix3public Matrix3()
1 0 0
0 1 0
0 0 1
| Method Detail |
|---|
public static Matrix3 matrixMultiply(Matrix3 a,
Matrix3 b,
Matrix3 c)
a - a Matrix3b - a Matrix3c - a Matrix that will contain result of multiplying a and b
public static double[][] matrixMultiply(double[][] a,
double[][] b,
double[][] c)
a - a 3 x 3 array of doublesb - a 3 x 3 array of doublesc - a 3 x 3 array of doubles that will contain result of multiplying a and b
public static Matrix3 transposeMatrix3(Matrix3 a,
Matrix3 b)
a - a Matrix3b - a Matrix3 that receives the transpose of a
public static double[][] transposeMatrix3(double[][] a,
double[][] b)
a - a 3 x 3 array of doublesb - a 3 x 3 array of doubles that receives the transpose of a
public void setScale(double xScale,
double yScale)
scaleCTM to set CTM and gSX, gSY.
xScale - scaling on x-axisyScale - scaling on y-axis
public void setTranslation(double xTrans,
double yTrans)
translateCTM to set CTM and gTX, gTY.
xTrans - translation along x-axisyTrans - translatiion along y-axispublic void setRotation(double theta)
rotateCTM to set CTM and gAng.
theta - angle to rotate, in radians
public void setShear(double xShear,
double yShear)
shearCTM to set CTM and gShX, gShY.
xShear - yShear - public void multiplyInScale()
translateCTM instead.
public void multiplyInTranslation()
translateCTM instead.
public void multiplyInRotation()
rotateCTM instead.
public void multiplyInShear()
shearCTM instead.
public void initMatxGlobals()
public void setCTM(Matrix3 newCTM)
newCTM - a Matrix3public void setCTM(double[][] elems)
elems - a 3 x 3 array of double
public void setCTM(double a,
double b,
double c,
double d,
double tx,
double ty)
a - value for element[0][0], scaling on x-axisb - value for element[0][1]c - value for element[1][0]d - value for element[1][1], scaling on y-axistx - value for element[2][0], translation on x-axisty - value for element[2][1], translation on y-axispublic double[][] getCTM()
public void initCTM()
public double[][] getElements()
public boolean isNormalCTM()
public void translateCTM(double xTrans,
double yTrans)
xTrans - translation on the x-axisyTrans - translation on the y-axis
public void scaleCTM(double xScale,
double yScale)
xScale - scaling on the x-axisyScale - scaling on the y-axispublic void rotateCTM(double angle)
angle - the angle to rotate
public void reflectCTM(boolean reflectHorizontal,
double xTrans,
double yTrans)
reflectHorizontal - true if reflection in on x-axis, false if reflection in on y-axisxTrans - displacement on x-axis applied prior to reflectionyTrans - displacement on y-axis applied prior to reflectionpublic void reflectCTM(boolean reflectHorizontal)
reflectHorizontal - true if reflection is on x-axis, false if reflection is on y-axis
public void shearCTM(double xShear,
double yShear)
xShear - shearing on x-axisyShear - shearing on y-axis
public Point2D.Double multiplyPointByNormalCTM(Point2D.Double pin,
Point2D.Double pout)
pin - point to transform by current transformation matrixpout - stores value of point that results from transform
public Point2D.Double multiplyPointByNormalCTM(double x,
double y,
Point2D.Double pout)
x - x-coordinate of pointy - y-coordinate of pointpout - stores value of point that results from transform
public Point2D.Double multiplyPointByProjCTM(Point2D.Double pin,
Point2D.Double pout)
pin - point to transform by current transformation matrixpout - stores value of point that results from transform
public Point2D.Double multiplyPointByProjCTM(double x,
double y,
Point2D.Double pout)
x - x-coordinate of pointy - y-coordinate of pointpout - stores value of point that results from transform
public ArrayList<Point2D.Double> transformList(ArrayList<Point2D.Double> pts)
pts - an ArrayList of points
public static Matrix3 copyMatrix3(Matrix3 min,
Matrix3 mout)
min - the source matrixmout - the target matrix
public static double[][] copyMatrix3(double[][] min,
double[][] mout)
min - the source matrix, 3x3 array of doublemout - the target matrix, 3x3 array of double
public static Matrix3 initMatrix3(Matrix3 anyM3)
anyM3 - the matrix to be initialized
public static double[][] initMatrix3(double[][] anyM3)
anyM3 - the matrix to be initialized, a 3x3 array of double
public static boolean isNormalMatrix3(Matrix3 anyM3)
anyM3 - a Matrix3
public static boolean isNormalMatrix3(double[][] anyM3)
anyM3 - a 3x3 array of double
public static Matrix3 translateMatrix3(double xTrans,
double yTrans,
Matrix3 anyM3)
xTrans - translation on x-axisyTrans - translation on y-axisanyM3 - matrix into which translations are concatenated
public static double[][] translateMatrix3(double xTrans,
double yTrans,
double[][] anyM3)
xTrans - translation on x-axisyTrans - translation on y-axisanyM3 - matrix into which translations are concatenated, a 3x3 array of double
public static Matrix3 scaleMatrix3(double xScale,
double yScale,
Matrix3 anyM3)
xScale - scaling on x-axisyScale - scaling on y-axisanyM3 - matrix into which scalings are concatenated
public static double[][] scaleMatrix3(double xScale,
double yScale,
double[][] anyM3)
xScale - scaling on x-axisyScale - scaling on y-axisanyM3 - matrix into which scalings are concatenated, a 3x3 arry of double
public static Matrix3 rotateMatrix3(double angle,
Matrix3 anyM3)
angle - angle of rotation in radiansanyM3 - the matrix to transform
public static double[][] rotateMatrix3(double angle,
double[][] anyM3)
angle - angle of rotation in radiansanyM3 - the matrix to transform, a 3x3 array of double
public static Matrix3 reflectMatrix3(boolean reflectHorizontal,
Matrix3 anyM3)
reflectHorizontal - true if reflection is around the x-axis, false if it's around the y-axisanyM3 - a matrix encapsulated as a Matrix3.
public static double[][] reflectMatrix3(boolean reflectHorizontal,
double[][] anyM3)
reflectHorizontal - true if reflection is around the x-axis, false if it's around the y-axisanyM3 - a 3x3 array of double
public static Matrix3 shearMatrix3(double shX,
double shY,
Matrix3 anyM3)
shX - x-axis shearingshY - y-axis shearinganyM3 - a Matrix3 to which the shearing operation will be concatenated.
public static double[][] shearMatrix3(double shX,
double shY,
double[][] anyM3)
shX - x-axis shearingshY - y-axis shearinganyM3 - a 3x3 array to which the shearing operation will be concatenated.
public static Point2D.Double multiplyPointByNormalMatrix3(Point2D.Double pin,
Point2D.Double pout,
Matrix3 anyM3)
pin - a point to transformpout - the transformed pointanyM3 - the matrix performing the transform
public static Point2D.Double multiplyPointByNormalMatrix3(double x,
double y,
Point2D.Double pout,
Matrix3 anyM3)
x - x-coordinate of pointy - y-coordinate of pointpout - the transformed pointanyM3 - the matrix performing the transform
public static Point2D.Double multiplyPointByNormalMatrix3(Point2D.Double pin,
Point2D.Double pout,
double[][] anyM3)
pin - a point to transformpout - the transformed pointanyM3 - the matrix performing the transform, a 3x3 array of double
public static Point2D.Double multiplyPointByNormalMatrix3(double x,
double y,
Point2D.Double pout,
double[][] anyM3)
x - x-coordinate of pointy - y-coordinate of pointpout - the transformed pointanyM3 - the matrix performing the transform, a 3x3 array of double
public static Point2D.Double multiplyPointByProjMatrix3(Point2D.Double pin,
Point2D.Double pout,
Matrix3 anyM3)
pin - a point to transformpout - the transformed pointanyM3 - the matrix performing the transform
public static Point2D.Double multiplyPointByProjMatrix3(double x,
double y,
Point2D.Double pout,
Matrix3 anyM3)
x - x-coordinate of pointy - y-coordinate of pointpout - the transformed pointanyM3 - the matrix performing the transform
public static Point2D.Double multiplyPointByProjMatrix3(Point2D.Double pin,
Point2D.Double pout,
double[][] anyM3)
pin - a point to transformpout - the transformed pointanyM3 - the matrix performing the transform, a 3x3 array of double
public static Point2D.Double multiplyPointByProjMatrix3(double x,
double y,
Point2D.Double pout,
double[][] anyM3)
x - x-coordinate of pointy - y-coordinate of pointpout - the transformed pointanyM3 - the matrix performing the transform, a 3x3 array of double
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||