de.jreality.math
Class Rn

java.lang.Object
  extended by de.jreality.math.Rn

public final class Rn
extends java.lang.Object

Static methods for n-dimensional Euclidean vector space Rn. All vectors are of type double[].

This includes a set of methods related to linear transformations of Rn. Because of the need to have matrices stored in contiguous memory (rather than Java-style as an array of pointers), matrices are also of type double[]. Since all the matrices that occur here are square ones, the actual dimensions can be calculated easily from the over-all length. For example, an array of length 16 corresponds to a 4x4 matrix. Currently the limit on the size of these square matrices is 10x10. Methods where there is a lower limit annotate this restriction.

Conventions:

Methods try as much as possible to react reasonably to differing argument types. In general, the methods check the lengths of the arguments, determine a minimum valid length on which the desired operation can be carried out, and does so. This allows some flexibility in terms of lengths of input vectors which the following paragraph attempts to justify on practical grounds.

For example. the method matrixTimesVector(double[], double[], double[]) is happiest when the dimension of the square matrix matches the length of the input vectors. However, it is often the case that users have dehomogenized coordinates for vectors, that is, one dimension less than the dimension of the matrix. For example, points in Euclidean 3-space are naturally stored as 3-vectors although the natural setting for isometries is 4x4 matrices. In this case the method assumes an implicit final coordinate of 1.0 and carries out the multiplication accordingly. At the same time, the method also operates correctly on 4-vectors.

Some commonly used methods come in two varieties: one acts on single vectors ( double[] ) and another acts on array of vectors ( double[][]). Compare matrixTimesVector(double[], double[], double[]) and matrixTimesVector(double[][], double[], double[][]).

Author:
Charles Gunn
See Also:
Pn

Field Summary
static double TOLERANCE
          The default tolerance used for checking numerical equality = 10E-8.
 
Method Summary
static double[] abs(double[] dst, double[] src)
           
static double[] add(double[] dst, double[] src1, double[] src2)
          Add the vector src1 to the vector src2 and put the result in dst.
static double[] adjoint(double[] dst, double[] src)
          Calculate the adjoint of the square matrix src and put the result into dst.
static double[] average(double[] dst, double[][] vlist)
          Calculate the average of the elements in the vector list vlist.
static double[] barycentricTriangleInterp(double[] dst, double[][] corners, double[] weights)
          Calculate the euclidean coordinates of the point whose barycentric coordinates with respect to the triangle corners are coords.
static double[] bezierCombination(double[] dst, double t, double[] v0, double[] t0, double[] t1, double[] v1)
           
static double[] bilinearInterpolation(double[] ds, double u, double v, double[] vb, double[] vt, double[] cb, double[] ct)
           
static double[][] calculateBounds(double[][] bounds, double[][] vlist)
          Given a list of vectors, calculate the minimum and maximum values in each coordinate.
static double cofactor(double[] m, int row, int column)
          Calculate the (i,j)th cofactor of the matrix m The dimension of the matrix m can be no greater than 5.
static double[][] completeBasis(double[][] dst, double[][] partial)
          The array partial contains m n-vectors which are assumed to be linearly independent.
static double[] conjugateByMatrix(double[] dst, double[] m, double[] c)
          Form the conjugate of the matrix m by the matrix c: dst = c .
static double[] convertArray2DToArray1D(double[] target, double[][] src)
          inlines the given 2-dim array.
static double[] convertArray3DToArray1D(double[][][] V)
           
static double[] convertArray3DToArray1D(double[][][] V, int usample, int vsample)
           
static double[][] convertArray3DToArray2D(double[][][] V)
           
static float[] convertDoubleToFloatArray(double[] ds)
           
static double[] copy(double[] dst, double[] src)
          Make a copy of src in dst.
static double[] crossProduct(double[] dst, double[] u, double[] v)
          Calculate the cross product of the two vectors u and v.
static double determinant(double[] m)
          Calculate the determinate of the square matrix m.
static double determinant(double[][] m)
           
static double[] diagonalMatrix(double[] dst, double[] entries)
           
static double dot(double dst, double[] src1, double[] src2)
          Multiply the vector by the scalar value factor and put result into dst.
static boolean equals(double[] u, double[] v)
          Calculate whether the two arrays contain exactly the same values.
static boolean equals(double[] u, double[] v, double tol)
          Calculate whether the two arrays contain the same values.
static double euclideanAngle(double[] u, double[] v)
          Calculate the euclidean angle between the vectors u and v.
static double euclideanDistance(double[] u, double[] v)
          Calculates and returns the euclidean distance between the two points u and v.
static double euclideanDistanceSquared(double[] u, double[] v)
          calculates and returns the square of the euclidean distance between the two points u and v.
static double euclideanNorm(double[] vec)
          Calculates and returns the euclidean norm of the input vector.
static double euclideanNormSquared(double[] vec)
          Calculates and returns the square of the euclidean norm of the input vector.
static double[] extractSubmatrix(double[] subm, double[] src, int l, int r, int t, int b)
          Extract a rectangular submatrix of the input matrix.
static double[] identityMatrix(int dim)
          Create and return an identity matrix of dimension dim.
static double innerProduct(double[] u, double[] v)
          Calculate and return the euclidean inner product of the two vectors.
static double innerProduct(double[] u, double[] v, int n)
          Calculate and return at most n terms of the inner product of the two vectors.
static double[] inverse(double[] minvIn, double[] m)
          Use Gaussian pivoting to calculate the inverse matrix of the input matrix.
static boolean isIdentityMatrix(double[] mat, double tol)
          Calculates whether the input matrix in within tol of the identity matrix.
static boolean isNan(double[] ds)
           
static boolean isSpecialMatrix(double[] mat, double tol)
          Calculates whether the input matrix is within tol of being a "special" matrix.
static boolean isZero(double[] iline)
           
static boolean isZero(double[] iline, double tol)
           
static double[] linearCombination(double[] dst, double a, double[] aVec, double b, double[] bVec)
          Calculate the linear combination dst = a*aVec + b*bVec.
static double manhattanNorm(double[] vec)
          Calculate the "manhattan norm" of the input vector.
static double manhattanNormDistance(double[] u, double[] v)
          Calculate the "manhattan norm" distance between the two input vectors.
static double[][] matrixTimesVector(double[][] dst, double[] m, double[][] src)
          A vectorized version of matrixTimesVector(double[], double[], double[]).
static double[] matrixTimesVector(double[] dst, double[] m, double[] src)
          Multiply the input vector src by the matrix m and put the result into dst.
static java.lang.String matrixToJavaString(double[] v)
          Like matrixToString(double[]), but formatted for direct insertion as java source code
static java.lang.String matrixToString(double[] m)
          Print the square matrix m into a string using default format from String.format(java.lang.String, java.lang.Object[]) and return the string.
static java.lang.String matrixToString(double[] m, java.lang.String formatString)
          Print the square matrix m into a string using formatString and return the string.
static double[] max(double[] dst, double[] src1, double[] src2)
          Calculate the maximum of two vectors, coordinate-wise.
static double maxNorm(double[] vec)
          Calculate the "max norm" of a vector.
static double maxNormDistance(double[] u, double[] v)
          Calculate the distance between two points based on the "max norm".
static double[] min(double[] dst, double[] src1, double[] src2)
          Calculate the minimum of two vectors, coordinate-wise.
static int mysqrt(int sq)
          Returns the square root of the sq parameter.
static double[] negate(double[] dst, double[] src)
          dst[i] = -src[i]
static double[][] normalize(double[][] dst, double[][] src)
           
static double[] normalize(double[] dst, double[] src)
          Normalize src using the euclidean norm.
static double[] permutationMatrix(double[] dst, int[] perm)
          Calculate a permutation matrix which sends e(i) to e(perm[i])
static double[] planeParallelToPassingThrough(double[] plane, double[] ds, double[] ds2)
           
static double[] polarDecompose(double[] q, double[] s, double[] m)
           
static double[] projectOnto(double[] dst, double[] src, double[] fixed)
          Project orthogonally src onto fixed.
static double[] projectOntoComplement(double[] dst, double[] src, double[] fixed)
          Project src onto the orthogonal complement of fixed.
static double[] setDiagonalMatrix(double[] dst, double[] diag)
          Construct and return a diagonal matrix with the entries given by the vector diag.
static double[] setEuclideanNorm(double[] dst, double length, double[] src)
          Scale the vector to have the given length.
static double[] setIdentityMatrix(double[] mat)
          Set the matrix to be the identity matrix.
static float[] setIdentityMatrix(float[] mat)
           
static double[] setToLength(double[] p1, double[] p12, double rad)
           
static double[] setToValue(double[] dst, double val)
          Set the destination to vector to have constant value val.
static double[] setToValue(double[] dst, double x, double y)
          Initialize the 2-vector dst.
static double[] setToValue(double[] dst, double x, double y, double z)
          Initialize the 3-vector dst.
static double[] setToValue(double[] dst, double x, double y, double z, double w)
          Initialize the 4-vector dst.
static double[] submatrix(double[] subm, double[] m, int row, int column)
          Extract the submatrix gotten by deleting the given row and column.
static double[] subtract(double[] dst, double[] src1, double[] src2)
          dst[i] = src1[i] - src2[i]
static void swap(double[] u, double[] v)
          Swap the contents of the two vectors.
static double[][] times(double[][] dst, double factor, double[][] src)
          A vectorized version of times(double[], double, double[]);
static double[] times(double[] dst, double[] src1, double[] src2)
          Multiply the square matrices according to the equation dst = src1 * src2 .
static double[] times(double[] dst, double factor, double[] src)
          Multiply the vector by the scalar value factor and put result into dst.
static float[] times(float[] dst, float[] src1, float[] src2)
           
static java.lang.String toString(double[] v)
          Print the array v into a string using default format from String.format(java.lang.String, java.lang.Object[]) and return the string.
static java.lang.String toString(double[][] v)
          A vectorized version of toString(double[]).
static java.lang.String toString(double[][][] v)
           
static java.lang.String toString(double[] v, java.lang.String formatString)
          Print the array v into a string using formatString and return the string.
static java.lang.String toString(float[] v)
           
static double trace(double[] m)
          Calculate the trace of the given square matrix.
static double[] transpose(double[] dst, double[] src)
          Transpose the given square matrix src into dst.
static float[] transposeD2F(float[] dst, double[] src)
          Transpose the given 4x4 matrix src into dst .
static double[] transposeF2D(double[] dst, float[] src)
          Transpose the given 4x4 matrix src into dst .
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOLERANCE

public static final double TOLERANCE
The default tolerance used for checking numerical equality = 10E-8.

See Also:
Constant Field Values
Method Detail

abs

public static double[] abs(double[] dst,
                           double[] src)
Parameters:
ds -
ds2 -

add

public static double[] add(double[] dst,
                           double[] src1,
                           double[] src2)
Add the vector src1 to the vector src2 and put the result in dst.

Parameters:
dst -
src1 -
src2 -
Returns:
dst

adjoint

public static double[] adjoint(double[] dst,
                               double[] src)
Calculate the adjoint of the square matrix src and put the result into dst. The adjoint of a matrix is a same-size matrix, whose (i,j)th entry is the determinant of the sub-matrix of the original matrix obtained by deleting the (i)th row and (j)th column. The dimension of the input matrix can be no greater than 4.

Parameters:
dst - may be null
src - may be = dst
Returns:
dst

average

public static double[] average(double[] dst,
                               double[][] vlist)
Calculate the average of the elements in the vector list vlist.

Parameters:
dst -
vlist -
Returns:

barycentricTriangleInterp

public static double[] barycentricTriangleInterp(double[] dst,
                                                 double[][] corners,
                                                 double[] weights)
Calculate the euclidean coordinates of the point whose barycentric coordinates with respect to the triangle corners are coords. This is just the weighted average of the corners of the triangle. Return the result in dst.

Parameters:
dst - double[n] (may be null)
corners - double[3][n]
weights - double[3]
Returns:

calculateBounds

public static double[][] calculateBounds(double[][] bounds,
                                         double[][] vlist)
Given a list of vectors, calculate the minimum and maximum values in each coordinate. Return the result in bounds. For example bounds[0][1] is the minimum y-value of the vectors in the list, etc.

Parameters:
bounds - double[2][n]
vlist - double[][n]
Returns:

cofactor

public static double cofactor(double[] m,
                              int row,
                              int column)
Calculate the (i,j)th cofactor of the matrix m The dimension of the matrix m can be no greater than 5.

Parameters:
m - double[n][n]
row -
column -
Returns:
m

conjugateByMatrix

public static double[] conjugateByMatrix(double[] dst,
                                         double[] m,
                                         double[] c)
Form the conjugate of the matrix m by the matrix c: dst = c . m . Inverse(c)

Parameters:
dst - double[n][n]
m - double[n][n]
c - double[n][n]
Returns:
dst

convertArray2DToArray1D

public static double[] convertArray2DToArray1D(double[] target,
                                               double[][] src)
inlines the given 2-dim array. Assumes equal length for sub-arrays

Returns:
the target array (a new one if target == null)

convertArray3DToArray1D

public static double[] convertArray3DToArray1D(double[][][] V)

convertArray3DToArray1D

public static double[] convertArray3DToArray1D(double[][][] V,
                                               int usample,
                                               int vsample)
Parameters:
V -
Returns:

convertArray3DToArray2D

public static double[][] convertArray3DToArray2D(double[][][] V)
Parameters:
V -
Returns:

convertDoubleToFloatArray

public static float[] convertDoubleToFloatArray(double[] ds)

copy

public static double[] copy(double[] dst,
                            double[] src)
Make a copy of src in dst. The length of dst may be larger than that of src. Excess terms will be left.

Parameters:
dst -
src -
Returns:

crossProduct

public static double[] crossProduct(double[] dst,
                                    double[] u,
                                    double[] v)
Calculate the cross product of the two vectors u and v. Note that the only valid dimension is 3.

Parameters:
dst - double[3]
u - double[3]
v - double[3]
Returns:
dst

determinant

public static double determinant(double[] m)
Calculate the determinate of the square matrix m. TODO: figure out how to generate the necessary permutations without having to recursively call submatrix()

Parameters:
m -
Returns:

determinant

public static double determinant(double[][] m)

dot

public static double dot(double dst,
                         double[] src1,
                         double[] src2)
Multiply the vector by the scalar value factor and put result into dst.

Parameters:
dst -
factor -
src -
Returns:

equals

public static boolean equals(double[] u,
                             double[] v)
Calculate whether the two arrays contain exactly the same values. Returns true only if the "manhattan norm" of the difference of the two vectors does not exceed the default tolerance.

Parameters:
u - double[n]
v - double[n]
Returns:
See Also:
equals()

equals

public static boolean equals(double[] u,
                             double[] v,
                             double tol)
Calculate whether the two arrays contain the same values. Returns true only if the "manhattan norm" of the difference of the two vectors does not exceed the provided tol.

Parameters:
u - double[n]
v - double[n]
tol -
Returns:

euclideanAngle

public static double euclideanAngle(double[] u,
                                    double[] v)
Calculate the euclidean angle between the vectors u and v.

Parameters:
u -
v -
Returns:

euclideanDistance

public static double euclideanDistance(double[] u,
                                       double[] v)
Calculates and returns the euclidean distance between the two points u and v.

Parameters:
u -
v -
Returns:

euclideanDistanceSquared

public static double euclideanDistanceSquared(double[] u,
                                              double[] v)
calculates and returns the square of the euclidean distance between the two points u and v.

Parameters:
u - double[n]
v - double[n]
Returns:

euclideanNorm

public static double euclideanNorm(double[] vec)
Calculates and returns the euclidean norm of the input vector.

Parameters:
vec - double[n]
Returns:
See Also:
innerProduct()

euclideanNormSquared

public static double euclideanNormSquared(double[] vec)
Calculates and returns the square of the euclidean norm of the input vector.

Parameters:
vec - double[n]
Returns:

extractSubmatrix

public static double[] extractSubmatrix(double[] subm,
                                        double[] src,
                                        int l,
                                        int r,
                                        int t,
                                        int b)
Extract a rectangular submatrix of the input matrix.

Parameters:
subm - double[b-t][r-l]
src - double[n][n]
l - begin with the lth column
r - and include the rth column
t - begin with the t-th row
b - and include the b-th row
Returns:
subm

identityMatrix

public static double[] identityMatrix(int dim)
Create and return an identity matrix of dimension dim.

Parameters:
dim -
Returns:

diagonalMatrix

public static double[] diagonalMatrix(double[] dst,
                                      double[] entries)

innerProduct

public static double innerProduct(double[] u,
                                  double[] v)
Calculate and return the euclidean inner product of the two vectors. If they are of different lengths only evaluates the inner product on the lesser of the two lengths.

Parameters:
u -
v -
Returns:

innerProduct

public static double innerProduct(double[] u,
                                  double[] v,
                                  int n)
Calculate and return at most n terms of the inner product of the two vectors. Useful when using homogenous coordinates but one wants to ignore the final coordinate.

Parameters:
u -
v -
Returns:

inverse

public static double[] inverse(double[] minvIn,
                               double[] m)
Use Gaussian pivoting to calculate the inverse matrix of the input matrix. This method is safe when minvIn == m.

Parameters:
minv - double[n][n]
m - double[n][n]
Returns:
minv

isIdentityMatrix

public static boolean isIdentityMatrix(double[] mat,
                                       double tol)
Calculates whether the input matrix in within tol of the identity matrix.

Parameters:
mat -
tol -
Returns:

isSpecialMatrix

public static boolean isSpecialMatrix(double[] mat,
                                      double tol)
Calculates whether the input matrix is within tol of being a "special" matrix. To be exact, returns true if the absolute value of the determinant is within tol of 1.0.

Parameters:
mat -
tol -
Returns:

linearCombination

public static double[] linearCombination(double[] dst,
                                         double a,
                                         double[] aVec,
                                         double b,
                                         double[] bVec)
Calculate the linear combination dst = a*aVec + b*bVec.

Parameters:
dst - double[n]
a -
aVec - double[n]
b -
bVec - double[n]
Returns:

manhattanNorm

public static double manhattanNorm(double[] vec)
Calculate the "manhattan norm" of the input vector. This is the sum of the absolute values of the entries.

Parameters:
vec -
Returns:

manhattanNormDistance

public static double manhattanNormDistance(double[] u,
                                           double[] v)
Calculate the "manhattan norm" distance between the two input vectors.

Parameters:
u -
v -
Returns:

matrixTimesVector

public static double[] matrixTimesVector(double[] dst,
                                         double[] m,
                                         double[] src)
Multiply the input vector src by the matrix m and put the result into dst. This method works correctly when the vectors are given using homogeneous or dehomogenous coordinates (but this must be consistent for both src and dst).

Parameters:
dst - double[n] (may be null)
m - double[n][n]
src - double[n]
Returns:
dst

matrixTimesVector

public static double[][] matrixTimesVector(double[][] dst,
                                           double[] m,
                                           double[][] src)
A vectorized version of matrixTimesVector(double[], double[], double[]).

Parameters:
dst - double[m][n] (may be null)
m - double[n][n]
src - double[m][n]
Returns:
dst

matrixToJavaString

public static java.lang.String matrixToJavaString(double[] v)
Like matrixToString(double[]), but formatted for direct insertion as java source code

Parameters:
v -
Returns:

matrixToString

public static java.lang.String matrixToString(double[] m)
Print the square matrix m into a string using default format from String.format(java.lang.String, java.lang.Object[]) and return the string.

Parameters:
m -
Returns:

matrixToString

public static java.lang.String matrixToString(double[] m,
                                              java.lang.String formatString)
Print the square matrix m into a string using formatString and return the string.

Parameters:
m -
formatString -
Returns:
See Also:
String.format(java.lang.String, java.lang.Object[])

max

public static double[] max(double[] dst,
                           double[] src1,
                           double[] src2)
Calculate the maximum of two vectors, coordinate-wise.

Parameters:
dst -
src1 -
src2 -
Returns:

maxNorm

public static double maxNorm(double[] vec)
Calculate the "max norm" of a vector. That is the maximum of the absolute values of the entries.

Parameters:
vec -
Returns:

maxNormDistance

public static double maxNormDistance(double[] u,
                                     double[] v)
Calculate the distance between two points based on the "max norm".

Parameters:
u -
v -
Returns:

min

public static double[] min(double[] dst,
                           double[] src1,
                           double[] src2)
Calculate the minimum of two vectors, coordinate-wise.

Parameters:
dst -
src1 -
src2 -
Returns:

negate

public static double[] negate(double[] dst,
                              double[] src)
dst[i] = -src[i]

Parameters:
dst -
src -
Returns:

normalize

public static double[] normalize(double[] dst,
                                 double[] src)
Normalize src using the euclidean norm.

Parameters:
dst -
src -
Returns:

normalize

public static double[][] normalize(double[][] dst,
                                   double[][] src)
Parameters:
ds -

planeParallelToPassingThrough

public static double[] planeParallelToPassingThrough(double[] plane,
                                                     double[] ds,
                                                     double[] ds2)
Parameters:
plane -
ds -
ds2 -

polarDecompose

public static double[] polarDecompose(double[] q,
                                      double[] s,
                                      double[] m)
Parameters:
q -
s -
m -
Returns:
See Also:
"Graphics Gems IV", p. 207 for details

projectOnto

public static double[] projectOnto(double[] dst,
                                   double[] src,
                                   double[] fixed)
Project orthogonally src onto fixed.

Parameters:
dst -
src -
fixed -
Returns:

projectOntoComplement

public static double[] projectOntoComplement(double[] dst,
                                             double[] src,
                                             double[] fixed)
Project src onto the orthogonal complement of fixed.

Parameters:
dst -
src -
fixed -
Returns:

setDiagonalMatrix

public static double[] setDiagonalMatrix(double[] dst,
                                         double[] diag)
Construct and return a diagonal matrix with the entries given by the vector diag. The number of entries of diag cannot be more than the dimension of the square matrix dst.

Parameters:
dst -
diag -
Returns:

setEuclideanNorm

public static double[] setEuclideanNorm(double[] dst,
                                        double length,
                                        double[] src)
Scale the vector to have the given length.

Parameters:
dst -
length -
src -
Returns:

setIdentityMatrix

public static double[] setIdentityMatrix(double[] mat)
Set the matrix to be the identity matrix.

Parameters:
mat -
Returns:

setIdentityMatrix

public static float[] setIdentityMatrix(float[] mat)

setToValue

public static double[] setToValue(double[] dst,
                                  double val)
Set the destination to vector to have constant value val.

Parameters:
dst -
val -
Returns:

setToValue

public static double[] setToValue(double[] dst,
                                  double x,
                                  double y)
Initialize the 2-vector dst.

Parameters:
dst -
x -
y -
Returns:

setToValue

public static double[] setToValue(double[] dst,
                                  double x,
                                  double y,
                                  double z)
Initialize the 3-vector dst.

Parameters:
dst -
x -
y -
z -
Returns:

setToValue

public static double[] setToValue(double[] dst,
                                  double x,
                                  double y,
                                  double z,
                                  double w)
Initialize the 4-vector dst.

Parameters:
dst -
x -
y -
z -
w -
Returns:

mysqrt

public static int mysqrt(int sq)
Returns the square root of the sq parameter. Will return very fast for square roots of 0 to 10.

Parameters:
sq -
Returns:

submatrix

public static double[] submatrix(double[] subm,
                                 double[] m,
                                 int row,
                                 int column)
Extract the submatrix gotten by deleting the given row and column.

Parameters:
subm - double[n-1 * n-1]
m - double[n*n]
row -
column -
Returns:

subtract

public static double[] subtract(double[] dst,
                                double[] src1,
                                double[] src2)
dst[i] = src1[i] - src2[i]

Parameters:
dst -
src1 -
src2 -
Returns:

swap

public static void swap(double[] u,
                        double[] v)
Swap the contents of the two vectors.

Parameters:
u -
v -

times

public static double[] times(double[] dst,
                             double factor,
                             double[] src)
Multiply the vector by the scalar value factor and put result into dst.

Parameters:
dst -
factor -
src -
Returns:

times

public static double[] times(double[] dst,
                             double[] src1,
                             double[] src2)
Multiply the square matrices according to the equation dst = src1 * src2 . This operation is overwrite-safe; that is, it gives correct results when src1=dst or src2=dst.

Parameters:
dst - double[n*n] may be null
src1 - double[n*n]
src2 - double[n*n]
Returns:

times

public static double[][] times(double[][] dst,
                               double factor,
                               double[][] src)
A vectorized version of times(double[], double, double[]);

Parameters:
dst -
factor -
src -
Returns:

toString

public static java.lang.String toString(double[] v)
Print the array v into a string using default format from String.format(java.lang.String, java.lang.Object[]) and return the string.

Parameters:
v -
Returns:

toString

public static java.lang.String toString(double[] v,
                                        java.lang.String formatString)
Print the array v into a string using formatString and return the string.

Parameters:
v -
Returns:
See Also:
String.format(java.lang.String, java.lang.Object[])

toString

public static java.lang.String toString(double[][] v)
A vectorized version of toString(double[]).

Parameters:
v -
Returns:

toString

public static java.lang.String toString(double[][][] v)

toString

public static java.lang.String toString(float[] v)

trace

public static double trace(double[] m)
Calculate the trace of the given square matrix.

Parameters:
m -
Returns:

transpose

public static double[] transpose(double[] dst,
                                 double[] src)
Transpose the given square matrix src into dst. This operation is overwrite-safe; that is, it gives correct results when src=dst.

Parameters:
dst -
src -
Returns:

transposeD2F

public static float[] transposeD2F(float[] dst,
                                   double[] src)
Transpose the given 4x4 matrix src into dst .
converts from double to float. This is useful for hooking up to GL libraries, for example.

Parameters:
dst -
src -
Returns:

transposeF2D

public static double[] transposeF2D(double[] dst,
                                    float[] src)
Transpose the given 4x4 matrix src into dst .
converts from float to double.

Parameters:
dst -
src -
Returns:

bilinearInterpolation

public static double[] bilinearInterpolation(double[] ds,
                                             double u,
                                             double v,
                                             double[] vb,
                                             double[] vt,
                                             double[] cb,
                                             double[] ct)

bezierCombination

public static double[] bezierCombination(double[] dst,
                                         double t,
                                         double[] v0,
                                         double[] t0,
                                         double[] t1,
                                         double[] v1)

isNan

public static boolean isNan(double[] ds)

setToLength

public static double[] setToLength(double[] p1,
                                   double[] p12,
                                   double rad)

completeBasis

public static double[][] completeBasis(double[][] dst,
                                       double[][] partial)
The array partial contains m n-vectors which are assumed to be linearly independent. The destination array dst is calculated so that it extends partial with n-m n-vectors, each of which is orthogonal to all elements of partial as well as to each other. That is, if partial is an orthogonal sub-basis, then dst will also be.

Parameters:
dst - double[n][n]
partial - double[m][n]
Returns:

permutationMatrix

public static double[] permutationMatrix(double[] dst,
                                         int[] perm)
Calculate a permutation matrix which sends e(i) to e(perm[i])

Parameters:
dst -
perm -
Returns:

isZero

public static boolean isZero(double[] iline)

isZero

public static boolean isZero(double[] iline,
                             double tol)

times

public static float[] times(float[] dst,
                            float[] src1,
                            float[] src2)