public final class Matrix extends Object
Class represents transformation matrix.
Constructor and Description |
---|
Matrix()
Constructor creates stanrard 1 to 1 matrix: [ A B C D E F ] = [ 1, 0, 0, 1, 0, 0]
|
Matrix(double[] matrixArray)
Constructor accepts a matrix with following array representation: [ A B C D E F ]
|
Matrix(double a,
double b,
double c,
double d,
double e,
double f)
Initializes transformation matrix with specified coefficients.
|
Matrix(float[] matrixArray)
Constructor accepts a matrix with following array representation: [ A B C D E F ]
|
Matrix(Matrix matrix)
Constructor accepts a matrix to create a copy
|
Modifier and Type | Method and Description |
---|---|
Matrix |
add(Matrix other)
Adds matrix to other matrix.
|
boolean |
equals(Object obj)
Compares matrix agains other object.
|
double |
getA()
Get A member of the transformation matrix.
|
static double |
getAngle(int rotation)
Transaltes rotation into angle (degrees)
|
double |
getB()
Get B member of the transformation matrix.
|
double |
getC()
Get C member of the transformation matrix.
|
double |
getD()
Get D member of the transformation matrix.
|
double[] |
getData()
Gets data of Matrix as array.
|
double |
getE()
Get E member of the transformation matrix.
|
float[] |
getElements()
Elements of the matrix.
|
double |
getF()
Get F member of the transformation matrix.
|
com.aspose.pdf.engine.data.IPdfArray |
getMatrix(com.aspose.pdf.engine.data.ITrailerable trailer)
Translates matrix into PDF array obect.
|
int |
hashCode()
Hash-code for object.
|
static boolean |
isInt16(double value)
For Internal usage only
|
boolean |
isInt16Values()
For Internal usage only
|
Matrix |
multiply(Matrix other)
Multiplies the matrix by other matrix.
|
Matrix |
reverse()
Calculates reverse matrix.
|
static Matrix |
rotation(double alpha)
Creates matrix for given rotation angle.
|
static Matrix |
rotation(int rotation)
Creates matrix for given rotation.
|
static Matrix |
scale(double x,
double y)
Creates matrix for given scale.
|
void |
scale(double x,
double y,
double[] x1,
double[] y1)
Scales x and y with the matrix using the following formula:
x1 = A*x + C*y;
y1 = B*x + D*y;
|
void |
setA(double value)
Set A member of the transformation matrix.
|
void |
setB(double value)
Set B member of the transformation matrix.
|
void |
setC(double value)
Set C member of the transformation matrix.
|
void |
setD(double value)
Set D member of the transformation matrix.
|
void |
setE(double value)
Set E member of the transformation matrix.
|
void |
setF(double value)
Set F member of the transformation matrix.
|
static Matrix |
skew(double alpha,
double beta)
Creates matrix for given rotation angle.
|
String |
toString()
Returns text representation of the matrix.
|
void |
transform(double x,
double y,
double[] x1,
double[] y1)
Transforms coordinates using this matrix.
|
Point |
transform(Point p)
Transforms point using this matrix.
|
Rectangle |
transform(Rectangle rect)
Transformes rectangle.
|
void |
unScale(double x1,
double y1,
double[] x,
double[] y)
Scales back x1 and y1 and returns x and y before the matrix transformation using the following formula:
x = (D * x1 - C * y1) / (A * D - C * B);
y = (A* y1 - B* x1) / (A* D - C* B);
|
void |
unTransform(double x1,
double y1,
double[] x,
double[] y)
Transforms back x1 and y1 and returns x and y before the matrix transformation using the following formula:
x = (D * x1 - C * y1 + C * F) / (A * D - C * B)
y = (A * y1 - B * x1 + B * E) / (A * D - C * B).
|
public Matrix()
Constructor creates stanrard 1 to 1 matrix: [ A B C D E F ] = [ 1, 0, 0, 1, 0, 0]
Matrix m = new Matrix();
public Matrix(double[] matrixArray)
Constructor accepts a matrix with following array representation: [ A B C D E F ]
double[] c = new double[] { 1, 0, 0, 1, 10, 20 }; Matrix m = new Matrix(c);
matrixArray
- Matrix data array.public Matrix(float[] matrixArray)
Constructor accepts a matrix with following array representation: [ A B C D E F ]
double[] c = new double[] { 1, 0, 0, 1, 10, 20 }; Matrix m = new Matrix(c);
matrixArray
- Matrix data array.public Matrix(Matrix matrix)
Constructor accepts a matrix to create a copy
matrix
- Matrix object.public Matrix(double a, double b, double c, double d, double e, double f)
Initializes transformation matrix with specified coefficients.
Matrix m = new Matrix(1, 0, 0, 1, 3, 3);
a
- A matrix value.b
- B matrix value.c
- C matrix value.d
- D matrix value.e
- E matrix value.f
- F matrix value.public final double[] getData()
Gets data of Matrix as array.
public double getA()
Get A member of the transformation matrix.
public void setA(double value)
Set A member of the transformation matrix.
value
- double valuepublic double getB()
Get B member of the transformation matrix.
public void setB(double value)
Set B member of the transformation matrix.
value
- double valuepublic double getC()
Get C member of the transformation matrix.
public void setC(double value)
Set C member of the transformation matrix.
value
- double valuepublic double getD()
Get D member of the transformation matrix.
public void setD(double value)
Set D member of the transformation matrix.
value
- double valuepublic double getE()
Get E member of the transformation matrix.
public void setE(double value)
Set E member of the transformation matrix.
value
- double valuepublic double getF()
Get F member of the transformation matrix.
public void setF(double value)
Set F member of the transformation matrix.
value
- double valuepublic float[] getElements()
Elements of the matrix.
public String toString()
Returns text representation of the matrix.
public boolean equals(Object obj)
Compares matrix agains other object.
public com.aspose.pdf.engine.data.IPdfArray getMatrix(com.aspose.pdf.engine.data.ITrailerable trailer)
Translates matrix into PDF array obect.
trailer
- Trailerable objectpublic static Matrix rotation(double alpha)
Creates matrix for given rotation angle.
Matrix m = Matrix.Rotation(Math.PI / 2);
alpha
- Rotation angle in radians.public static Matrix rotation(int rotation)
Creates matrix for given rotation.
rotation
- Rotation. Valid values are: None, on90, on180, on270public static Matrix skew(double alpha, double beta)
Matrix m = Matrix.skew(Math.PI / 2, Math.PI / 2);
alpha
- Skew x angle in radians.beta
- Skew y angle in radians.public static Matrix scale(double x, double y)
Creates matrix for given scale.
Matrix m = Matrix.scale(x, y);
x
- Scale x.y
- Scale y.public final void scale(double x, double y, double[] x1, double[] y1)
Scales x and y with the matrix using the following formula: x1 = A*x + C*y; y1 = B*x + D*y;
x
- Input X coordinatey
- Input Y coordinatex1
- Output X coordinatey1
- Output Y coordinatepublic final void unScale(double x1, double y1, double[] x, double[] y)
Scales back x1 and y1 and returns x and y before the matrix transformation using the following formula: x = (D * x1 - C * y1) / (A * D - C * B); y = (A* y1 - B* x1) / (A* D - C* B);
x1
- Input X coordinatey1
- Input Y coordinatex
- Output X coordinatey
- Output Y coordinatepublic static double getAngle(int rotation)
Transaltes rotation into angle (degrees)
double angle = Matrix.getAngle(Rotation.on90); Matrix m = Matrix.rotation(angle);
rotation
- Rotation value.public Matrix multiply(Matrix other)
Multiplies the matrix by other matrix.
Matrix a = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 }); Matrix b = new Matrix(new double[] { 0, -1, 1, 0, 0, 0 } ); Matrix c= a.multiply(b);
other
- Multiplier matrix.public Matrix add(Matrix other)
Adds matrix to other matrix.
other
- Matrix to be added.public Point transform(Point p)
Transforms point using this matrix.
Matrix m = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 } ); Point p = new Point(5, 5); Point p1 = m.transform(p);
p
- Point which will be transformed.public final void transform(double x, double y, double[] x1, double[] y1)
Transforms coordinates using this matrix.
Matrix m = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 } ); double x, y, x1, y1; m.transform(double x, double y, out double x1, out double y1);
x
- X coordinate.y
- Y coordinate.x1
- Transformed X coordinate.y1
- Transformed Y coordinate.public final void unTransform(double x1, double y1, double[] x, double[] y)
Transforms back x1 and y1 and returns x and y before the matrix transformation using the following formula: x = (D * x1 - C * y1 + C * F) / (A * D - C * B) y = (A * y1 - B * x1 + B * E) / (A * D - C * B).
x1
- Input X coordinatey1
- Input Y coordinatex
- Output X coordinatey
- Output Y coordinatepublic Rectangle transform(Rectangle rect)
Transformes rectangle. If angle is not 90 * N degrees then bounding rectangle is returned.
Matrix m = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 } ); Rectangle r = new Rectangle(0, 0, 100, 100); Rectangle r1 = m.transform(r1);
rect
- Rectangle to be transformed.public Matrix reverse()
Calculates reverse matrix.
Matrix m = Matrix.rotation(Math.PI / 2); Matrix m1 = m.reverse();
public int hashCode()
Hash-code for object.
public static boolean isInt16(double value)
value
- double valuepublic boolean isInt16Values()
Copyright © 2023 Aspose. All Rights Reserved.