|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jwo.utils.structure.JWMatrix
Class containing Matrix processing operations. Includes general martix operations such as addition, multiplication, and inverses, dot and cross products. Also includes operations optimised for 3D vectors. Some of these routines (e.g. vMatch) were converted from the vector maths utilities in C, written by Gustav Taxen, 1998.
Constructor Summary | |
JWMatrix()
|
Method Summary | |
static double[][] |
mCopy(double[][] m)
Produces a copy of a given (4x4) matrix. |
static float[][] |
mCopy(float[][] m)
Produces a copy of a given (4x4) matrix. |
static void |
mDisplay(double[][] m)
Displays the contents of a 2D matrix of any size to maximum number of decimal places. |
static void |
mDisplay(double[][] m,
int dp)
Displays the contents of a 2D matrix of any size to a given number of decimal places. |
static void |
mDisplay(float[][] m)
Displays the contents of a 2D matrix of any size to maximum number of decimal places. |
static void |
mDisplay(float[][] m,
int dp)
Displays the contents of a 2D matrix of any size to a given number of decimal places. |
static float[][] |
mIdentity()
Creates a (4x4) identity matrix. |
static double[][] |
mIdentityd()
Creates a (4x4) identity matrix. |
static float[][] |
mInverse(float[][] m)
Calculates the inverse of a (4x4) matrix. |
static float[][] |
mmMultiply(float[][] m1,
float[][] m2)
Multiplies two 2-dimensional matrices (m1 dot m2) of any size. |
static double[][] |
mMultiply(double[][] m1,
double[][] m2)
Premultiplies two (4x4) homogeneous matrices (m1 dot m2). |
static float[][] |
mMultiply(float[][] m1,
float[][] m2)
Premultiplies two (4x4) homogeneous matrices (m1 dot m2). |
static double[][] |
mRotate(double[] axis,
double alpha)
Calculates the (4x4) homogeneous rotation matrix by a given angle about a given axis. |
static float[][] |
mRotate(float[] axis,
float alpha)
Calculates the (4x4) homogeneous rotation matrix by a given angle about a given axis. |
static float[][] |
mTranspose(float[][] m)
Returns the transpose of a 2D matrix of any size. |
static float[] |
mvMultiply(float[][] m,
float[] v)
Multiplies a 2-dimensional matrix by a vector (m dot v) of any size. |
static double[] |
serialise(double[][] m)
Returns a 1-dimensional 'serialised' verion of a given 2d 4x4 matrix. |
static float[] |
serialise(float[][] m)
Returns a 1-dimensional 'serialised' verion of a given 2d 4x4 matrix. |
static double[] |
vAdd(double[] u,
double[] v)
Adds one (3D) vector to another. |
static float[] |
vAdd(float[] u,
float[] v)
Adds one (3D) vector to another. |
static double |
vAngle(double[] u,
double[] v)
Calculates the angle between two (3D) vectors u and v. |
static float |
vAngle(float[] u,
float[] v)
Calculates the angle between two (3D) vectors u and v. |
static double[] |
vCopy(double[] v)
Produces a copy of a given (3D) vector. |
static float[] |
vCopy(float[] v)
Produces a copy of a given (3D) vector. |
static double[] |
vCross(double[] u,
double[] v)
Calculates the cross product of two (3D) vectors. |
static double[] |
vCross(double x1,
double y1,
double z1,
double x2,
double y2,
double z2)
Calculates the cross product of two (3D) vectors. |
static float[] |
vCross(float[] u,
float[] v)
Calculates the cross product of two (3D) vectors. |
static float[] |
vCross(float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
Calculates the cross product of two (3D) vectors. |
static void |
vDisplay(double[] v)
Displays the contents of a 1D vector of any size. |
static void |
vDisplay(float[] v)
Displays the contents of a 1D vector of any size. |
static double |
vDistance(double[] u,
double[] v)
Calculates the distance between two (3D) points u and v. |
static float |
vDistance(float[] u,
float[] v)
Calculates the distance between two (3D) points u and v. |
static double |
vDistanceSq(double[] u,
double[] v)
Calculates the squared distance between two (3D) points u and v. |
static float |
vDistanceSq(float[] u,
float[] v)
Calculates the squared distance between two (3D) points u and v. |
static double |
vDot(double[] u,
double[] v)
Calculates the dot product of two (3D) vectors. |
static float |
vDot(float[] u,
float[] v)
Calculates the dot product of two (3D) vectors. |
static double |
vLength(double[] v)
Calculates the length of a (3D) vector. |
static float |
vLength(float[] v)
Calculates the length of a (3D) vector. |
static double |
vLengthSq(double[] v)
Calculates the squared length of a (3D) vector. |
static float |
vLengthSq(float[] v)
Calculates the squared length of a (3D) vector. |
static double[] |
vMatch(double[] u,
double[] v)
Calculates the rotation angle R and axis A such that when rotated, (3D) vector u coincides with (3D) vector v. |
static float[] |
vMatch(float[] u,
float[] v)
Calculates the rotation angle R and axis A such that when rotated, (3D) vector u coincides with (3D) vector v. |
static double[] |
vNormalise(double[] v)
Normalises a (3D) vector so its length is 1. |
static float[] |
vNormalise(float[] v)
Normalises a (3D) vector so its length is 1. |
static double[] |
vRotate(double[] v,
double[] axis,
double alpha)
Rotates a (3D) vector by a given angle around a given axis. |
static float[] |
vRotate(float[] v,
float[] axis,
float alpha)
Rotates a (3D) vector by a given angle around a given axis. |
static float[] |
vRotateRel(float[] v1,
float alpha1,
float[] v2,
float alpha2)
Given two rotation axis vectors and their angles of rotation, returns the relative rotation vector that would rotate the first to the second. |
static double[] |
vRotateX(double[] v,
double alpha)
Rotates a (3D) vector by a given angle around the X axis. |
static float[] |
vRotateX(float[] v,
float alpha)
Rotates a (3D) vector by a given angle around the X axis. |
static double[] |
vRotateY(double[] v,
double alpha)
Rotates a (3D) vector by a given angle around the Y axis. |
static float[] |
vRotateY(float[] v,
float alpha)
Rotates a (3D) vector by a given angle around the Y axis. |
static double[] |
vRotateZ(double[] v,
double alpha)
Rotates a (3D) vector by a given angle around the Z axis. |
static float[] |
vRotateZ(float[] v,
float alpha)
Rotates a (3D) vector by a given angle around the Z axis. |
static double[] |
vScale(double[] v,
double s)
Multiplies a (3D) vector by a given scalar constant. |
static float[] |
vScale(float[] v,
float s)
Multiplies a (3D) vector by a given scalar constant. |
static double[] |
vSphere(double phi,
double lambda)
Finds the (3D) vector represented by given phi and lambda angles in spherical coordinates. |
static float[] |
vSphere(float phi,
float lambda)
Finds the (3D) vector represented by given phi and lambda angles in spherical coordinates. |
static double[] |
vSubtract(double[] u,
double[] v)
Subtracts a (3D) vector from another. |
static float[] |
vSubtract(float[] u,
float[] v)
Subtracts a (3D) vector from another. |
static double[] |
vTransform(double[][] m,
double[] v)
Premultiplies a (3D) vector by a homogeneous (4x4) transformation matrix. |
static float[] |
vTransform(float[][] m,
float[] v)
Premultiplies a (3D) vector by a homogeneous (4x4) transformation matrix. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JWMatrix()
Method Detail |
public static float[][] mTranspose(float[][] m)
m
- Input matrix
public static float[] vAdd(float[] u, float[] v)
u
- First vector.v
- Second vector.
public static double[] vAdd(double[] u, double[] v)
u
- First vector.v
- Second vector.
public static float vAngle(float[] u, float[] v)
u
- First vector.v
- Second vector.
public static double vAngle(double[] u, double[] v)
u
- First vector.v
- Second vector.
public static float[][] mCopy(float[][] m)
m
- Matrix to copy.
public static double[][] mCopy(double[][] m)
m
- Matrix to copy.
public static float[] vCopy(float[] v)
v
- Vector to copy.
public static double[] vCopy(double[] v)
v
- Vector to copy.
public static float[] vCross(float[] u, float[] v)
u
- First vector.v
- Second vector.
public static float[] vCross(float x1, float y1, float z1, float x2, float y2, float z2)
x1
- First vector x coordinate.y1
- First vector y coordinate.z1
- First vector z coordinate.x2
- Second vector x coordinate.y2
- Second vector y coordinate.z2
- Second vector z coordinate.
public static double[] vCross(double[] u, double[] v)
u
- First vector.v
- Second vector.
public static double[] vCross(double x1, double y1, double z1, double x2, double y2, double z2)
x1
- First vector x coordinate.y1
- First vector y coordinate.z1
- First vector z coordinate.x2
- Second vector x coordinate.y2
- Second vector y coordinate.z2
- Second vector z coordinate.
public static void mDisplay(float[][] m)
m
- Matrix to display.public static void mDisplay(double[][] m)
m
- Matrix to display.public static void mDisplay(float[][] m, int dp)
m
- Matrix to display.dp
- Number of decimal places to display.public static void mDisplay(double[][] m, int dp)
m
- Matrix to display.dp
- Number of decimal places to display.public static void vDisplay(float[] v)
v
- Vector to display.public static void vDisplay(double[] v)
v
- Vector to display.public static float vDistance(float[] u, float[] v)
u
- First point vector.v
- Second point vector.
public static double vDistance(double[] u, double[] v)
u
- First point vector.v
- Second point vector.
public static float vDistanceSq(float[] u, float[] v)
u
- First point vector.v
- Second point vector.
public static double vDistanceSq(double[] u, double[] v)
u
- First point vector.v
- Second point vector.
public static float vDot(float[] u, float[] v)
u
- First vector.v
- Second vector.
public static double vDot(double[] u, double[] v)
u
- First vector.v
- Second vector.
public static float[][] mIdentity()
public static double[][] mIdentityd()
public static float[][] mInverse(float[][] m)
m
- Matrix to find inverse of.
public static float vLength(float[] v)
v
- Vector to measure.
public static double vLength(double[] v)
v
- Vector to measure.
public static float vLengthSq(float[] v)
v
- Vector to measure.
public static double vLengthSq(double[] v)
v
- Vector to measure.
public static float[] vMatch(float[] u, float[] v)
u
- First normalised vector to compare.v
- Second normalised vector to compare.
public static double[] vMatch(double[] u, double[] v)
u
- First normalised vector to compare.v
- Second normalised vector to compare.
public static float[][] mMultiply(float[][] m1, float[][] m2)
m1
- First matrix.m2
- Second matrix.
public static float[][] mmMultiply(float[][] m1, float[][] m2)
m1
- First matrix.m2
- Second matrix.
public static float[] mvMultiply(float[][] m, float[] v)
m
- Matrix. This must have the same number of columns as the vector has elements.v
- Vector. This must have the same number of elements as the matrix has columns.
public static double[][] mMultiply(double[][] m1, double[][] m2)
m1
- First matrix.m2
- Second matrix.
public static float[] vNormalise(float[] v)
v
- Vector to normalise.
public static double[] vNormalise(double[] v)
v
- Vector to normalise.
public static float[][] mRotate(float[] axis, float alpha)
axis
- Vector representing normalised rotation axis.alpha
- Angle to rotate by (in radians).
public static double[][] mRotate(double[] axis, double alpha)
axis
- Vector representing normalised rotation axis.alpha
- Angle to rotate by (in radians).
public static float[] vRotate(float[] v, float[] axis, float alpha)
v
- Vector to rotate.axis
- Vector representing normalised rotation axis.alpha
- Angle to rotate by (in radians).
public static double[] vRotate(double[] v, double[] axis, double alpha)
v
- Vector to rotate. Double precision version.axis
- Vector representing normalised rotation axis.alpha
- Angle to rotate by (in radians).
public static float[] vRotateX(float[] v, float alpha)
v
- Vector to rotate.alpha
- Angle to rotate by (in radians).
public static double[] vRotateX(double[] v, double alpha)
v
- Vector to rotate.alpha
- Angle to rotate by (in radians).
public static float[] vRotateY(float[] v, float alpha)
v
- Vector to rotate.alpha
- Angle to rotate by (in radians).
public static double[] vRotateY(double[] v, double alpha)
v
- Vector to rotate.alpha
- Angle to rotate by (in radians).
public static float[] vRotateZ(float[] v, float alpha)
v
- Vector to rotate.alpha
- Angle to rotate by (in radians).
public static double[] vRotateZ(double[] v, double alpha)
v
- Vector to rotate.alpha
- Angle to rotate by (in radians).
public static float[] vRotateRel(float[] v1, float alpha1, float[] v2, float alpha2)
v1
- First rotation axis.alpha1
- Angle of first rotation (in radians).v2
- Second rotation axis.alpha2
- Angle of second rotation (in radians).
public static float[] vScale(float[] v, float s)
v
- Vector to scale.s
- Scalar constant.
public static double[] vScale(double[] v, double s)
v
- Vector to scale.s
- Scalar constant.
public static float[] vSphere(float phi, float lambda)
phi
- 'Latitude' in radians from 0 - PI.lambda
- 'Longitude' in radians from 0 - 2*PI.
public static double[] vSphere(double phi, double lambda)
phi
- 'Latitude' in radians from 0 - PI.lambda
- 'Longitude' in radians from 0 - 2*PI.
public static float[] vSubtract(float[] u, float[] v)
u
- First vector.v
- Second vector.
public static double[] vSubtract(double[] u, double[] v)
u
- First vector.v
- Second vector.
public static float[] vTransform(float[][] m, float[] v)
m
- Transformation Matrix (4x4).v
- Coordinate vector.
public static double[] vTransform(double[][] m, double[] v)
m
- Transformation Matrix (4x4).v
- Coordinate vector.
public static float[] serialise(float[][] m)
m
- 4x4 matrix to serialise.
public static double[] serialise(double[][] m)
m
- 4x4 matrix to serialise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |