public class Matrix
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static double |
EPSILON |
static Matrix |
IDENTITY |
double |
m11 |
double |
m12 |
double |
m13 |
double |
m14 |
double |
m21 |
double |
m22 |
double |
m23 |
double |
m24 |
double |
m31 |
double |
m32 |
double |
m33 |
double |
m34 |
double |
m41 |
double |
m42 |
double |
m43 |
double |
m44 |
protected static double |
NEAR_ZERO_THRESHOLD |
Constructor and Description |
---|
Matrix(double value) |
Matrix(double m11,
double m12,
double m13,
double m14,
double m21,
double m22,
double m23,
double m24,
double m31,
double m32,
double m33,
double m34,
double m41,
double m42,
double m43,
double m44) |
Modifier and Type | Method and Description |
---|---|
Matrix |
add(Matrix matrix) |
static void |
computeEigensystemFromSymmetricMatrix3(Matrix matrix,
double[] outEigenvalues,
Vec4[] outEigenvectors)
Computes the eigensystem of the specified symmetric Matrix's upper 3x3 matrix.
|
Matrix |
divideComponents(double value) |
Matrix |
divideComponents(Matrix matrix) |
boolean |
equals(java.lang.Object obj) |
Vec4 |
extractEyePoint()
Extracts this viewing matrix's eye point.
|
Vec4 |
extractForwardVector()
Extracts this viewing matrix's forward vector.
|
AVList |
extractViewingParameters(Vec4 origin,
Angle roll,
Globe globe)
Extracts this viewing matrix's parameters given a viewing origin and a globe.
|
static Matrix |
fromArray(double[] compArray,
int offset,
boolean rowMajor) |
static Matrix |
fromAxes(Vec4[] axes)
Returns a Cartesian transform
Matrix that maps a local orientation to model coordinates. |
static Matrix |
fromAxisAngle(Angle angle,
double axisX,
double axisY,
double axisZ) |
static Matrix |
fromAxisAngle(Angle angle,
Vec4 axis) |
static Matrix |
fromCovarianceOfVertices(BufferWrapper coordinates,
int stride)
Computes a symmetric covariance Matrix from the x, y, z coordinates of the specified buffer of points.
|
static Matrix |
fromCovarianceOfVertices(java.lang.Iterable<? extends Vec4> points)
Computes a symmetric covariance Matrix from the x, y, z coordinates of the specified points Iterable.
|
static Matrix |
fromGeographicToImage(AVList worldFileParams) |
static Matrix |
fromGeographicToImage(java.awt.geom.Point2D[] imagePoints,
LatLon[] geoPoints) |
static Matrix |
fromGeographicToViewport(Sector sector,
int x,
int y,
int width,
int height)
Computes a Matrix that will map the geographic region defined by sector onto a Cartesian region of the specified
width and height and centered at the point (x, y) . |
static Matrix |
fromImageToGeographic(AVList worldFileParams) |
static Matrix |
fromImageToGeographic(int imageWidth,
int imageHeight,
Sector sector)
Computes a
Matrix that will map a aligned 2D grid coordinates to geographic coordinates in degrees. |
static Matrix |
fromImageToGeographic(java.awt.geom.Point2D[] imagePoints,
LatLon[] geoPoints)
Computes a
Matrix that will map constrained 2D grid coordinates to geographic coordinates in
degrees. |
static Matrix |
fromLocalOrientation(Vec4 origin,
Vec4[] axes)
Returns a Cartesian transform
Matrix that maps a local origin and orientation to model coordinates. |
static Matrix |
fromModelLookAt(Vec4 eye,
Vec4 center,
Vec4 up)
Returns a local origin transform matrix in model coordinates defined by the specified eye point, reference point
indicating the center of the local scene, and up vector.
|
static Matrix |
fromOrthographic(double width,
double height,
double near,
double far) |
static Matrix |
fromOrthographic2D(double width,
double height) |
static Matrix |
fromPerspective(Angle horizontalFieldOfView,
double viewportWidth,
double viewportHeight,
double near,
double far) |
static Matrix |
fromPerspective(double width,
double height,
double near,
double far) |
static Matrix |
fromQuaternion(Quaternion quaternion) |
static Matrix |
fromRotationX(Angle angle) |
static Matrix |
fromRotationXYZ(Angle xRotation,
Angle yRotation,
Angle zRotation) |
static Matrix |
fromRotationY(Angle angle) |
static Matrix |
fromRotationZ(Angle angle) |
static Matrix |
fromScale(double scale) |
static Matrix |
fromScale(double scaleX,
double scaleY,
double scaleZ) |
static Matrix |
fromScale(Vec4 scale) |
static Matrix |
fromSkew(Angle theta,
Angle phi) |
static Matrix |
fromTranslation(double x,
double y,
double z) |
static Matrix |
fromTranslation(Vec4 translation) |
static Matrix |
fromViewLookAt(Vec4 eye,
Vec4 center,
Vec4 up)
Returns a viewing matrix in model coordinates defined by the specified View eye point, reference point indicating
the center of the scene, and up vector.
|
static Matrix |
fromViewportToGeographic(Sector sector,
int x,
int y,
int width,
int height)
Computes a Matrix that will map a Cartesian region of the specified
width and height
and centered at the point (x, y) to the geographic region defined by sector onto . |
double |
getDeterminant() |
Matrix |
getInverse()
Returns the inverse of this matrix, or
null if this matrix is singular and has no inverse. |
Angle |
getKMLRotationX() |
Angle |
getKMLRotationY() |
Angle |
getKMLRotationZ() |
double |
getM11() |
double |
getM12() |
double |
getM13() |
double |
getM14() |
double |
getM21() |
double |
getM22() |
double |
getM23() |
double |
getM24() |
double |
getM31() |
double |
getM32() |
double |
getM33() |
double |
getM34() |
double |
getM41() |
double |
getM42() |
double |
getM43() |
double |
getM44() |
Angle |
getRotationX() |
Angle |
getRotationY() |
Angle |
getRotationZ() |
double |
getTrace() |
Vec4 |
getTranslation() |
Matrix |
getTranspose() |
int |
hashCode() |
double |
m11() |
double |
m12() |
double |
m13() |
double |
m14() |
double |
m21() |
double |
m22() |
double |
m23() |
double |
m24() |
double |
m31() |
double |
m32() |
double |
m33() |
double |
m34() |
double |
m41() |
double |
m42() |
double |
m43() |
double |
m44() |
Matrix |
multiply(Matrix matrix) |
Matrix |
multiplyComponents(double value) |
Matrix |
negate() |
Matrix |
subtract(Matrix matrix) |
double[] |
toArray(double[] compArray,
int offset,
boolean rowMajor) |
java.lang.String |
toString() |
Vec4 |
transformBy3(Matrix matrix,
double x,
double y,
double z) |
protected static final double EPSILON
public static final Matrix IDENTITY
public final double m11
public final double m12
public final double m13
public final double m14
public final double m21
public final double m22
public final double m23
public final double m24
public final double m31
public final double m32
public final double m33
public final double m34
public final double m41
public final double m42
public final double m43
public final double m44
protected static final double NEAR_ZERO_THRESHOLD
public Matrix(double value)
public Matrix(double m11, double m12, double m13, double m14, double m21, double m22, double m23, double m24, double m31, double m32, double m33, double m34, double m41, double m42, double m43, double m44)
public static void computeEigensystemFromSymmetricMatrix3(Matrix matrix, double[] outEigenvalues, Vec4[] outEigenvectors)
outEigenValues
and outEigenVectors
, placing the eigenvalues in the
entries of array outEigenValues
, and the corresponding eigenvectors in the entires of array
outEigenVectors
. These arrays must be non-null, and have length three or greater.matrix
- the symmetric Matrix for which to compute an eigensystem.outEigenvalues
- the array which receives the three output eigenvalues.outEigenvectors
- the array which receives the three output eigenvectors.java.lang.IllegalArgumentException
- if the Matrix is null or is not symmetric, if the output eigenvalue array is
null or has length less than 3, or if the output eigenvector is null or has
length less than 3.public final Matrix divideComponents(double value)
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public Vec4 extractEyePoint()
This method assumes that this matrix represents a viewing matrix. If this does not represent a viewing matrix the results are undefined.
In model coordinates, a viewing matrix's eye point is the point the viewer is looking from and maps to the center of the screen.
public Vec4 extractForwardVector()
This method assumes that this matrix represents a viewing matrix. If this does not represent a viewing matrix the results are undefined.
In model coordinates, a viewing matrix's forward vector is the direction the viewer is looking and maps to a vector going into the screen.
public AVList extractViewingParameters(Vec4 origin, Angle roll, Globe globe)
This method assumes that this matrix represents a viewing matrix. If this does not represent a viewing matrix the results are undefined.
This returns a parameterization of this viewing matrix based on the specified origin and globe. The origin indicates the model coordinate point that the view's orientation is relative to, while the globe provides the necessary model coordinate context for the origin and the orientation. The origin should be either the view's eye point or a point on the view's forward vector. The view's roll must be specified in order to disambiguate heading and roll when the view's tilt is zero. The following list outlines the returned key-value pairs and their meanings:
origin
- the origin of the viewing parameters, in model coordinates.roll
- the view's roll.globe
- the globe the viewer is looking at.java.lang.IllegalArgumentException
- if any argument is null.public static Matrix fromArray(double[] compArray, int offset, boolean rowMajor)
public static Matrix fromAxes(Vec4[] axes)
Matrix
that maps a local orientation to model coordinates. The
orientation is specified by an array of three axes
. The axes
array must contain three
non-null vectors, which are interpreted in the following order: x-axis, y-axis, z-axis. This ensures that the
axes in the returned Matrix
have unit length and are orthogonal to each other.axes
- an array must of three non-null vectors defining a local orientation in the following order: x-axis,
y-axis, z-axis.Matrix
that a transforms local coordinates to world coordinates.java.lang.IllegalArgumentException
- if axes
is null
, if axes
contains less
than three elements, or if any of the first three elements in axes
is null
.public static Matrix fromAxisAngle(Angle angle, double axisX, double axisY, double axisZ)
public static Matrix fromCovarianceOfVertices(BufferWrapper coordinates, int stride)
The returned covariance matrix represents the correlation between each pair of x-, y-, and z-coordinates as they're distributed about the points arithmetic mean. Its layout is as follows:
C(x, x) C(x, y) C(x, z)
C(x, y) C(y, y) C(y, z)
C(x, z) C(y, z) C(z, z)
C(i, j) is the covariance of coordinates i and j, where i or j are a coordinate's dispersion about its mean
value. If any entry is zero, then there's no correlation between the two coordinates defining that entry. If the
returned matrix is diagonal, then all three coordinates are uncorrelated, and the specified points are
distributed evenly about their mean point.
The buffer must contain XYZ coordinate tuples which are either tightly packed or offset by the specified stride. The stride specifies the number of buffer elements between the first coordinate of consecutive tuples. For example, a stride of 3 specifies that each tuple is tightly packed as XYZXYZXYZ, whereas a stride of 5 specifies that there are two elements between each tuple as XYZabXYZab (the elements "a" and "b" are ignored). The stride must be at least 3. If the buffer's length is not evenly divisible into stride-sized tuples, this ignores the remaining elements that follow the last complete tuple.
coordinates
- the buffer containing the point coordinates for which to compute a Covariance matrix.stride
- the number of elements between the first coordinate of consecutive points. If stride is 3,
this interprets the buffer has having tightly packed XYZ coordinate tuples.java.lang.IllegalArgumentException
- if the buffer is null, or if the stride is less than three.public static Matrix fromCovarianceOfVertices(java.lang.Iterable<? extends Vec4> points)
The returned covariance matrix represents the correlation between each pair of x-, y-, and z-coordinates as they're distributed about the point Iterable's arithmetic mean. Its layout is as follows:
C(x, x) C(x, y) C(x, z)
C(x, y) C(y, y) C(y, z)
C(x, z) C(y, z) C(z, z)
C(i, j) is the covariance of coordinates i and j, where i or j are a coordinate's dispersion about its mean
value. If any entry is zero, then there's no correlation between the two coordinates defining that entry. If the
returned matrix is diagonal, then all three coordinates are uncorrelated, and the specified point Iterable is
distributed evenly about its mean point.points
- the Iterable of points for which to compute a Covariance matrix.java.lang.IllegalArgumentException
- if the points Iterable is null.public static Matrix fromGeographicToImage(java.awt.geom.Point2D[] imagePoints, LatLon[] geoPoints)
public static Matrix fromGeographicToViewport(Sector sector, int x, int y, int width, int height)
width
and height
and centered at the point (x, y)
.sector
- the geographic region which will be mapped to the Cartesian regionx
- x-coordinate of lower left hand corner of the Cartesian regiony
- y-coordinate of lower left hand corner of the Cartesian regionwidth
- width of the Cartesian region, extending to the right from the x-coordinateheight
- height of the Cartesian region, extending up from the y-coordinatejava.lang.IllegalArgumentException
- if sector
is null, or if width
or height
are less than zero.public static Matrix fromImageToGeographic(int imageWidth, int imageHeight, Sector sector)
Matrix
that will map a aligned 2D grid coordinates to geographic coordinates in degrees.
It is assumed that the destination grid is parallel with lines of latitude and longitude, and has its origin in
the upper left hand corner.sector
- the grid sector.imageWidth
- the grid width.imageHeight
- the grid height.Matrix
that will map from grid coordinates to geographic coordinates in degrees.java.lang.IllegalArgumentException
- if sector
is null, or if either width
or
height
are less than 1.public static Matrix fromImageToGeographic(java.awt.geom.Point2D[] imagePoints, LatLon[] geoPoints)
Matrix
that will map constrained 2D grid coordinates to geographic coordinates in
degrees. The grid is defined by three control points. Each control point maps a location in the source grid to a
geographic location.imagePoints
- three control points in the source grid.geoPoints
- three geographic locations corresponding to each grid control point.Matrix
that will map from geographic coordinates to grid coordinates in degrees.java.lang.IllegalArgumentException
- if either imagePoints
or geoPoints
is null or have
length less than 3.public static Matrix fromLocalOrientation(Vec4 origin, Vec4[] axes)
Matrix
that maps a local origin and orientation to model coordinates.
The transform is specified by a local origin
and an array of three axes
. The
axes
array must contain three non-null vectors, which are interpreted in the following order:
x-axis, y-axis, z-axis. This ensures that the axes in the returned Matrix
have unit length and are
orthogonal to each other.origin
- the origin of the local coordinate system.axes
- an array must of three non-null vectors defining a local orientation in the following order:
x-axis, y-axis, z-axis.Matrix
that transforms local coordinates to world coordinates.java.lang.IllegalArgumentException
- if origin
is null
, if axes
is
null
, if axes
contains less than three elements, or if
any of the first three elements in axes
is null
.public static Matrix fromModelLookAt(Vec4 eye, Vec4 center, Vec4 up)
eye
- the eye point, in model coordinates.center
- the scene's reference center point, in model coordinates.up
- the direction of the up vector, in model coordinates.java.lang.IllegalArgumentException
- if any of the eye point, reference center point, or up vector are null, if the
eye point and reference center point are coincident, or if the up vector and the
line of sight are parallel.public static Matrix fromOrthographic(double width, double height, double near, double far)
public static Matrix fromOrthographic2D(double width, double height)
public static Matrix fromPerspective(Angle horizontalFieldOfView, double viewportWidth, double viewportHeight, double near, double far)
public static Matrix fromPerspective(double width, double height, double near, double far)
public static Matrix fromQuaternion(Quaternion quaternion)
public static Matrix fromRotationXYZ(Angle xRotation, Angle yRotation, Angle zRotation)
public static Matrix fromScale(double scale)
public static Matrix fromScale(double scaleX, double scaleY, double scaleZ)
public static Matrix fromTranslation(double x, double y, double z)
public static Matrix fromViewLookAt(Vec4 eye, Vec4 center, Vec4 up)
fromPerspective(Angle, double, double, double, double)
, this maps
the center of the scene to the center of the viewport, and maps the up vector to the viewoport's positive Y axis
(the up vector points up in the viewport). The eye point and reference center point must not be coincident, and
the up vector must not be parallel to the line of sight (the vector from the eye point to the reference center
point).eye
- the eye point, in model coordinates.center
- the scene's reference center point, in model coordinates.up
- the direction of the up vector, in model coordinates.java.lang.IllegalArgumentException
- if any of the eye point, reference center point, or up vector are null, if the
eye point and reference center point are coincident, or if the up vector and the
line of sight are parallel.public static Matrix fromViewportToGeographic(Sector sector, int x, int y, int width, int height)
width
and height
and centered at the point (x, y)
to the geographic region defined by sector onto .sector
- the geographic region the Cartesian region will be mapped tox
- x-coordinate of lower left hand corner of the Cartesian regiony
- y-coordinate of lower left hand corner of the Cartesian regionwidth
- width of the Cartesian region, extending to the right from the x-coordinateheight
- height of the Cartesian region, extending up from the y-coordinatejava.lang.IllegalArgumentException
- if sector
is null, or if width
or height
are less than zero.public final double getDeterminant()
public final Matrix getInverse()
null
if this matrix is singular and has no inverse.null
if this matrix has no inverse.public final Angle getKMLRotationX()
public final Angle getKMLRotationY()
public final Angle getKMLRotationZ()
public final double getM11()
public final double getM12()
public final double getM13()
public final double getM14()
public final double getM21()
public final double getM22()
public final double getM23()
public final double getM24()
public final double getM31()
public final double getM32()
public final double getM33()
public final double getM34()
public final double getM41()
public final double getM42()
public final double getM43()
public final double getM44()
public final Angle getRotationX()
public final Angle getRotationY()
public final Angle getRotationZ()
public final double getTrace()
public final Vec4 getTranslation()
public final Matrix getTranspose()
public final int hashCode()
hashCode
in class java.lang.Object
public final double m11()
public final double m12()
public final double m13()
public final double m14()
public final double m21()
public final double m22()
public final double m23()
public final double m24()
public final double m31()
public final double m32()
public final double m33()
public final double m34()
public final double m41()
public final double m42()
public final double m43()
public final double m44()
public final Matrix multiplyComponents(double value)
public final Matrix negate()
public final double[] toArray(double[] compArray, int offset, boolean rowMajor)
public final java.lang.String toString()
toString
in class java.lang.Object