public class LinAlgHelpers extends Object
Constructor and Description |
---|
LinAlgHelpers() |
Modifier and Type | Method and Description |
---|---|
static void |
add(double[][] A,
double[][] B,
double[][] C)
set C = A + B.
|
static void |
add(double[] a,
double[] b,
double[] c)
set c = a + b.
|
static double |
angleFromR(double[][] R)
compute the angle of rotation from a rotation matrix.
|
static void |
axisFromR(double[][] R,
double[] a)
compute the axis of rotation from a rotation matrix.
|
static int |
cols(double[][] A) |
static void |
copy(double[][] A,
double[][] C)
set C = A, where A is a matrix.
|
static void |
cross(double[] a,
double[] b,
double[] c)
compute cross product, set c = a ^ b.
|
static double |
det3x3(double[] a)
Calculates the determinant of a 3x3 matrix given as a double[] (row major).
|
static double |
det3x3(double m00,
double m01,
double m02,
double m10,
double m11,
double m12,
double m20,
double m21,
double m22)
Calculate the determinant of a 3x3 matrix.
|
static double |
distance(double[] a,
double[] b)
get the length of (a - b).
|
static double |
dot(double[] a,
double[] b)
compute dot product a * b.
|
static void |
getCol(int c,
double[][] A,
double[] b)
extract column c of A into vector b.
|
static void |
getRow(int r,
double[][] A,
double[] b)
extract row r of A into vector b.
|
static void |
invert3x3(double[] m)
Invert a 3x3 matrix given as row major double[] in place.
|
static double[] |
invert3x3(double m00,
double m01,
double m02,
double m10,
double m11,
double m12,
double m20,
double m21,
double m22)
Invert a 3x3 matrix given as elements in row major order.
|
static void |
invertSymmetric2x2(double[][] m,
double[][] inverse)
Inverts a (invertible) symmetric 2x2 matrix.
|
static void |
invertSymmetric3x3(double[][] m,
double[][] inverse)
Inverts a (invertible) symmetric 3x3 matrix.
|
static double |
length(double[] a)
get the length of a.
|
static void |
lerp(double[] a,
double[] b,
double t,
double[] c)
set c = ( 1 - t ) * a + t * b, where a, b are vectors and t is scalar.
|
static void |
mult(double[][] A,
double[][] B,
double[][] C)
set C = A * B.
|
static void |
mult(double[][] A,
double[] b,
double[] c)
set c = A * b.
|
static void |
multABT(double[][] A,
double[][] B,
double[][] C)
set C = A * B^T.
|
static void |
multATB(double[][] A,
double[][] B,
double[][] C)
set C = A^T * B.
|
static void |
multT(double[][] A,
double[] b,
double[] c)
set c = A^T * b.
|
static void |
normalize(double[] a)
normalize a, i.e., scale to unit length.
|
static void |
outer(double[] a,
double[] b,
double[][] C)
compute outer product, set C = a * b^T.
|
static void |
quaternionApply(double[] q,
double[] p,
double[] qp)
Apply quaternion rotation q to 3D point p, set qp = q * p.
|
static void |
quaternionFromAngleAxis(double[] axis,
double angle,
double[] q)
compute a quaternion from rotation axis and angle.
|
static void |
quaternionFromR(double[][] R,
double[] q)
compute a unit quaternion from a rotation matrix.
|
static void |
quaternionInvert(double[] p,
double[] q)
invert quaternion, set q = p^{-1}.
|
static void |
quaternionMultiply(double[] p,
double[] q,
double[] pq)
compute the quaternion product pq = p * q.
|
static void |
quaternionPower(double[] q,
double a,
double[] qa)
compute the power of a quaternion q raised to the exponent a.
|
static void |
quaternionToR(double[] q,
double[][] R)
compute a rotation matrix from a unit quaternion.
|
static int |
rows(double[] a) |
static int |
rows(double[][] A) |
static void |
scale(double[][] A,
double b,
double[][] C)
set C = A * b, where A is a matrix and b is scalar.
|
static void |
scale(double[] a,
double b,
double[] c)
set c = a * b, where a is a vector and b is scalar.
|
static void |
setCol(int c,
double[] a,
double[][] B)
set column c of B to vector a.
|
static void |
setRow(int r,
double[] a,
double[][] B)
set row r of B to vector a.
|
static double |
squareDistance(double[] a,
double[] b)
get the squared length of (a - b).
|
static double |
squareLength(double[] a)
get the squared length of a.
|
static void |
subtract(double[] a,
double[] b,
double[] c)
set c = a - b.
|
static String |
toString(double[] a) |
static String |
toString(double[][] A) |
static String |
toString(double[][] A,
String format) |
static String |
toString(double[] a,
String format) |
public static int rows(double[] a)
public static int rows(double[][] A)
public static int cols(double[][] A)
public static double squareLength(double[] a)
a
- public static double length(double[] a)
a
- public static double squareDistance(double[] a, double[] b)
a
- b
- public static double distance(double[] a, double[] b)
a
- b
- public static void lerp(double[] a, double[] b, double t, double[] c)
public static void scale(double[] a, double b, double[] c)
a
- b
- c
- public static void scale(double[][] A, double b, double[][] C)
A
- b
- C
- public static void copy(double[][] A, double[][] C)
A
- C
- public static void subtract(double[] a, double[] b, double[] c)
a
- b
- c
- public static void add(double[] a, double[] b, double[] c)
a
- b
- c
- public static void mult(double[][] A, double[] b, double[] c)
A
- b
- c
- public static void multT(double[][] A, double[] b, double[] c)
A
- b
- c
- public static void mult(double[][] A, double[][] B, double[][] C)
A
- B
- C
- public static void multABT(double[][] A, double[][] B, double[][] C)
A
- B
- C
- public static void multATB(double[][] A, double[][] B, double[][] C)
A
- B
- C
- public static void add(double[][] A, double[][] B, double[][] C)
A
- B
- C
- public static void getCol(int c, double[][] A, double[] b)
c
- A
- b
- public static void setCol(int c, double[] a, double[][] B)
c
- a
- B
- public static void getRow(int r, double[][] A, double[] b)
r
- A
- b
- public static void setRow(int r, double[] a, double[][] B)
r
- a
- B
- public static void normalize(double[] a)
a
- public static double dot(double[] a, double[] b)
a
- b
- public static void cross(double[] a, double[] b, double[] c)
a
- b
- public static void outer(double[] a, double[] b, double[][] C)
a
- b
- C
- public static double angleFromR(double[][] R)
R
- rotation matrixpublic static void axisFromR(double[][] R, double[] a)
R
- rotation matrixa
- rotation axis is stored herepublic static void quaternionFromR(double[][] R, double[] q)
R
- rotation matrix.q
- unit quaternion (w, x, y, z) is stored here.public static void quaternionToR(double[] q, double[][] R)
q
- unit quaternion (w, x, y, z).R
- rotation matrix is stored here.public static void quaternionFromAngleAxis(double[] axis, double angle, double[] q)
axis
- rotation axis as a unit vector.angle
- rotation angle [rad].q
- unit quaternion (w, x, y, z) is stored here.public static void quaternionMultiply(double[] p, double[] q, double[] pq)
p
- unit quaternion (w, x, y, z).q
- unit quaternion (w, x, y, z).pq
- quaternion product p * q is stored here.public static void quaternionPower(double[] q, double a, double[] qa)
q
- unit quaternion (w, x, y, z).a
- exponent.qa
- q^a is stored here.public static void quaternionInvert(double[] p, double[] q)
p
- unit quaternion (w, x, y, z).q
- inverse of p is stored here.public static void quaternionApply(double[] q, double[] p, double[] qp)
q
- unit quaternion (w, x, y, z).p
- 3D point.qp
- rotated 3D point is stored here.public static final double det3x3(double[] a)
a
- public static final double det3x3(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
m00
- m01
- m02
- m10
- m11
- m12
- m20
- m21
- m22
- public static final void invert3x3(double[] m) throws IllegalArgumentException
m
- matrixIllegalArgumentException
- if matrix is not invertiblepublic static final double[] invert3x3(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22) throws IllegalArgumentException
IllegalArgumentException
- if matrix is not invertiblepublic static void invertSymmetric3x3(double[][] m, double[][] inverse)
m
- symmetric matrix to invert.inverse
- inverse of m
is stored here.public static void invertSymmetric2x2(double[][] m, double[][] inverse)
m
- symmetric matrix to invert.inverse
- inverse of m
is stored here.public static String toString(double[][] A)
public static String toString(double[] a)
Copyright © 2015–2022 ImgLib2. All rights reserved.