vmm3d.core3D
Class GridTransformMatrix
- java.lang.Object
-
- vmm3d.core3D.GridTransformMatrix
-
public class GridTransformMatrix extends java.lang.ObjectRepresents an affine transform on real 3-space as a matrix; meant for use withGrid3Dto represent transformations applied to a basic grid to produce additional segments of a complete surface.
-
-
Constructor Summary
Constructors Constructor and Description GridTransformMatrix()Constructs an identity matrix.GridTransformMatrix(GridTransformMatrix m)Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description Vector3Dapply(Vector3D vec)Applies the transform to a vector.Vector3DapplyToNormal(Vector3D N)Apply the transformation to a surface normal.booleanequals(java.lang.Object o)Tests whether a given object is equal to this TransformMatrix.booleangetReverseSurfaceOrientation()Gets the value of the reverseSurfaceOrientation property.GridTransformMatrixleftMultiplyBy(GridTransformMatrix m)Multiplying this GridTransformationMatrix on the left by another matrix.GridTransformMatrixreverse()Reverses the value of the reverseSurfaceOrientation property.GridTransformMatrixrotateX(double degrees)Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix.GridTransformMatrixrotateY(double degrees)Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix.GridTransformMatrixrotateZ(double degrees)Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix.GridTransformMatrixscale(double s)Applies a scaling operation to this TransformMatrix, by multiplying it on the LEFT by a scaling matrix.GridTransformMatrixscale(double sx, double sy, double sz)Applies a scaling operation to this TransformMatrix, by multiplying it on the LEFT by a scaling matrix.static GridTransformMatrixSetGridTransformMatrix(double a0, double a1, double a2, double a3, double b0, double b1, double b2, double b3, double c0, double c1, double c2, double c3, boolean or)Explicit constructor, giving the entries in the transformation matrix.GridTransformMatrixsetReverseSurfaceOrientation(boolean reverseSurfaceOrientation)Sets the value of the reverseSurfaceOrientation property.GridTransformMatrixsetTranslation(double x, double y, double z)Replaces the translation part of the matrix with the vector (x,y,z).GridTransformMatrixsetTranslation(Vector3D vt)Replaces the translation part of the matrix with a given Vector3D vt.GridTransformMatrixtranslate(double tx, double ty, double tz)Applies a translation operation to this TransformMatrix, by multiplying it on the LEFT by a translation matrix.GridTransformMatrixtranslate(Vector3D v)Applies a translation operation to this TransformMatrix, by multiplying it on the LEFT by a translation matrix.
-
-
-
Constructor Detail
-
GridTransformMatrix
public GridTransformMatrix()
Constructs an identity matrix.
-
GridTransformMatrix
public GridTransformMatrix(GridTransformMatrix m)
Copy constructor.- Parameters:
m- The TransformMatrix object to be copied. If m is null, an identity matrix is constructed.
-
-
Method Detail
-
SetGridTransformMatrix
public static GridTransformMatrix SetGridTransformMatrix(double a0, double a1, double a2, double a3, double b0, double b1, double b2, double b3, double c0, double c1, double c2, double c3, boolean or)
Explicit constructor, giving the entries in the transformation matrix.- Parameters:
or- tells whether the transformation should be orientation-reversing.
-
equals
public boolean equals(java.lang.Object o)
Tests whether a given object is equal to this TransformMatrix. If the object is null or is not a TransformMatrix, the return value is false. Otherwise, the return value is true if and only if the two transforms have the same matrices. ===> How about the orientation? <== HK- Overrides:
equalsin classjava.lang.Object
-
apply
public Vector3D apply(Vector3D vec)
Applies the transform to a vector. To apply the transform to (x,y,z), the column vector (x,y,z,1) is mulitplied on the left by a 4-by-4 matrix, producing a vector (a,b,c,1). The return value is the vector (a,b,c).- Parameters:
vec- The non-null vector that is to be transformed. This vector is not modified.- Returns:
- A new Vector3D object containing the result of applying the transform to vec.
-
applyToNormal
public Vector3D applyToNormal(Vector3D N)
Apply the transformation to a surface normal. If the reverseSurfaceOrientation property is true, the resulting normal is multiplied by -1.- Parameters:
N- The non-null normal vector that is to be transformed. This vector is not modified.- Returns:
- A new Vector3D object containing the result of applying the transform to N.
-
getReverseSurfaceOrientation
public boolean getReverseSurfaceOrientation()
Gets the value of the reverseSurfaceOrientation property.- See Also:
setReverseSurfaceOrientation(boolean)
-
setReverseSurfaceOrientation
public GridTransformMatrix setReverseSurfaceOrientation(boolean reverseSurfaceOrientation)
Sets the value of the reverseSurfaceOrientation property. The default value is false. This property affects the result of applying the transformation to a surface normal vector using theapplyToNormal(Vector3D)method. If the value of this property is true, then the transformed vector is negated.
-
reverse
public GridTransformMatrix reverse()
Reverses the value of the reverseSurfaceOrientation property. Calling this method is equivalent to calling setReverseSurfaceOrientation( ! getReverseSurfaceOrientation )- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
scale
public GridTransformMatrix scale(double s)
Applies a scaling operation to this TransformMatrix, by multiplying it on the LEFT by a scaling matrix. This TransformMatrix is modified in place.- Parameters:
s- The (uniform) scale factor.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
scale
public GridTransformMatrix scale(double sx, double sy, double sz)
Applies a scaling operation to this TransformMatrix, by multiplying it on the LEFT by a scaling matrix. This TransformMatrix is modified in place.- Parameters:
sx- The scaling in the x direction.sy- The scaling in the y direction.sz- The scaling in the z direction.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
translate
public GridTransformMatrix translate(double tx, double ty, double tz)
Applies a translation operation to this TransformMatrix, by multiplying it on the LEFT by a translation matrix. This TransformMatrix is modified in place.- Parameters:
tx- The translation in the x direction.ty- The translation in the y direction.tz- The translation in the z direction.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
translate
public GridTransformMatrix translate(Vector3D v)
Applies a translation operation to this TransformMatrix, by multiplying it on the LEFT by a translation matrix. This TransformMatrix is modified in place.- Parameters:
v- The translation vector. If v == null: return this.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
setTranslation
public GridTransformMatrix setTranslation(Vector3D vt)
Replaces the translation part of the matrix with a given Vector3D vt. This does not compose the transformation with a translation; it disacards the current translation and applies a new one. Calling this method is equivalent to calling translate(tr.minus(getTranslation())).- Parameters:
vt- The vector that becomes the new translation. A null vector is taken to be zero.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
setTranslation
public GridTransformMatrix setTranslation(double x, double y, double z)
Replaces the translation part of the matrix with the vector (x,y,z). This does not compose the transformation with a translation; it disacards the current translation and applies a new one.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
rotateZ
public GridTransformMatrix rotateZ(double degrees)
Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix. The rotation is about the z-axis, through a specified number of degrees. This TransformMatrix is modified in place.- Parameters:
degrees- Measure, in degrees, of the angle of rotation about the z-axis.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
rotateX
public GridTransformMatrix rotateX(double degrees)
Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix. The rotation is about the x-axis, through a specified number of degrees. This TransformMatrix is modified in place.- Parameters:
degrees- Measure, in degrees, of the angle of rotation about the x-axis.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
rotateY
public GridTransformMatrix rotateY(double degrees)
Applies a rotation operation to this TransformMatrix, by multiplying it on the LEFT by a rotation matrix. The rotation is about the y-axis, through a specified number of degrees. This TransformMatrix is modified in place.- Parameters:
degrees- Measure, in degrees, of the angle of rotation about the y-axis.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
leftMultiplyBy
public GridTransformMatrix leftMultiplyBy(GridTransformMatrix m)
Multiplying this GridTransformationMatrix on the left by another matrix. Note that the transformation is modified in place.- Parameters:
m- the matrix by which this matrix is to be multiplied on the left. If m is null, this matrix is not modified.- Returns:
- A reference to this TransformMatrix -- returned for convenience to allow chaining of transformations.
-
-
DMelt 3.0 © DataMelt by jWork.ORG