|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.media.jai.PerspectiveTransform
A 2D perspective (or projective) transform, used by various OpImages.
A perspective transformation is capable of mapping an arbitrary quadrilateral into another arbitrary quadrilateral, while preserving the straightness of lines. Unlike an affine transformation, the parallelism of lines in the source is not necessarily preserved in the output.
Such a coordinate transformation can be represented by a 3x3
matrix which transforms homogenous source coordinates
(x, y, 1)
into destination coordinates
(x', y', w)
. To convert back into non-homogenous
coordinates (X, Y), x'
and y'
are divided by
w
.
[ x'] [ m00 m01 m02 ] [ x ] [ m00x + m01y + m02 ] [ y'] = [ m10 m11 m12 ] [ y ] = [ m10x + m11y + m12 ] [ w ] [ m20 m21 m22 ] [ 1 ] [ m20x + m21y + m22 ] x' = (m00x + m01y + m02) y' = (m10x + m11y + m12) w = (m20x + m21y + m22) X = x' / w Y = y' / w
Constructor Summary | |
PerspectiveTransform()
Constructs an identity PerspectiveTransform. |
|
PerspectiveTransform(AffineTransform transform)
Constructs a new PerspectiveTransform with the same effect as an existing AffineTransform. |
|
PerspectiveTransform(double[] flatmatrix)
Deprecated. as of JAI 1.1 Use PerspectiveTransform(double[][]) instead. |
|
PerspectiveTransform(double[][] matrix)
Constructs a new PerspectiveTransform from a two-dimensional array of doubles. |
|
PerspectiveTransform(double m00,
double m01,
double m02,
double m10,
double m11,
double m12,
double m20,
double m21,
double m22)
Deprecated. as of JAI 1.1 Use PerspectiveTransform(double[][]) instead. |
|
PerspectiveTransform(float[] flatmatrix)
Deprecated. as of JAI 1.1 Use PerspectiveTransform(double[][]) instead. |
|
PerspectiveTransform(float[][] matrix)
Deprecated. as of JAI 1.1 Use PerspectiveTransform(double[][]) instead. |
|
PerspectiveTransform(float m00,
float m01,
float m02,
float m10,
float m11,
float m12,
float m20,
float m21,
float m22)
Deprecated. as of JAI 1.1 Use PerspectiveTransform(double[][]) instead. |
Method Summary | |
Object |
clone()
Returns a copy of this PerspectiveTransform object. |
void |
concatenate(AffineTransform Tx)
Post-concatenates a given AffineTransform to this transform. |
void |
concatenate(PerspectiveTransform Tx)
Post-concatenates a given PerspectiveTransform to this transform. |
PerspectiveTransform |
createAdjoint()
Returns a new PerpectiveTransform that is the adjoint, of the current transform. |
PerspectiveTransform |
createInverse()
Returns a new PerpectiveTransform that is the inverse of the current transform. |
boolean |
equals(Object obj)
Tests if this PerspectiveTransform equals a supplied one. |
double |
getDeterminant()
Returns the determinant of the matrix representation of the transform. |
double[] |
getMatrix(double[] flatmatrix)
Deprecated. as of JAI 1.1 Use double[][] getMatrix(double[][] matrix) instead. |
double[][] |
getMatrix(double[][] matrix)
Retrieves the 9 specifiable values in the 3x3 affine transformation matrix into a 2-dimensional array of double precision values. |
static PerspectiveTransform |
getQuadToQuad(double x0,
double y0,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x0p,
double y0p,
double x1p,
double y1p,
double x2p,
double y2p,
double x3p,
double y3p)
Creates a PerspectiveTransform that maps an arbitrary quadrilateral onto another arbitrary quadrilateral. |
static PerspectiveTransform |
getQuadToQuad(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
float x0p,
float y0p,
float x1p,
float y1p,
float x2p,
float y2p,
float x3p,
float y3p)
Creates a PerspectiveTransform that maps an arbitrary quadrilateral onto another arbitrary quadrilateral. |
static PerspectiveTransform |
getQuadToSquare(double x0,
double y0,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
Creates a PerspectiveTransform that maps an arbitrary quadrilateral onto the unit square. |
static PerspectiveTransform |
getQuadToSquare(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
Creates a PerspectiveTransform that maps an arbitrary quadrilateral onto the unit square. |
static PerspectiveTransform |
getSquareToQuad(double x0,
double y0,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
Creates a PerspectiveTransform that maps the unit square onto an arbitrary quadrilateral. |
static PerspectiveTransform |
getSquareToQuad(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
Creates a PerspectiveTransform that maps the unit square onto an arbitrary quadrilateral. |
void |
inverseTransform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Inverse transforms an array of double precision coordinates by this transform. |
Point2D |
inverseTransform(Point2D ptSrc,
Point2D ptDst)
Inverse transforms the specified ptSrc and stores the result in ptDst. |
boolean |
isIdentity()
Returns the boolean true value if this PerspectiveTransform is an identity transform. |
void |
preConcatenate(AffineTransform Tx)
Pre-concatenates a given AffineTransform to this transform. |
void |
preConcatenate(PerspectiveTransform Tx)
Pre-concatenates a given PerspectiveTransform to this transform. |
void |
rotate(double theta)
Concatenates this transform with a rotation transformation. |
void |
rotate(double theta,
double x,
double y)
Concatenates this transform with a translated rotation transformation. |
void |
scale(double sx,
double sy)
Concatenates this transform with a scaling transformation. |
void |
setToIdentity()
Resets this transform to the Identity transform. |
void |
setToRotation(double theta)
Sets this transform to a rotation transformation. |
void |
setToRotation(double theta,
double x,
double y)
Sets this transform to a rotation transformation about a specified point (x, y). |
void |
setToScale(double sx,
double sy)
Sets this transform to a scale transformation with scale factors sx and sy. |
void |
setToShear(double shx,
double shy)
Sets this transform to a shearing transformation with shear factors sx and sy. |
void |
setToTranslation(double tx,
double ty)
Sets this transform to a translation transformation. |
void |
setTransform(AffineTransform Tx)
Sets this transform to a given AffineTransform. |
void |
setTransform(double[][] matrix)
Sets this transform using a two-dimensional array of double precision values. |
void |
setTransform(float m00,
float m10,
float m20,
float m01,
float m11,
float m21,
float m02,
float m12,
float m22)
Deprecated. as of JAI 1.1 Use double[][] getMatrix(double[][] matrix) instead. |
void |
setTransform(PerspectiveTransform Tx)
Sets this transform to a given PerspectiveTransform. |
void |
shear(double shx,
double shy)
Concatenates this transform with a shearing transformation. |
String |
toString()
Returns a String that represents the value of this Object. |
void |
transform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of double precision coordinates by this transform. |
void |
transform(double[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
Transforms an array of double precision coordinates by this transform, storing the results into an array of floats. |
void |
transform(float[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of floating point coordinates by this transform, storing the results into an array of doubles. |
void |
transform(float[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
Transforms an array of floating point coordinates by this transform. |
void |
transform(Point2D[] ptSrc,
int srcOff,
Point2D[] ptDst,
int dstOff,
int numPts)
Transforms an array of point objects by this transform. |
Point2D |
transform(Point2D ptSrc,
Point2D ptDst)
Transforms the specified ptSrc and stores the result in ptDst. |
void |
translate(double tx,
double ty)
Concatenates this transform with a translation transformation. |
Methods inherited from class java.lang.Object |
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public PerspectiveTransform()
public PerspectiveTransform(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
public PerspectiveTransform(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
public PerspectiveTransform(float[] flatmatrix)
public PerspectiveTransform(float[][] matrix)
public PerspectiveTransform(double[] flatmatrix)
public PerspectiveTransform(double[][] matrix)
public PerspectiveTransform(AffineTransform transform)
Method Detail |
public static PerspectiveTransform getSquareToQuad(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
(0, 0) -> (x0, y0) (1, 0) -> (x1, y1) (1, 1) -> (x2, y2) (0, 1) -> (x3, y3)
public static PerspectiveTransform getSquareToQuad(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
(0, 0) -> (x0, y0) (1, 0) -> (x1, y1) (1, 1) -> (x2, y2) (0, 1) -> (x3, y3)
public static PerspectiveTransform getQuadToSquare(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
(x0, y0) -> (0, 0) (x1, y1) -> (1, 0) (x2, y2) -> (1, 1) (x3, y3) -> (0, 1)
public static PerspectiveTransform getQuadToSquare(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
(x0, y0) -> (0, 0) (x1, y1) -> (1, 0) (x2, y2) -> (1, 1) (x3, y3) -> (0, 1)
public static PerspectiveTransform getQuadToQuad(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double x0p, double y0p, double x1p, double y1p, double x2p, double y2p, double x3p, double y3p)
(x0, y0) -> (x0p, y0p) (x1, y1) -> (x1p, y1p) (x2, y2) -> (x2p, y2p) (x3, y3) -> (x3p, y3p)
public static PerspectiveTransform getQuadToQuad(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float x0p, float y0p, float x1p, float y1p, float x2p, float y2p, float x3p, float y3p)
(x0, y0) -> (x0p, y0p) (x1, y1) -> (x1p, y1p) (x2, y2) -> (x2p, y2p) (x3, y3) -> (x3p, y3p)
public double getDeterminant()
public double[] getMatrix(double[] flatmatrix)
flatmatrix
- The double array used to store the returned
values. The length of the array is assumed to be at
least 9.public double[][] getMatrix(double[][] matrix)
matrix
- The 2-dimensional double array to store the
returned values. The array is assumed to be at least 3x3.public void translate(double tx, double ty)
[ 1 0 tx ] [ 0 1 ty ] [ 0 0 1 ]
public void rotate(double theta)
[ cos(theta) -sin(theta) 0 ] [ sin(theta) cos(theta) 0 ] [ 0 0 1 ]Rotating with a positive angle theta rotates points on the positive X axis toward the positive Y axis.
theta
- The angle of rotation in radians.public void rotate(double theta, double x, double y)
translate(x, y); rotate(theta); translate(-x, -y);Rotating with a positive angle theta rotates points on the positive X axis toward the positive Y axis.
theta
- The angle of rotation in radians.x
- The X coordinate of the origin of the rotationy
- The Y coordinate of the origin of the rotationpublic void scale(double sx, double sy)
[ sx 0 0 ] [ 0 sy 0 ] [ 0 0 1 ]
sx
- The X axis scale factor.sy
- The Y axis scale factor.public void shear(double shx, double shy)
[ 1 shx 0 ] [ shy 1 0 ] [ 0 0 1 ]
shx
- The factor by which coordinates are shifted towards
the positive X axis direction according to their Y
coordinate.shy
- The factor by which coordinates are shifted towards
the positive Y axis direction according to their X
coordinate.public void setToIdentity()
public void setToTranslation(double tx, double ty)
[ 1 0 tx ] [ 0 1 ty ] [ 0 0 1 ]
tx
- The distance by which coordinates are translated in the
X axis directionty
- The distance by which coordinates are translated in the
Y axis directionpublic void setToRotation(double theta)
[ cos(theta) -sin(theta) 0 ] [ sin(theta) cos(theta) 0 ] [ 0 0 1 ]Rotating with a positive angle theta rotates points on the positive X axis toward the positive Y axis.
theta
- The angle of rotation in radians.public void setToRotation(double theta, double x, double y)
setToTranslate(x, y); rotate(theta); translate(-x, -y);Rotating with a positive angle theta rotates points on the positive X axis toward the positive Y axis.
theta
- The angle of rotation in radians.x
- The X coordinate of the origin of the rotationy
- The Y coordinate of the origin of the rotationpublic void setToScale(double sx, double sy)
[ sx 0 0 ] [ 0 sy 0 ] [ 0 0 1 ]
sx
- The X axis scale factor.sy
- The Y axis scale factor.public void setToShear(double shx, double shy)
[ 1 shx 0 ] [ shy 1 0 ] [ 0 0 1 ]
shx
- The factor by which coordinates are shifted towards
the positive X axis direction according to their Y
coordinate.shy
- The factor by which coordinates are shifted towards
the positive Y axis direction according to their X
coordinate.public void setTransform(AffineTransform Tx)
public void setTransform(PerspectiveTransform Tx)
public void setTransform(float m00, float m10, float m20, float m01, float m11, float m21, float m02, float m12, float m22)
public void setTransform(double[][] matrix)
matrix
- The 2D double array to be used for setting this transform.
The array is assumed to be at least 3x3.public void concatenate(AffineTransform Tx)
public void concatenate(PerspectiveTransform Tx)
public void preConcatenate(AffineTransform Tx)
public void preConcatenate(PerspectiveTransform Tx)
public PerspectiveTransform createInverse() throws NoninvertibleTransformException, CloneNotSupportedException
public PerspectiveTransform createAdjoint() throws CloneNotSupportedException
The adjoint is a scalar multiple of the inverse matrix. Because points to be transformed are converted into homogeneous coordinates, where scalar factors are irrelevant, the adjoint may be used in place of the true inverse. Since it is unnecessary to normalize the adjoint, it is both faster to compute and more numerically stable than the true inverse.
public Point2D transform(Point2D ptSrc, Point2D ptDst)
ptSrc
- The array containing the source point objects.ptDst
- The array where the transform point objects are returned.public void transform(Point2D[] ptSrc, int srcOff, Point2D[] ptDst, int dstOff, int numPts)
ptSrc
- The array containing the source point objects.ptDst
- The array where the transform point objects are returned.srcOff
- The offset to the first point object to be transformed
in the source array.dstOff
- The offset to the location where the first transformed
point object is stored in the destination array.numPts
- The number of point objects to be transformed.public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
srcPts
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.srcOff
- The offset to the first point to be transformed
in the source array.dstPts
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.dstOff
- The offset to the location where the first transformed
point is stored in the destination array.numPts
- The number of points to be transformed.public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
srcPts
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.dstPts
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.srcOff
- The offset to the first point to be transformed
in the source array.dstOff
- The offset to the location where the first transformed
point is stored in the destination array.numPts
- The number of point objects to be transformed.public void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
srcPts
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.srcOff
- The offset to the first point to be transformed
in the source array.dstPts
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.dstOff
- The offset to the location where the first transformed
point is stored in the destination array.numPts
- The number of points to be transformed.public void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts)
srcPts
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.dstPts
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.srcOff
- The offset to the first point to be transformed
in the source array.dstOff
- The offset to the location where the first transformed
point is stored in the destination array.numPts
- The number of point objects to be transformed.public Point2D inverseTransform(Point2D ptSrc, Point2D ptDst) throws NoninvertibleTransformException
ptSrc
- The point to be inverse transformed.ptDst
- The resulting transformed point.public void inverseTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws NoninvertibleTransformException
srcPts
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.dstPts
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.srcOff
- The offset to the first point to be transformed
in the source array.dstOff
- The offset to the location where the first transformed
point is stored in the destination array.numPts
- The number of point objects to be transformed.public String toString()
public boolean isIdentity()
public Object clone()
public boolean equals(Object obj)
obj
- The PerspectiveTransform to be compared to this one.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |