- All Implemented Interfaces:
Cloneable
,Transform3D
Affine Transformations can be constructed by concatenating a series of translations, scaling transformation, rotations, and shears. They can also be constructed by providing the parameters m in the matrix above.
90-degree rotations are handled the same way as the class
AffineTransform
handles them. While there are some
differences due to the differences between 3D and 2D Euclidean spaces,
as far as possible this class was modeled after
AffineTransform
in terms of the methods provided - both
their names and their signatures.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The transform will change an object's chirality when the object has a chirality.static final int
The transform is a general one.static final int
The transform is a rotation about some point for an arbitrary angle.static final int
The transform is an identity transform.static final int
This field defines a mask for the two types used to represent rotations.static final int
This field defines a mask for the two types used to represent scaling transformations.static final int
The transform is a rotation about some point by multiples of 90 degrees for each Eulerian angle.static final int
The transform is a scaling transformation, with different scale factors in different directions.static final int
The transform includes a translation so that the point (0,0,0) will be moved by the transformation.static final int
The transform is a scaling transformation, with the same scale factor in each direction. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.AffineTransform3D
(double[] flatmatrix) Constructor given a flat, double-precision matrix representing the transform.AffineTransform3D
(double m00, double m10, double m20, double m01, double m11, double m21, double m02, double m12, double m22, double m03, double m13, double m23) Constructor given matrix elements in double precision.AffineTransform3D
(float[] flatmatrix) Constructor given a flat, single-precision matrix representing the transform.AffineTransform3D
(float m00, float m10, float m20, float m01, float m11, float m21, float m02, float m12, float m22, float m03, float m13, float m23) Constructor given matrix elements in single precision.Constructor that represents the same transform as another transform. -
Method Summary
Modifier and TypeMethodDescriptionaffineTransform
(double x, double y, double z) Get the AffineTransform3D that approximates this transform in a neighborhood of a point whose coordinates are (x, y, z).clone()
void
Concatenates this transform with an AffineTransform3D.Create an AffineTransform3D that is the inverse of this transform.void
deltaTransform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transform a sequence of vectors (directed line segments).boolean
double
Get the determinant of this AffineTransform3D's matrixstatic AffineTransform3D
getMapInstance
(Point3D p1, double[] xvec1, double[] yvec1, Point3D p2, double[] xvec2, double[] yvec2, double theta) Create an affine transform that maps the point p1 to p2, and arranges that points along a line in the direction of a vector xvec1 will lie along a line in the direction of a vector xvec2, and that points along a line in the direction of a vector yvec1 will lie along a line in the direction of a vector yvec2.void
getMatrix
(double[] flatMatrix) Get the elements of the matrix representing this AffineTransform3D, with each element a double-precision number.static AffineTransform3D
getRotateInstance
(double phi, double theta, double psi) Create an AffineTransform3D that represents a rotation about the point (0, 0, 0).static AffineTransform3D
getRotateInstance
(double phi, double theta, double psi, double anchorx, double anchory, double anchorz) Create an AffineTransform3D that represents a rotation about an anchor point.static AffineTransform3D
getScaleInstance
(double sx, double sy, double sz) Create an AffineTransform3D that will scale an object.double
Get the X coordinate scale factor m00 for this transform.double
Get the Y coordinate scale factor m11 for this transform.double
Get the Z coordinate scale factor m22 for this transform.static AffineTransform3D
getShearInstance
(double shxy, double shxz, double shyx, double shyz, double shzx, double shzy) Create a new AffineTransform3D representing a shearing transformation.double
Get the factor by which the X coordinate is shifted when this factor is multiplied by the Y coordinate.double
Get the factor by which the X coordinate is shifted when this factor is multiplied by the Z coordinate.double
Get the factor by which the Y coordinate is shifted when this factor is multiplied by the X coordinate.double
Get the factor by which the Y coordinate is shifted when this factor is multiplied by the Z coordinate.double
Get the factor by which the Z coordinate is shifted when this factor is multiplied by the X coordinate.double
Get the factor by which the Z coordinate is shifted when this factor is multiplied by the Y coordinate.static AffineTransform3D
getTranslateInstance
(double tx, double ty, double tz) Create a new AffineTransform3D representing a translation.double
Get the translation in the X direction for this transform.double
Get the translation in the Y direction for this transform.double
Get the translation in the Z direction for this transform.int
getType()
Get the type of the transformation.int
hashCode()
void
inverseTransform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Apply the inverse of this transform to a sequence of points, Each point is an ordered triplet (px,py,pz stored as consecutive array elements in that order.inverseTransform
(Point3D ptSrc, Point3D ptDst) Apply the inverse of this transform to a point.void
invert()
Replace this transform with its inverse.boolean
Test if this AffineTransform3D is an identity transform.void
map
(Point3D p1, double[] xvec1, double[] yvec1, Point3D p2, double[] xvec2, double[] yvec2, double theta) Concatenate this transform with an affine transform that maps the point p1 to p2, and arranges that points along a line in the direction of a vector xvec1 will lie along a line in the direction of a vector xvec2, and that points along a line in the direction of a vector yvec1 will lie along a line in the direction of a vector yvec2.void
Concatenates an AffineTransform3D with this affine transform.void
rotate
(double phi, double theta, double psi) Concatenate this transform with a rotation about the point (0, 0, 0).void
rotate
(double phi, double theta, double psi, double anchorx, double anchory, double anchorz) Concatenate this transform with a rotation about an anchor point.void
scale
(double sx, double sy, double sz) Concatenate this transform with a scaling transformation.void
Set this transform to an identity transform.void
setToMap
(Point3D p1, double[] xvec1, double[] yvec1, Point3D p2, double[] xvec2, double[] yvec2, double theta) Sets this affine transform to one that maps the point p1 to p2, and arranges that points along a line in the direction of a vector xvec1 will lie along a line in the direction of a vector xvec2, and that points along a line in the direction of a vector yvec1 will lie along a line in the direction of a vector yvec2.void
setToRotation
(double phi, double theta, double psi) Set this transform to a rotation about (0, 0, 0).void
setToRotation
(double phi, double theta, double psi, double anchorx, double anchory, double anchorz) Set this transform to a rotation about an anchor point.void
setToScale
(double sx, double sy, double sz) Set this transform to a scaling transform.void
setToShear
(double shxy, double shxz, double shyx, double shyz, double shzx, double shzy) Set this transform to a shearing transform.void
setToTranslation
(double tx, double ty, double tz) Set this transform to a translation.void
setTransform
(double m00, double m10, double m20, double m01, double m11, double m21, double m02, double m12, double m22, double m03, double m13, double m23) Set this transform's parameters.void
Set this transform to the same transformation used by another transform.void
shear
(double shxy, double shxz, double shyx, double shyz, double shzx, double shzy) Concatenate this transform with a shearing transform.toString()
void
transform
(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Apply this transform to a sequence of points with the source points' coordinates specified as double-precision numbers and the destination points' coordinates specified as double-precision numbers.void
transform
(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Apply this transform to a sequence of points with the source points' coordinates specified as double-precision numbers and the destination points' coordinates specified as single-precision numbers.void
transform
(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Apply this transform to a sequence of points with the source points' coordinates specified as single-precision numbers and the destination points' coordinates specified as double-precision numbers.void
transform
(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Apply this transform to a sequence of points with the source points' coordinates specified as single-precision numbers and the destination points' coordinates specified as single-precision numbers.Apply this transform to a single point, optionally storing the transformed value in a specified point.void
translate
(double tx, double ty, double tz) Concatenate this transform with a translation.
-
Field Details
-
TYPE_IDENTITY
public static final int TYPE_IDENTITYThe transform is an identity transform.- See Also:
-
TYPE_FLIP_CHIRALITY
public static final int TYPE_FLIP_CHIRALITYThe transform will change an object's chirality when the object has a chirality.- See Also:
-
TYPE_GENERAL_ROTATION
public static final int TYPE_GENERAL_ROTATIONThe transform is a rotation about some point for an arbitrary angle.- See Also:
-
TYPE_QUADRANT_ROTATION
public static final int TYPE_QUADRANT_ROTATIONThe transform is a rotation about some point by multiples of 90 degrees for each Eulerian angle.- See Also:
-
TYPE_SCALE
public static final int TYPE_SCALEThe transform is a scaling transformation, with different scale factors in different directions. The scaling is restricted to occur along the X, Y, or Z axes.- See Also:
-
TYPE_UNIFORM_SCALE
public static final int TYPE_UNIFORM_SCALEThe transform is a scaling transformation, with the same scale factor in each direction.- See Also:
-
TYPE_TRANSLATION
public static final int TYPE_TRANSLATIONThe transform includes a translation so that the point (0,0,0) will be moved by the transformation.- See Also:
-
TYPE_GENERAL
public static final int TYPE_GENERALThe transform is a general one.- See Also:
-
TYPE_MASK_ROTATION
public static final int TYPE_MASK_ROTATIONThis field defines a mask for the two types used to represent rotations.- See Also:
-
TYPE_MASK_SCALE
public static final int TYPE_MASK_SCALEThis field defines a mask for the two types used to represent scaling transformations.- See Also:
-
-
Constructor Details
-
AffineTransform3D
public AffineTransform3D()Constructor. The AffineTransform3D created will be an identity transform. -
AffineTransform3D
Constructor that represents the same transform as another transform.- Parameters:
Tx
- the transform to copy
-
AffineTransform3D
public AffineTransform3D(double[] flatmatrix) Constructor given a flat, double-precision matrix representing the transform. The elements of the flat matrix are {m00, m10, m20, m01, m11, m21, m02, m12, m22, [m03, m13, m23]} The last 3 are optional and are used when the length of the matrix is 12 or more. Additional arguments are ignored.- Parameters:
flatmatrix
- the flattened matrix with non-varying elements removed
-
AffineTransform3D
public AffineTransform3D(double m00, double m10, double m20, double m01, double m11, double m21, double m02, double m12, double m22, double m03, double m13, double m23) Constructor given matrix elements in double precision.- Parameters:
m00
- the matrix element m00m10
- the matrix element m10m20
- the matrix element m20m01
- the matrix element m01m11
- the matrix element m11m21
- the matrix element m21m02
- the matrix element m02m12
- the matrix element m12m22
- the matrix element m22m03
- the matrix element m03m13
- the matrix element m13m23
- the matrix element m23
-
AffineTransform3D
public AffineTransform3D(float[] flatmatrix) Constructor given a flat, single-precision matrix representing the transform. The elements of the flat matrix are {m00, m10, m20, m01, m11, m21, m02, m12, m22, [m03, m13, m23]} The last 3 are optional and are used when the length of the matrix is 12 or more. Additional arguments are ignored.- Parameters:
flatmatrix
- the flattened matrix with non-varying elements removed
-
AffineTransform3D
public AffineTransform3D(float m00, float m10, float m20, float m01, float m11, float m21, float m02, float m12, float m22, float m03, float m13, float m23) Constructor given matrix elements in single precision.- Parameters:
m00
- the matrix element m00m10
- the matrix element m10m20
- the matrix element m20m01
- the matrix element m01m11
- the matrix element m11m21
- the matrix element m21m02
- the matrix element m02m12
- the matrix element m12m22
- the matrix element m22m03
- the matrix element m03m13
- the matrix element m13m23
- the matrix element m23
-
-
Method Details
-
clone
-
concatenate
Concatenates this transform with an AffineTransform3D. Given the matrix representation M for this affine transform and the matrix representation MT for the transform Tx, this transform's new value is M MT.- Parameters:
Tx
- the affine transform to concatenate
-
preConcatenate
Concatenates an AffineTransform3D with this affine transform. Given the matrix representation M for this affine transform and the matrix representation MT for the transform Tx, this transform's new value is MT M.- Parameters:
Tx
- the affine transform to concatenate
-
createInverse
Create an AffineTransform3D that is the inverse of this transform.- Returns:
- the inverse transform
- Throws:
NoninvertibleTransformException
- an inverse cannot be computed
-
deltaTransform
public void deltaTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Transform a sequence of vectors (directed line segments). The translation is not applied as a translation is meaningful for points. Each vector is an ordered triplet (vx,vy,vz stored as consecutive array elements in that order.- Parameters:
srcPts
- the vectors to transformsrcOff
- the offset int srcPts at which the first vector is storeddstPts
- the transformed vectorsdstOff
- the offset in dstPts at which the first transformed vector will be storednumPts
- the number of vectors
-
equals
-
getDeterminant
public double getDeterminant()Get the determinant of this AffineTransform3D's matrix- Returns:
- the determinant
-
getMatrix
public void getMatrix(double[] flatMatrix) Get the elements of the matrix representing this AffineTransform3D, with each element a double-precision number. The elements are stored in row-major order:{m00, m10, m20, m01, m11, m21, m02, m12, m22, m03, m13, m23} Only nontrivial entries are included (a few are always 0 or 1).
- Parameters:
flatMatrix
- an array that will hold the non-trivial elements of the matrix
-
getRotateInstance
Create an AffineTransform3D that represents a rotation about the point (0, 0, 0).The rotation is described by three angles based on Eulerian angles: φ, θ, ψ. Eulerian angles as described in Goldstein, "Classical Mechanics," determine how orthonormal coordinate systems transform using a rotation. For an affine transformation that modifies objects, not coordinate systems, the effect is the same as reversing the signs of these angles, which getRotateInstance does implicitly. The angle phi is the angle the object rotates with positive values of phi indicating a counter-clockwise rotation when viewed from positive values of z towards the plane in which z=0. Theta then indicates a rotation about the x axis, and psi indicates another rotation about the z axis.
- Parameters:
phi
- the Eulerian angle phi in radianstheta
- the Eulerian angle theta in radianspsi
- the Eulerian angle psi in radians- Returns:
- an affine transformation representing a rotation about the point (0,0,0)
-
getRotateInstance
public static AffineTransform3D getRotateInstance(double phi, double theta, double psi, double anchorx, double anchory, double anchorz) Create an AffineTransform3D that represents a rotation about an anchor point.The rotation is described by three angles based on Eulerian angles: φ, θ, ψ. Eulerian angles as described in Goldstein, "Classical Mechanics," determine how orthonormal coordinate systems transform using a rotation. For an affine transformation that modifies objects, not coordinate systems, the effect is the same as reversing the signs of these angles, which getRotateInstance does implicitly. The angle phi is the angle the object rotates with positive values of phi indicating a counter-clockwise rotation when viewed from positive values of z towards the plane in which z=0. Theta then indicates a rotation about the x axis, and psi indicates another rotation about the z axis. A translation will then be applied so that, after the transform is applied, the anchor point (anchorx, anchory, anchorz) will not move.
- Parameters:
phi
- the Eulerian angle phi in radianstheta
- the Eulerian angle theta in radianspsi
- the Eulerian angle psi in radiansanchorx
- the x coordinate of the anchor pointanchory
- the y coordinate of the anchor pointanchorz
- the z coordinate of the anchor point- Returns:
- an affine transformation representing a rotation about the point (0,0,0)
-
getScaleInstance
Create an AffineTransform3D that will scale an object. This transform will stretch an object by specified amounts in the x, y, and z directions, with the point (0,0,0) not moving.- Parameters:
sx
- the scaling factor in the x directionsy
- the scaling factor in the y directionsz
- the scaling factor in the z direction- Returns:
- the transform
-
getScaleX
public double getScaleX()Get the X coordinate scale factor m00 for this transform.- Returns:
- the scale factor
-
getScaleY
public double getScaleY()Get the Y coordinate scale factor m11 for this transform.- Returns:
- the scale factor
-
getScaleZ
public double getScaleZ()Get the Z coordinate scale factor m22 for this transform.- Returns:
- the scale factor
-
getShearInstance
public static AffineTransform3D getShearInstance(double shxy, double shxz, double shyx, double shyz, double shzx, double shzy) Create a new AffineTransform3D representing a shearing transformation.- Parameters:
shxy
- the X coordinate is shifted by this factor times the Y coordinate; equivalent to the value of m01shxz
- the X coordinate is shifted by this factor times the Z coordinate; equivalent to the value of m02shyx
- the Y coordinate is shifted by this factor times the X coordinate; equivalent to the value of m10shyz
- the Y coordinate is shifted by this factor times the Z coordinate; equivalent to the value of m12shzx
- the Z coordinate is shifted by this factor times the X coordinate; equivalent to the value of m20shzy
- the Z coordinate is shifted by this factor times the Y coordinate; equivalent to the value of m21- Returns:
- the new shearing transformation
-
getShearXY
public double getShearXY()Get the factor by which the X coordinate is shifted when this factor is multiplied by the Y coordinate.- Returns:
- the factor; equivalent to the value of m01
-
getShearXZ
public double getShearXZ()Get the factor by which the X coordinate is shifted when this factor is multiplied by the Z coordinate.- Returns:
- the factor; equivalent to the value of m02
-
getShearYX
public double getShearYX()Get the factor by which the Y coordinate is shifted when this factor is multiplied by the X coordinate.- Returns:
- the factor; equivalent to the value of m10
-
getShearYZ
public double getShearYZ()Get the factor by which the Y coordinate is shifted when this factor is multiplied by the Z coordinate.- Returns:
- the factor; equivalent to the value of m12
-
getShearZX
public double getShearZX()Get the factor by which the Z coordinate is shifted when this factor is multiplied by the X coordinate.- Returns:
- the factor; equivalent to the value of m20
-
getShearZY
public double getShearZY()Get the factor by which the Z coordinate is shifted when this factor is multiplied by the Y coordinate.- Returns:
- the factor; equivalent to the value of m21
-
getTranslateInstance
Create a new AffineTransform3D representing a translation.- Parameters:
tx
- the translation in the X directionty
- the translation in the Y directiontz
- the translation in the Z direction- Returns:
- the transform
-
getTranslateX
public double getTranslateX()Get the translation in the X direction for this transform.- Returns:
- the translation; equivalent to m03
-
getTranslateY
public double getTranslateY()Get the translation in the Y direction for this transform.- Returns:
- the translation; equivalent to m13
-
getTranslateZ
public double getTranslateZ()Get the translation in the Z direction for this transform.- Returns:
- the translation; equivalent to m23
-
hashCode
public int hashCode() -
inverseTransform
public void inverseTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws NoninvertibleTransformException Apply the inverse of this transform to a sequence of points, Each point is an ordered triplet (px,py,pz stored as consecutive array elements in that order.- Parameters:
srcPts
- the points to transformsrcOff
- the offset int srcPts at which the first point is storeddstPts
- the transformed pointsdstOff
- the offset in dstPts at which the first transformed point will be storednumPts
- the number of points- Throws:
NoninvertibleTransformException
- this transform does not have an inverse
-
inverseTransform
public Point3D inverseTransform(Point3D ptSrc, Point3D ptDst) throws NoninvertibleTransformException Apply the inverse of this transform to a point. Note: ptSrc and ptDst can be the same point.- Parameters:
ptSrc
- the untransformed pointptDst
- the point to be transformed (a new point will be created if the value is null)- Returns:
- the transformed point
- Throws:
NoninvertibleTransformException
- this transform does not have an inverse
-
invert
Replace this transform with its inverse.- Throws:
NoninvertibleTransformException
- an inverse does not exist
-
getType
public int getType()Get the type of the transformation. The type of an AffineTransform3D is represented by an integer, with specific bits indicating various features. masks are provided to denote useful combinations of bits. The symbolic names for the bits and their masks are constants associated with this class:- the value TYPE_IDENTITY is mutually exclusive with the other types and denotes the identity matrix.
- the value TYPE_TRANSLATION indicates that the transform includes a translation whose elements are not all zero.
- the value TYPE_MASK_ROTATION is a mask for two mutually exclusive types, both indicating rotations. This should be used to find rotations of either type.
- the value TYPE_QUADRANT_ROTATION denotes rotations the exchange the x, y, and z axes in some way that does not involve a reflection. The tests that determine this type are dependent on floating-point accuracy, and are most likely to work for small angles (e.g. π/2, not 1016π + π/2).
- the value TYPE_GENERAL_ROTATION includes all other rotations.
- the value TYPE_MASK_SCALE is a mask for two mutually exclusive scaling transformation. This should be used to find scaling transformations of either type.
- the value TYPE_UNIFORM_SCALE indicates that the scaling is the same along the X, Y, and Z directions.
- the value TYPE_SCALE is used when the X, Y, and Z values are scaled.
- the value TYPE_GENERAL applies to all other transforms, including shears, which are not given any special designation.
- the value TYPE_FLIP_CHIRALITY apples to TYPE_UNIFORM_SCALE, TYPE_SCALE, and TYPE_GENERAL. TYPE_FLIP_CHIRALITY indicates a chirality change. If an object is sufficiently asymmetric that there can be left-handed and right-handed versions of it, this bit indicates that a left-handed version will be turned into a right-handed version and vice versa.
Note: Determining the type requires some computation, so the implementation caches the results and clears the cache if there is a change (or in a few cases, replaces it with the new value when this can be trivially determined).
- Returns:
- the type of the affine transformation as described above
-
isIdentity
public boolean isIdentity()Test if this AffineTransform3D is an identity transform.- Returns:
- true if this transform is an identity transform; false if not
-
rotate
public void rotate(double phi, double theta, double psi) Concatenate this transform with a rotation about the point (0, 0, 0). The rotation is described by three angles based on Eulerian angles: φ, θ, ψ. Eulerian angles as described in Goldstein, "Classical Mechanics," determine how orthonormal coordinate systems transform using a rotation. For an affine transformation that modifies objects, not coordinate systems, the effect is the same as reversing the signs of these angles, which getRotateInstance does implicitly. The angle phi is the angle the object rotates with positive values of phi indicating a counter-clockwise rotation when viewed from positive values of z towards the plane in which z=0. Theta then indicates a rotation about the x axis, and psi indicates another rotation about the z axis.- Parameters:
phi
- the Eulerian angle phi in radianstheta
- the Eulerian angle theta in radianspsi
- the Eulerian angle psi in radians
-
rotate
public void rotate(double phi, double theta, double psi, double anchorx, double anchory, double anchorz) Concatenate this transform with a rotation about an anchor point. The rotation is described by three angles based on Eulerian angles: φ, θ, ψ. Eulerian angles as described in Goldstein, "Classical Mechanics," determine how orthonormal coordinate systems transform using a rotation. For an affine transformation that modifies objects, not coordinate systems, the effect is the same as reversing the signs of these angles, which getRotateInstance does implicitly. The angle phi is the angle the object rotates with positive values of phi indicating a counter-clockwise rotation when viewed from positive values of z towards the plane in which z=0. Theta then indicates a rotation about the x axis, and psi indicates another rotation about the z axis.- Parameters:
phi
- the Eulerian angle phi in radianstheta
- the Eulerian angle theta in radianspsi
- the Eulerian angle psi in radiansanchorx
- the x coordinate of the anchor pointanchory
- the y coordinate of the anchor pointanchorz
- the z coordinate of the anchor point
-
scale
public void scale(double sx, double sy, double sz) Concatenate this transform with a scaling transformation. The scaling transform will stretch an object by specified amounts in the x, y, and z directions, with the point (0,0,0) not moving.- Parameters:
sx
- the scaling factor in the x directionsy
- the scaling factor in the y directionsz
- the scaling factor in the z direction
-
setToIdentity
public void setToIdentity()Set this transform to an identity transform. -
setToRotation
public void setToRotation(double phi, double theta, double psi) Set this transform to a rotation about (0, 0, 0). The rotation is described by three angles based on Eulerian angles: φ, θ, ψ. Eulerian angles as described in Goldstein, "Classical Mechanics," determine how orthonormal coordinate systems transform using a rotation. For an affine transformation that modifies objects, not coordinate systems, the effect is the same as reversing the signs of these angles, which getRotateInstance does implicitly. The angle phi is the angle the object rotates with positive values of phi indicating a counter-clockwise rotation when viewed from positive values of z towards the plane in which z=0. Theta then indicates a rotation about the x axis, and psi indicates another rotation about the z axis.- Parameters:
phi
- the Eulerian angle phi in radianstheta
- the Eulerian angle theta in radianspsi
- the Eulerian angle psi in radians
-
setToRotation
public void setToRotation(double phi, double theta, double psi, double anchorx, double anchory, double anchorz) Set this transform to a rotation about an anchor point. The rotation is described by three angles based on Eulerian angles: φ, θ, ψ. Eulerian angles as described in Goldstein, "Classical Mechanics," determine how orthonormal coordinate systems transform using a rotation. For an affine transformation that modifies objects, not coordinate systems, the effect is the same as reversing the signs of these angles, which getRotateInstance does implicitly. The angle phi is the angle the object rotates with positive values of phi indicating a counter-clockwise rotation when viewed from positive values of z towards the plane in which z=0. Theta then indicates a rotation about the x axis, and psi indicates another rotation about the z axis.After the rotation, a translation is applied so that the anchor point will have the same coordinates before and after the transform is applied.
- Parameters:
phi
- the Eulerian angle phi in radianstheta
- the Eulerian angle theta in radianspsi
- the Eulerian angle psi in radiansanchorx
- the x coordinate of the anchor pointanchory
- the y coordinate of the anchor pointanchorz
- the z coordinate of the anchor point
-
setToScale
public void setToScale(double sx, double sy, double sz) Set this transform to a scaling transform. The scaling transform will stretch an object by specified amounts in the x, y, and z directions, with the point (0,0,0) not moving.- Parameters:
sx
- the scaling factor in the x directionsy
- the scaling factor in the y directionsz
- the scaling factor in the z direction
-
setToShear
public void setToShear(double shxy, double shxz, double shyx, double shyz, double shzx, double shzy) Set this transform to a shearing transform.- Parameters:
shxy
- the X coordinate is shifted by this factor times the Y coordinate; equivalent to the value of m01shxz
- the X coordinate is shifted by this factor times the Z coordinate; equivalent to the value of m02shyx
- the Y coordinate is shifted by this factor times the X coordinate; equivalent to the value of m10shyz
- the Y coordinate is shifted by this factor times the Z coordinate; equivalent to the value of m12shzx
- the Z coordinate is shifted by this factor times the X coordinate; equivalent to the value of m20shzy
- the Z coordinate is shifted by this factor times the Y coordinate; equivalent to the value of m21
-
setToTranslation
public void setToTranslation(double tx, double ty, double tz) Set this transform to a translation.- Parameters:
tx
- the translation in the X directionty
- the translation in the Y directiontz
- the translation in the Z direction
-
setTransform
Set this transform to the same transformation used by another transform.- Parameters:
Tx
- the transform whose configuration will be copied
-
setTransform
public void setTransform(double m00, double m10, double m20, double m01, double m11, double m21, double m02, double m12, double m22, double m03, double m13, double m23) Set this transform's parameters.- Parameters:
m00
- the matrix element m00m10
- the matrix element m10m20
- the matrix element m20m01
- the matrix element m01m11
- the matrix element m11m21
- the matrix element m21m02
- the matrix element m02m12
- the matrix element m12m22
- the matrix element m22m03
- the matrix element m03m13
- the matrix element m13m23
- the matrix element m23
-
shear
public void shear(double shxy, double shxz, double shyx, double shyz, double shzx, double shzy) Concatenate this transform with a shearing transform. The parameters define the shearing transform.- Parameters:
shxy
- the X coordinate is shifted by this factor times the Y coordinate; equivalent to the value of m01shxz
- the X coordinate is shifted by this factor times the Z coordinate; equivalent to the value of m02shyx
- the Y coordinate is shifted by this factor times the X coordinate; equivalent to the value of m10shyz
- the Y coordinate is shifted by this factor times the Z coordinate; equivalent to the value of m12shzx
- the Z coordinate is shifted by this factor times the X coordinate; equivalent to the value of m20shzy
- the Z coordinate is shifted by this factor times the Y coordinate; equivalent to the value of m21
-
toString
-
transform
public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Apply this transform to a sequence of points with the source points' coordinates specified as double-precision numbers and the destination points' coordinates specified as double-precision numbers. Each point is an ordered triplet (px,py,pz stored as consecutive array elements in that order. The implementation allows srcPts and dstPnts to be the same array and their offsets to overlap, in which case the new values will not be stored until the old values have been used.- Specified by:
transform
in interfaceTransform3D
- Parameters:
srcPts
- the points to transformsrcOff
- the offset int srcPts at which the first point is storeddstPts
- the transformed pointsdstOff
- the offset in dstPts at which the first transformed point will be storednumPts
- the number of points
-
transform
public void transform(double[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Apply this transform to a sequence of points with the source points' coordinates specified as double-precision numbers and the destination points' coordinates specified as single-precision numbers. Each point is an ordered triplet (px,py,pz stored as consecutive array elements in that order.- Specified by:
transform
in interfaceTransform3D
- Parameters:
srcPts
- the points to transformsrcOff
- the offset int srcPts at which the first point is storeddstPts
- the transformed pointsdstOff
- the offset in dstPts at which the first transformed point will be storednumPts
- the number of points
-
transform
public void transform(float[] srcPts, int srcOff, float[] dstPts, int dstOff, int numPts) Apply this transform to a sequence of points with the source points' coordinates specified as single-precision numbers and the destination points' coordinates specified as single-precision numbers. Each point is an ordered triplet (px,py,pz stored as consecutive array elements in that order. The implementation allows srcPts and dstPnts to be the same array and their offsets to overlap, in which case the new values will not be stored until the old values have been used.- Specified by:
transform
in interfaceTransform3D
- Parameters:
srcPts
- the points to transformsrcOff
- the offset int srcPts at which the first point is storeddstPts
- the transformed pointsdstOff
- the offset in dstPts at which the first transformed point will be storednumPts
- the number of points
-
transform
public void transform(float[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) Apply this transform to a sequence of points with the source points' coordinates specified as single-precision numbers and the destination points' coordinates specified as double-precision numbers. Each point is an ordered triplet (px,py,pz stored as consecutive array elements in that order.- Specified by:
transform
in interfaceTransform3D
- Parameters:
srcPts
- the points to transformsrcOff
- the offset int srcPts at which the first point is storeddstPts
- the transformed pointsdstOff
- the offset in dstPts at which the first transformed point will be storednumPts
- the number of points
-
transform
Apply this transform to a single point, optionally storing the transformed value in a specified point. Note: ptSrc and ptDst can be the same point.- Specified by:
transform
in interfaceTransform3D
- Parameters:
ptSrc
- the untransformed pointptDst
- the point to be transformed (a new point will be created if the value is null)- Returns:
- the transformed point
-
translate
public void translate(double tx, double ty, double tz) Concatenate this transform with a translation.- Parameters:
tx
- the translation in the X directionty
- the translation in the Y directiontz
- the translation in the Z direction
-
setToMap
public void setToMap(Point3D p1, double[] xvec1, double[] yvec1, Point3D p2, double[] xvec2, double[] yvec2, double theta) throws IllegalArgumentException Sets this affine transform to one that maps the point p1 to p2, and arranges that points along a line in the direction of a vector xvec1 will lie along a line in the direction of a vector xvec2, and that points along a line in the direction of a vector yvec1 will lie along a line in the direction of a vector yvec2. In addition, points along a line in the direction of a vector zvec1 will lie along a line in the direction of a vector zvec2, where zvec1 is the cross product of xvec1 and yvec1, and zvec2 is the cross product of the xvec2 and yvec2. The two vectors xvec1 and yvec1 must be orthogonal, as must xvec2 and yvec2.The argument theta adds an extra rotation in the xvec2-yvec2 plane about p2. Positive values of theta correspondings to a counterclockwise rotation when xvec2 is viewed as pointing right and yvec2 as pointing up. with positive angles moving the
- Parameters:
p1
- the initial point; null for (0,0,0)xvec1
- a vector treated as defining an initial 'X' axisyvec1
- a vector treated as defining an initial 'Y' axisp2
- the final point; null for (0,0,0)xvec2
- a vector treated as defining a final 'X' axisyvec2
- a vector treated as defining a final 'Y' axistheta
- an extra rotation in the xvec2-yvec2 plane with positive values of theta corresponding to a clockwise rotation (i.e., a rotation moving from xvec towards yvec).- Throws:
IllegalArgumentException
- an argument was illegal
-
getMapInstance
public static AffineTransform3D getMapInstance(Point3D p1, double[] xvec1, double[] yvec1, Point3D p2, double[] xvec2, double[] yvec2, double theta) throws IllegalArgumentException Create an affine transform that maps the point p1 to p2, and arranges that points along a line in the direction of a vector xvec1 will lie along a line in the direction of a vector xvec2, and that points along a line in the direction of a vector yvec1 will lie along a line in the direction of a vector yvec2. In addition, points along a line in the direction of a vector zvec1 will lie along a line in the direction of a vector zvec2, where zvec1 is the cross product of xvec1 and yvec1, and zvec2 is the cross product of the xvec2 and yvec2. The two vectors xvec1 and yvec1 must be orthogonal, as must xvec2 and yvec2.The argument theta adds an extra rotation in the xvec2-yvec2 plane about p2. Positive values of theta correspondings to a counterclockwise rotation when xvec2 is viewed as pointing right and
- Parameters:
p1
- the initial point; null for (0,0,0)xvec1
- a vector treated as defining an initial 'X' axisyvec1
- a vector treated as defining an initial 'Y' axisp2
- the final point; null for (0,0,0)xvec2
- a vector treated as defining a final 'X' axisyvec2
- a vector treated as defining a final 'Y' axistheta
- an extra rotation in the xvec2-yvec2 plane with positive values of theta corresponding to a clockwise rotation (i.e., a rotation moving from xvec towards yvec).- Returns:
- the affine transform
- Throws:
IllegalArgumentException
- an argument was illegal
-
map
public void map(Point3D p1, double[] xvec1, double[] yvec1, Point3D p2, double[] xvec2, double[] yvec2, double theta) throws IllegalArgumentException Concatenate this transform with an affine transform that maps the point p1 to p2, and arranges that points along a line in the direction of a vector xvec1 will lie along a line in the direction of a vector xvec2, and that points along a line in the direction of a vector yvec1 will lie along a line in the direction of a vector yvec2. In addition, points along a line in the direction of a vector zvec1 will lie along a line in the direction of a vector zvec2, where zvec1 is the cross product of xvec1 and yvec1, and zvec2 is the cross product of the xvec2 and yvec2. The two vectors xvec1 and yvec1 must be orthogonal, as must xvec2 and yvec2.The argument theta adds an extra rotation in the xvec2-yvec2 plane about p2. Positive values of theta correspondings to a counterclockwise rotation when xvec2 is viewed as pointing right and
- Parameters:
p1
- the initial point; null for (0,0,0)xvec1
- a vector treated as defining an initial 'X' axisyvec1
- a vector treated as defining an initial 'Y' axisp2
- the final point; null for (0,0,0)xvec2
- a vector treated as defining a final 'X' axisyvec2
- a vector treated as defining a final 'Y' axistheta
- an extra rotation in the xvec2-yvec2 plane with positive values of theta corresponding to a clockwise rotation (i.e., a rotation moving from xvec towards yvec).- Throws:
IllegalArgumentException
- an argument was illegal
-
affineTransform
public AffineTransform3D affineTransform(double x, double y, double z) throws UnsupportedOperationException Description copied from interface:Transform3D
Get the AffineTransform3D that approximates this transform in a neighborhood of a point whose coordinates are (x, y, z).If a transform is represented by the equations
x' = f(x,y,z) y' = g(x,y,z) z' = h(x,y,z)
and the first partial derivatives of f, g, and h exist, then we can approximate the transform at a point (x0,y0,z0) byx' = f(x0,y0,z0) + f1(x0,y0,z0)(x-x0) + f2(x0,y0,z0)(y-y0) + f3(x0,y0,z0)(z-z0) y' = g(x0,y0,z0) + g1(x0,y0,z0)(x-x0) + g2(x0,y0,z0)(y-y0) + g3(x0,y0,z0)(z-z0) z' = h(x0,y0,z0) + h1(x0,y0,z0)(x-x0) + h2(x0,y0,z0)(y-y0) + h3(x0,y0,z0)(z-z0)
This set of equations represents an affine transform whose non-translation components arem00 = f1(x0,y0,z0) m10 = g1(x0,y0,z0) m20 = h1(x0,y0,z0) m01 = f2(x0,y0,z0) m11 = g2(x0,y0,z0) m21 = h2(x0,y0,z0) m02 = f3(x0,y0,z0) m12 = g3(x0,y0,z0) m22 = h3(x0,y0,z0)
and whose translation components arem03 = f(x0,y0,z0) - f1(x0,y0,z0)x0 - f2(x0,y0,z0)y0 - f3(x0,y0,z0)z0 m13 = g(x0,y0,z0) - g1(x0,y0,z0)x0 - g2(x0,y0,z0)y0 - g3(x0,y0,z0)z0 m23 = h(x0,y0,z0) - h1(x0,y0,z0)x0 - h2(x0,y0,z0)y0 - h3(x0,y0,z0)z0
that is a good approximation to this transform in a sufficiently small neighborhood of the point (x0,y0,z0).- Specified by:
affineTransform
in interfaceTransform3D
- Parameters:
x
- the X coordinatey
- the Y coordinatez
- the Z coordinate- Returns:
- an AffineTransform3D that approximates this transform; null if one does not exist at the point whose coordinates are (x, y, z)
- Throws:
UnsupportedOperationException
- this operation is not supported by this transform
-