|
MathWorx | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object | +--AffineTransform
This is a class that specifies special matrices that are affine transformations of homogeneous coordinates and allows them to be applied to point2D and point3D objectss.
This class is primarily used internally by the point2D and point3D classes, but can also be called as such, for example:
var T = new AffineTransform(3).rotationX(Math.PI);
The transformation methods return the current AffineTransform object, allowing compound transformation. Compound transformations are handled in reverse order. For example:
var p3D = T.applyTo(new point3D(1,1,1));
var T = new AffineTransform(3).rotationX(Math.PI).translate3D(1,1,1);
var p3D = T.applyTo(new point3D(1,1,1));
represents the following operation:
p3D = (translate3D(1,1,1) x rotationX(Math.PI)) x (1,1,1,1);
p3D =
([1 0 0 1] [1 0 0 0] ) [1]
([0 1 0 1] [0 -1 0 0]) [1]
([0 0 1 1] [0 0 -1 0]) [1]
([0 0 0 1] [0 0 0 1] ) [1]
(NOTE: [1 1 1 1] is the column matrix representation of the new point3D(1,1,1) object)
Note that the transformation methods update the current AffineTransform object (allowing compound transformations) while the invert() method creates a new AffineTransform object with the opposite transformation as its matrix.
Defined in AffineTransform.js
Requires:
Field Summary | |
Integer |
dim
The dimension of the transformation (1 less than dimension of matrix). |
Matrix |
matrix
The transformation matrix that will be created when specific methods are called. |
Constructor Summary | |
AffineTransform(<Integer> dim)
Construct a new AffineTransform object, which contains a dimension, a transformation matrix (set by instance methods), and the applyTo method. |
Method Summary | |
Object
|
applyTo(point)
Applies the transformation to a point2D or point3D object. |
AffineTransform
|
invert()
Inverts an Affine Transformation. |
Boolean
|
invertible()
Tests to see if an Affine Transformation is invertible. |
Object
|
newCoordinates(<Number> theta, <Number> phi)
Transforms a point in Euler coordinates to a new coordinate system, defined by a normal vector from the origin. |
AffineTransform
|
rotate2D(<Number> theta)
Rotates a point (x,y,1) about the angle theta in the xy-plane. |
AffineTransform
|
rotation(<Number> theta, <Object> axis)
Creates a rotation matrix about an arbitrary axis. |
AffineTransform
|
rotationX(<Number> phi)
Rotates a point (x,y,z,1) through an angle phi about the x-axis. |
AffineTransform
|
rotationY(theta)
Rotates a point (x,y,z,1) through an angle theta about the y-axis. |
AffineTransform
|
rotationZ(psi)
Rotates a point (x,y,z,1) through an angle psi about the z-axis. |
String
|
toString()
Returns a string representation of the Affine Transformation matrix. |
AffineTransform
|
translate2D(<Number> tx, <Number> ty)
Creates a 2D translation matrix (3x3). |
AffineTransform
|
translate3D(<Number> tx, <Number> ty, <Number> tz)
Creates a 3D translation matrix (4x4). |
Field Detail |
Integer dim
Matrix matrix
Constructor Detail |
AffineTransform(<Integer> dim)
dim
- the dimension (2 or 3) of the Affine Transformation.
Method Detail |
Object applyTo(point)
AffineTransform invert()
Boolean invertible()
Object newCoordinates(<Number> theta, <Number> phi)
theta
- the degree (in radians) on the XY-plane to the normal vector
phi
- the degree in radians from the positive z axis to the normal vector
AffineTransform rotate2D(<Number> theta)
theta
- the degrees (in radians) to rotate the point by
AffineTransform rotation(<Number> theta, <Object> axis)
theta
- the number of degrees (in radians) to rotate
axis
- (Optional) the axis (3-D Vector, point3D or Array or Line) about which to rotate; if not supplied, assume 2D rotation of theta in XY-plane
AffineTransform rotationX(<Number> phi)
phi
- the degrees (in radians) to rotate the point by
AffineTransform rotationY(theta)
phi
- the degrees (in radians) to rotate the point by
AffineTransform rotationZ(psi)
phi
- the degrees (in radians) to rotate the point by
String toString()
AffineTransform translate2D(<Number> tx, <Number> ty)
tx
- the x-coordinate translation
ty
- the y-coordinate translation
tz
- the z-coordinate translation
AffineTransform translate3D(<Number> tx, <Number> ty, <Number> tz)
tx
- the x-coordinate translation
ty
- the y-coordinate translation
tz
- the z-coordinate translation
|
MathWorx | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |