jv.vecmath
Class PuReflect
- java.lang.Object
-
- jv.vecmath.PuReflect
-
public class PuReflect extends java.lang.ObjectUtility class with static methods to compute reflection and other symmetry matrices.Most matrices are intended to work with homogenous coordinate representations, that means, the matrix of dimension (dim+1)*(dim+1) is later applied to points in ambient dim-space. See also the classes PdVector and PdMatrix which provide homogenous linear algebra multiplications.
- Author:
- Konrad Polthier
- Version:
- 04.11.06, 1.50 revised (kp) Several methods for arbitrary dimension, new methods for rotation.
29.12.03, 1.40 revised (kp) New method getRotation().
26.06.03, 1.30 revised (kp) Reduce internal object allocations.
18.03.01, 1.20 revised (kp) Method scale added.
03.10.99, 1.10 revised (kp) Renamed from PdReflect to PuReflect.
11.07.99, 1.01 revised (kp) Included in JavaView, method mult43() moved to PdVector.
00.06.99, 1.00 created (kp) Converted from my c-code.
-
-
Constructor Summary
Constructors Constructor and Description PuReflect()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.lang.DoublegetRotation(PdMatrix mat, PdVector axis)Get axis and angle of a 3x3 rotation matrix.static booleanmakeRotation(PdMatrix mat, PdVector axis, double angle)Assign a (3*3)-rotation matrix to rotate around axis through origin with given angle.static PdMatrixplaneReflect(PdVector base, PdVector normal)Generate a (dim+1)*(dim+1)-matrix to reflect in plane determined by a base point and a plane normal.static PdMatrixplaneReflect(PdVector a, PdVector b, PdVector c)Generate a (4*4)-matrix to reflect in plane given by three vertices on the plane in R3.static PdMatrixpointReflect(PdVector p)Generate a (dim+1)*(dim+1)-matrix to invert space at a given center point.static PdMatrixrotate(PdMatrix mat, double angle, int indI, int indJ)Generate a homogeneous matrix to rotate in the (indI,indJ)-plane around a given angle in radians (i.e.static PdMatrixrotateLine(PdMatrix mat, PdVector base, PdVector axis)Fill a given (4*4)-matrix to rotate around axisbase+t*dirby 180 degrees.static PdMatrixrotateLine(PdMatrix mat, PdVector base, PdVector axis, double angle)Fill a (4*4)-matrix to rotate around axisbase+t*dirby given angle.static PdMatrixrotateLine(PdVector base, PdVector axis)Generate a (4*4)-matrix to rotate around axisbase+t*dirby 180 degrees.static PdMatrixrotateLine(PdVector base, PdVector axis, double fi)Generate a (4*4)-matrix to rotate around axisbase+t*dirby given angle.static PdMatrixrotateXY(double angle, int dim)Generate a homogeneous matrix to rotate in the XY-plane around a given angle in radians (i.e.static PdMatrixrotateXZ(double angle, int dim)Generate a homogeneous matrix to rotate in the XZ-plane around a given angle in radians (i.e.static PdMatrixrotateYZ(double angle, int dim)Generate a homogeneous matrix to rotate in the YZ-plane around a given angle in radians (i.e.static PdMatrixscale(double s, int dim)Generate a homogeneous matrix to non-uniform scale by a given vectorp[i] = p[i]*s.static PdMatrixscale(PdVector v)Generate a homogeneous matrix to non-uniform scale by a given vectorp[i] = p[i]*v[i].static PdMatrixtranslate(PdVector v)Generate a (dim+1)*(dim+1) matrix m to translate a point p by a given vector v:m*p=p+v.
-
-
-
Method Detail
-
makeRotation
public static boolean makeRotation(PdMatrix mat, PdVector axis, double angle)
Assign a (3*3)-rotation matrix to rotate around axis through origin with given angle. Parameter mat and axis must have dimension greater or equal to three. Only first three components are used.- Parameters:
mat- Matrix to hold the transformation matrix.axis- direction of rotation axis, need not be normalizedangle- angle in radians about to rotate- Returns:
- false missing axis or problems in its normalization
- Version:
- 26.06.03, 1.10 revised (kp) Avoid internal object allocation.
07.09.99, 1.00 created (kp) Method moved from PdMatrix.
-
getRotation
public static java.lang.Double getRotation(PdMatrix mat, PdVector axis)
Get axis and angle of a 3x3 rotation matrix. I- and J-dimension of matrix must both be equal or greater than 3.- Parameters:
mat- Matrix to hold the transformation matrix.axis- direction of rotation axis, need not be normalized- Returns:
- angle in radians about to rotate or null if error
- Version:
- 28.12.03, 1.00 created (kp)
-
rotateLine
public static PdMatrix rotateLine(PdMatrix mat, PdVector base, PdVector axis)
Fill a given (4*4)-matrix to rotate around axisbase+t*dirby 180 degrees. Parameter base and axis must have dimension greater or equal to three. Only first three components are used.There are no object allocations in this method.
- Parameters:
mat- 4*4 matrix which will be filled.base- Arbitrary point on rotation axis.axis- Direction of rotation axis, need not be normalized- Returns:
- given matrix
- Since:
- JavaView 2.83.000
- Version:
- 26.06.03, 1.00 created (kp) From body of rotateLine(PdVector,PdVector).
-
rotateLine
public static PdMatrix rotateLine(PdVector base, PdVector axis)
Generate a (4*4)-matrix to rotate around axisbase+t*dirby 180 degrees. Parameter base and axis must have dimension greater or equal to three. Only first three components are used.Method allocates a new matrix and invokes
rotateLine- Parameters:
base- Arbitrary point on rotation axis.axis- Direction of rotation axis, need not be normalized- Returns:
- new rotation matrix
- Version:
- 26.06.03, 2.00 revised (kp) Body moved to rotateLine(PdMatrix,PdVector,PdVector).
-
rotateLine
public static PdMatrix rotateLine(PdMatrix mat, PdVector base, PdVector axis, double angle)
Fill a (4*4)-matrix to rotate around axisbase+t*dirby given angle. Parameter base and axis must have dimension greater or equal to three. Only first three components are used.There are no object allocations in this method.
- Parameters:
mat- 4*4 matrix which will be filled.base- Arbitrary point on rotation axis.axis- Direction of rotation axis, need not be normalizedangle- Angle in radians about to rotate.- Returns:
- given matrix
- Since:
- JavaView 2.83.000
- Version:
- 26.06.03, 1.00 created (kp) From body of rotateLine(PdVector,PdVector,double).
-
rotateLine
public static PdMatrix rotateLine(PdVector base, PdVector axis, double fi)
Generate a (4*4)-matrix to rotate around axisbase+t*dirby given angle. Parameter base and axis must have dimension greater or equal to three. Only first three components are used.- Parameters:
base- Arbitrary point on rotation axis.axis- Direction of rotation axis, need not be normalizedfi- Angle in radians about to rotate.- Returns:
- Rotation matrix
- Version:
- 26.06.03, 2.00 revised (kp) Body moved to rotateLine(PdMatrix,PdVector,PdVector,double).
-
planeReflect
public static PdMatrix planeReflect(PdVector a, PdVector b, PdVector c)
Generate a (4*4)-matrix to reflect in plane given by three vertices on the plane in R3.- Parameters:
a- Point on the plane.b- Point on the plane.c- Point on the plane.- Returns:
- Reflection matrix of dimension (4*4).
-
planeReflect
public static PdMatrix planeReflect(PdVector base, PdVector normal)
Generate a (dim+1)*(dim+1)-matrix to reflect in plane determined by a base point and a plane normal.- Parameters:
base- Arbitrary point on plane of dimension dim.normal- Normal vector orthonormal to plane.- Returns:
- Reflection matrix of dimension (dim+1)
- Version:
- 26.06.03, 1.10 revised (kp) Reduce internal object allocation.
-
pointReflect
public static PdMatrix pointReflect(PdVector p)
Generate a (dim+1)*(dim+1)-matrix to invert space at a given center point. The mapping is: reflect(x) = -x+2p. If p=0 then x goes to -x. The matrix has dimension (dim+1) if dim is the dimension of the vector.- Parameters:
p- Arbitrary point of dimension dim as inversion center.- Returns:
- Inversion matrix of dimension (dim+1)
- Version:
- 12.09.07, 1.35 revised (kp) Bug in array index removed.
19.06.07, 1.30 revised (kp) Bug for 2d point removed.
04.11.06, 1.20 revised (kp) Arbitrary dimension.
28.12.03, 1.10 revised (kp) Assure 3d dimensionality of point.
-
translate
public static PdMatrix translate(PdVector v)
Generate a (dim+1)*(dim+1) matrix m to translate a point p by a given vector v:m*p=p+v. The matrix has dimension (dim+1) if dim is the dimension of the vector.- Parameters:
v- Translation vector.- Returns:
- Translation matrix of dimension (dim+1)
- Version:
- 29.03.06, 1.20 revised (ah) Arbitrary dimension.
28.12.03, 1.10 revised (kp) Assure 3d dimensionality of vector.
-
scale
public static PdMatrix scale(PdVector v)
Generate a homogeneous matrix to non-uniform scale by a given vectorp[i] = p[i]*v[i]. The matrix has dimension (dim+1) if dim is the dimension of the vector.- Parameters:
v- Scaling vector of dimension dim.- Returns:
- New scaling matrix of dimension (dim+1)
- Version:
- 29.03.06, 1.20 revised (ah) Arbitrary dimension.
28.12.03, 1.10 revised (kp) Assure 3d dimensionality of vector.
18.03.01, 1.00 created (kp)
-
scale
public static PdMatrix scale(double s, int dim)
Generate a homogeneous matrix to non-uniform scale by a given vectorp[i] = p[i]*s. The generated matrix is a (dim+1) square matrix.- Parameters:
s- Scaling factor.dim- Dimension of ambient space.- Returns:
- New scaling matrix of dimension (dim+1)
- Version:
- 29.03.06, 1.00 created (ah)
-
rotateXY
public static PdMatrix rotateXY(double angle, int dim)
Generate a homogeneous matrix to rotate in the XY-plane around a given angle in radians (i.e. PI). The generated matrix is a (dim+1) square matrix.- Parameters:
angle- Angle in radians.dim- Dimension of ambient space.- Returns:
- New rotation matrix of dimension (dim+1)
- Since:
- JavaView 3.97.016
- Version:
- 04.11.06, 1.00 created (kp)
-
rotateYZ
public static PdMatrix rotateYZ(double angle, int dim)
Generate a homogeneous matrix to rotate in the YZ-plane around a given angle in radians (i.e. PI). The generated matrix is a (dim+1) square matrix.- Parameters:
angle- Angle in radians.dim- Dimension of ambient space.- Returns:
- New rotation matrix of dimension (dim+1)
- Since:
- JavaView 3.97.016
- Version:
- 04.11.06, 1.00 created (kp)
-
rotateXZ
public static PdMatrix rotateXZ(double angle, int dim)
Generate a homogeneous matrix to rotate in the XZ-plane around a given angle in radians (i.e. PI). The generated matrix is a (dim+1) square matrix.- Parameters:
angle- Angle in radians.dim- Dimension of ambient space.- Returns:
- New rotation matrix of dimension (dim+1)
- Since:
- JavaView 3.97.016
- Version:
- 04.11.06, 1.00 created (kp)
-
rotate
public static PdMatrix rotate(PdMatrix mat, double angle, int indI, int indJ)
Generate a homogeneous matrix to rotate in the (indI,indJ)-plane around a given angle in radians (i.e. PI). The generated matrix is a homogeneous (dim+1) square matrix.- Parameters:
angle- Angle in radians.indI- Dimension of first coordinates axis which determines the plane of rotation.indJ- Dimension of second coordinates axis which determines the plane of rotation.- Returns:
- Given rotation matrix
- Since:
- JavaView 3.97.016
- Version:
- 04.11.06, 1.00 created (kp)
-
-
"