public final class MatrixBuilder extends Object
This class wraps a Matrix
instance for easy specification of
concatenated operations.
All the static methods are factory methods that
create an instance for a selected metric.
Note: the factory methods with Transformation as a
parameter copy the underlying double[]
and wrap
the copy into a new Matrix instance - the factory methods that
take a Matrix as a parameter simply work on the given Matrix.
Finally, the factory methods without parameters create a
new identity matrix to act on.
The instance methods which carry out matrix operations are always applyed on the right hand side of the current value of the matrix. All these methods return this instance as value, so that one can do many calls in a row.
Matrix m = MatrixBuilder.euclidean() .translate(2,2,2) .rotate(Math.PI/2, 1, 1, 1) .scale(3,1,2) .getMatrix(); SceneGraphComponent camCom = new SceneGraphComponent(); MatrixBuilder.euclidean().translate(0,2,3) .rotateFromTo(new double[]{0,0,-1}, new double[]{0,-2,-3}) .scale(2) .assignTo(camComp); // Transformation gets set and assignedFor explanation of metric, see
P3
.Modifier and Type | Method and Description |
---|---|
void |
assignTo(double[] array) |
void |
assignTo(Matrix m) |
void |
assignTo(SceneGraphComponent comp) |
void |
assignTo(Transformation trafo) |
MatrixBuilder |
conjugateBy(double[] c) |
static MatrixBuilder |
elliptic()
Create a matrix builder which generates isometries with respect to elliptic (or (4,0)) metric.
|
static MatrixBuilder |
elliptic(Matrix m) |
static MatrixBuilder |
elliptic(SceneGraphComponent cmp) |
static MatrixBuilder |
elliptic(Transformation m) |
static MatrixBuilder |
euclidean()
Create a matrix builder which generates isometries with respect to euclidean metric.
|
static MatrixBuilder |
euclidean(Matrix m) |
static MatrixBuilder |
euclidean(SceneGraphComponent cmp) |
static MatrixBuilder |
euclidean(Transformation m)
Create a matrix builder which generates isometries with respect to euclidean metric.
|
double[] |
getArray() |
Matrix |
getMatrix() |
static MatrixBuilder |
hyperbolic()
Create a matrix builder which generates isometries with respect to hyperbolic (or (3,1)) metric.
|
static MatrixBuilder |
hyperbolic(Matrix m) |
static MatrixBuilder |
hyperbolic(SceneGraphComponent cmp) |
static MatrixBuilder |
hyperbolic(Transformation m) |
static MatrixBuilder |
init(Matrix m,
int metric)
This constructor accepts the metric as an argument.
|
static MatrixBuilder |
projective()
Create a matrix builder which strictly speaking doesn't know about metric: purely projective.
|
static MatrixBuilder |
projective(int metric) |
static MatrixBuilder |
projective(Matrix m) |
static MatrixBuilder |
projective(Transformation m) |
MatrixBuilder |
reflect(double[] plane)
reflects the wrapped Matrix at the plane
|
MatrixBuilder |
reflect(double[] v1,
double[] v2,
double[] v3)
reflects the wrapped Matrix at the plane
determined by the the given 3 points
|
MatrixBuilder |
reset()
assigns ID to the underlying matrix
|
MatrixBuilder |
rotate(double[] p1,
double[] p2,
double angle)
rotate about the axis through the points p1 and p2
|
MatrixBuilder |
rotate(double angle,
double[] axis) |
MatrixBuilder |
rotate(double angle,
double axisX,
double axisY,
double axisZ) |
MatrixBuilder |
rotateFromTo(double[] v1,
double[] v2)
A rotation which takes vector v1 to vector v2.
|
MatrixBuilder |
rotateX(double angle) |
MatrixBuilder |
rotateY(double angle) |
MatrixBuilder |
rotateZ(double angle) |
MatrixBuilder |
scale(double scale) |
MatrixBuilder |
scale(double[] scale) |
MatrixBuilder |
scale(double scaleX,
double scaleY,
double scaleZ) |
MatrixBuilder |
skew(int i,
int j,
double val) |
MatrixBuilder |
times(double[] array)
multiplies array (considered as 4x4 matrix) on the right hand side
|
MatrixBuilder |
times(Matrix matrix)
multiplies the given Matrix on the right hand side
|
MatrixBuilder |
translate(double[] vector) |
MatrixBuilder |
translate(double[] from,
double[] to) |
MatrixBuilder |
translate(double dx,
double dy,
double dz) |
MatrixBuilder |
translateFromTo(double[] p1,
double[] p2) |
public static MatrixBuilder euclidean(Transformation m)
m
- public static MatrixBuilder euclidean(Matrix m)
public static MatrixBuilder projective(int metric)
public static MatrixBuilder euclidean()
m
- public static MatrixBuilder euclidean(SceneGraphComponent cmp)
public static MatrixBuilder hyperbolic(Transformation m)
public static MatrixBuilder hyperbolic(Matrix m)
public static MatrixBuilder hyperbolic()
m
- public static MatrixBuilder hyperbolic(SceneGraphComponent cmp)
public static MatrixBuilder elliptic(Transformation m)
public static MatrixBuilder elliptic(Matrix m)
public static MatrixBuilder elliptic()
m
- public static MatrixBuilder elliptic(SceneGraphComponent cmp)
public static MatrixBuilder projective(Transformation m)
public static MatrixBuilder projective(Matrix m)
public static MatrixBuilder projective()
m
- public static MatrixBuilder init(Matrix m, int metric)
public MatrixBuilder rotate(double angle, double axisX, double axisY, double axisZ)
public MatrixBuilder rotate(double angle, double[] axis)
public MatrixBuilder rotate(double[] p1, double[] p2, double angle)
p1
- first point on axisp2
- second point on axisangle
- the angle to rotateP3.makeRotationMatrix(double[], double[], double[], double, int)
public MatrixBuilder rotateX(double angle)
public MatrixBuilder rotateY(double angle)
public MatrixBuilder rotateZ(double angle)
public MatrixBuilder rotateFromTo(double[] v1, double[] v2)
v1
- v2
- P3.makeRotationMatrix(double[], double[], double[])
public MatrixBuilder scale(double scale)
scale
- P3.makeStretchMatrix(double[], double)
public MatrixBuilder scale(double[] scale)
scale
- P3.makeStretchMatrix(double[], double[])
public MatrixBuilder scale(double scaleX, double scaleY, double scaleZ)
scaleX
- scaleY
- scaleZ
- P3.makeStretchMatrix(double[], double, double, double)
public MatrixBuilder skew(int i, int j, double val)
public MatrixBuilder translate(double[] vector)
public MatrixBuilder translate(double[] from, double[] to)
public MatrixBuilder translate(double dx, double dy, double dz)
dx
- dy
- dz
- P3.makeTranslationMatrix(double[], double[], int)
public MatrixBuilder translateFromTo(double[] p1, double[] p2)
p1
- p2
- P3.makeTranslationMatrix(double[], double[], double[], int)
public MatrixBuilder reflect(double[] v1, double[] v2, double[] v3)
v1
- first point on reflection planev2
- second point on reflection planev3
- third point on reflection planepublic MatrixBuilder reflect(double[] plane)
plane
- P3.makeReflectionMatrix(double[], double[], int)
public MatrixBuilder conjugateBy(double[] c)
public MatrixBuilder times(Matrix matrix)
matrix
- public MatrixBuilder times(double[] array)
array
- public MatrixBuilder reset()
public Matrix getMatrix()
public void assignTo(SceneGraphComponent comp)
public void assignTo(Transformation trafo)
public void assignTo(double[] array)
public void assignTo(Matrix m)
public double[] getArray()