|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecty25.graphics.Transform
Represents a transform in three dimensional space that can be applied to points and vectors.
Internally, every transform is stored as a 4x4 matrix M
.
Applying a transform on a point p = (px,py,pz)^t
simply means pre-multiplying the matrix after extending the point with the
homogeneous coordinate of 1
:
p_transformed = M * (px,py,pz,1)^t
("^t" means transposed).
Similary, transforming a vector v = (vx,vy,vz)
is
accomplished by appending a homogeneous coordinate of 0
and
then pre-multiplying by M
:
v_transformed = M * (vx,vy,vz,0)^t
.
Therefore, all transformations that can be performed by this class are affine and projective transforms.
Nested Class Summary | |
static class |
Transform.Matrix4x4
A representation for 4x4 matrices. |
Field Summary | |
static int |
COLUMNS
Storage specifier - indicates that the columns of a matrix are stored consecutively. |
protected Transform.Matrix4x4 |
inverse
The matrix that stores the inverse of the current transform operation. |
static int |
ROWS
Storage specifier - indicates that the rows of a matrix are stored consecutively. |
protected Transform.Matrix4x4 |
transform
The matrix that stores the current transform operation. |
Constructor Summary | |
Transform()
Creates an identity transform (a transform that has no effect when applied). |
|
Transform(float[] m,
int storeOrder)
Creates a transform by means of a user specified transformation matrix. |
|
Transform(Transform.Matrix4x4 trans)
Creates a transform by means of a user specified transformation matrix. |
|
Transform(Transform.Matrix4x4 trans,
Transform.Matrix4x4 inv)
Creates a transform by means of a user specified transformation matrix and its inverse. |
|
Transform(Transform t)
Creates a transform by copying the given transform. |
Method Summary | |
Point3D |
apply(Point3D p)
Applies this transform to the passed point and returns a reference to that point. |
Transform |
apply(Transform t)
Applies this transform to the passed transform and returns a reference to the modified passed transform. |
Vector3D |
apply(Vector3D v)
Applies this transform to the passed vector and returns a reference to that vector. |
Point3D |
getApplied(Point3D p)
Applies this transform to a copy of the passed point and returns the copy. |
Transform |
getApplied(Transform t)
Applies this transform to a copy of the passed transform and returns a reference to that copy. |
Vector3D |
getApplied(Vector3D v)
Applies this transform to the passed vector and returns a reference to that vector. |
float[] |
getArray(int storeOrder)
Returns the entries of the matrix that represents this transform in the specified order. |
Transform |
getInverted()
Returns copy of this transform that is the inverse of this transform. |
Transform |
invert()
Inverts this transform. |
static Transform |
lookAt(Point3D pos,
Point3D look,
Vector3D up)
Creates a transform that can be used as a viewing transform that has the same effect as the OpenGL gluLookAt() routine. |
static Transform |
perspective(float fov,
float aspect,
float zNear,
float zFar)
Creates a transform that can be used as a projection transform that has the same effect as the OpenGL gluPerspective() routine. |
static Transform |
rotate(Vector3D axis,
float angle)
Creates a transform, that, when applied, performs a counter-clockwise rotation around the given vector. |
static Transform |
rotateX(float angle)
Creates a transform, that, when applied, performs a counter-clockwise rotation around the x-axis. |
static Transform |
rotateY(float angle)
Creates a transform, that, when applied, performs a counter-clockwise rotation around the y-axis. |
static Transform |
rotateZ(float angle)
Creates a transform, that, when applied, performs a counter-clockwise rotation around the z-axis. |
static Transform |
scale(float x,
float y,
float z)
Creates a transform, that, when applied, performs a scaling of the x,y,z-axes by the given factors. |
void |
setIdentity()
Sets the current transform to the identity transform. |
String |
toString()
|
static Transform |
translate(Vector3D delta)
Creates a transform, that, when applied, performs a translation by the given vector. |
static Transform |
viewport(float x,
float y,
float width,
float height)
Creates a transform that can be used as a viewport transform that has the same effect as the OpenGL glViewport() routine. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Transform.Matrix4x4 transform
protected Transform.Matrix4x4 inverse
public static final int ROWS
public static final int COLUMNS
Constructor Detail |
public Transform()
public Transform(Transform t)
public Transform(float[] m, int storeOrder)
The passed array has to hold 4*4=16 values for all entries of a 4x4
matrix and the storeOrder
specifies if columns or rows
appear consecutively in the passed array.
public Transform(Transform.Matrix4x4 trans)
public Transform(Transform.Matrix4x4 trans, Transform.Matrix4x4 inv)
Method Detail |
public static Transform translate(Vector3D delta)
public static Transform scale(float x, float y, float z)
public static Transform rotateX(float angle)
The passed angles are in degrees, not radians.
public static Transform rotateY(float angle)
The passed angles are in degrees, not radians.
public static Transform rotateZ(float angle)
The passed angles are in degrees, not radians.
public static Transform rotate(Vector3D axis, float angle)
The passed angles are in degrees, not radians.
public static Transform lookAt(Point3D pos, Point3D look, Vector3D up)
When a "viewing transform" is applied to a vector that has world coordinates, they are transformed to camera coordinates.
public static Transform perspective(float fov, float aspect, float zNear, float zFar)
public static Transform viewport(float x, float y, float width, float height)
public void setIdentity()
public float[] getArray(int storeOrder)
public Transform invert()
public Transform getInverted()
public Point3D apply(Point3D p)
public Point3D getApplied(Point3D p)
public Vector3D apply(Vector3D v)
public Vector3D getApplied(Vector3D v)
public Transform apply(Transform t)
public Transform getApplied(Transform t)
public String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |