NASA World Wind

gov.nasa.worldwind.geom
Class Matrix

java.lang.Object
  extended by gov.nasa.worldwind.geom.Matrix

public class Matrix
extends Object


Field Summary
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
           
 
Constructor Summary
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)
           
 
Method Summary
 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(Object obj)
           
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)
           
static Matrix fromCovarianceOfVertices(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(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(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()
           
 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)
           
 String toString()
           
 Vec4 transformBy3(Matrix matrix, double x, double y, double z)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EPSILON

protected static final double EPSILON
See Also:
Constant Field Values

IDENTITY

public static final Matrix IDENTITY

m11

public final double m11

m12

public final double m12

m13

public final double m13

m14

public final double m14

m21

public final double m21

m22

public final double m22

m23

public final double m23

m24

public final double m24

m31

public final double m31

m32

public final double m32

m33

public final double m33

m34

public final double m34

m41

public final double m41

m42

public final double m42

m43

public final double m43

m44

public final double m44
Constructor Detail

Matrix

public Matrix(double value)

Matrix

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)
Method Detail

add

public final Matrix add(Matrix matrix)

computeEigensystemFromSymmetricMatrix3

public static void computeEigensystemFromSymmetricMatrix3(Matrix matrix,
                                                          double[] outEigenvalues,
                                                          Vec4[] outEigenvectors)
Computes the eigensystem of the specified symmetric Matrix's upper 3x3 matrix. If the Matrix's upper 3x3 matrix is not symmetric, this throws an IllegalArgumentException. This writes the eigensystem parameters to the specified arrays 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.

Parameters:
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.
Throws:
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.

divideComponents

public final Matrix divideComponents(double value)

divideComponents

public final Matrix divideComponents(Matrix matrix)

equals

public final boolean equals(Object obj)
Overrides:
equals in class Object

fromArray

public static Matrix fromArray(double[] compArray,
                               int offset,
                               boolean rowMajor)

fromAxes

public static Matrix fromAxes(Vec4[] axes)
Returns a Cartesian transform 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.

Parameters:
axes - an array must of three non-null vectors defining a local orientation in the following order: x-axis, y-axis, z-axis.
Returns:
a Matrix that a transforms local coordinates to world coordinates.
Throws:
IllegalArgumentException - if axes is null, if axes contains less than three elements, or if any of the first three elements in axes is null.

fromAxisAngle

public static Matrix fromAxisAngle(Angle angle,
                                   double axisX,
                                   double axisY,
                                   double axisZ)

fromAxisAngle

public static Matrix fromAxisAngle(Angle angle,
                                   Vec4 axis)

fromCovarianceOfVertices

public static Matrix fromCovarianceOfVertices(BufferWrapper coordinates)

fromCovarianceOfVertices

public static Matrix fromCovarianceOfVertices(Iterable<? extends Vec4> points)
Computes a symmetric covariance Matrix from the x, y, z coordinates of the specified points Iterable. This returns null if the points Iterable is empty, or if all of the points are null.

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.

Parameters:
points - the Iterable of points for which to compute a Covariance matrix.
Returns:
the covariance matrix for the iterable of 3D points.
Throws:
IllegalArgumentException - if the points Iterable is null.

fromGeographicToImage

public static Matrix fromGeographicToImage(AVList worldFileParams)

fromGeographicToImage

public static Matrix fromGeographicToImage(Point2D[] imagePoints,
                                           LatLon[] geoPoints)

fromGeographicToViewport

public 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).

Parameters:
sector - the geographic region which will be mapped to the Cartesian region
x - x-coordinate of lower left hand corner of the Cartesian region
y - y-coordinate of lower left hand corner of the Cartesian region
width - width of the Cartesian region, extending to the right from the x-coordinate
height - height of the Cartesian region, extending up from the y-coordinate
Returns:
Matrix that will map from the geographic region to the Cartesian region.
Throws:
IllegalArgumentException - if sector is null, or if width or height are less than zero.

fromImageToGeographic

public static Matrix fromImageToGeographic(AVList worldFileParams)

fromImageToGeographic

public 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. 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.

Parameters:
sector - the grid sector.
imageWidth - the grid width.
imageHeight - the grid height.
Returns:
Matrix that will map from grid coordinates to geographic coordinates in degrees.
Throws:
IllegalArgumentException - if sector is null, or if either width or height are less than 1.

fromImageToGeographic

public static Matrix fromImageToGeographic(Point2D[] imagePoints,
                                           LatLon[] geoPoints)
Computes a 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.

Parameters:
imagePoints - three control points in the source grid.
geoPoints - three geographic locations corresponding to each grid control point.
Returns:
Matrix that will map from geographic coordinates to grid coordinates in degrees.
Throws:
IllegalArgumentException - if either imagePoints or geoPoints is null or have length less than 3.

fromLocalOrientation

public static Matrix fromLocalOrientation(Vec4 origin,
                                          Vec4[] axes)
Returns a Cartesian transform 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.

Parameters:
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.
Returns:
a Matrix that transforms local coordinates to world coordinates.
Throws:
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.

fromModelLookAt

public 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. The eye point, center point, and up vector are in model coordinates. The returned viewing matrix maps the the positive Z axis to the reference center point, the origin to the eye point, and the positive Y axis to the up vector. 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).

Parameters:
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.
Returns:
a viewing matrix in model coordinates defined by the specified eye point, reference center point, and up vector.
Throws:
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.

fromOrthographic

public static Matrix fromOrthographic(double width,
                                      double height,
                                      double near,
                                      double far)

fromOrthographic2D

public static Matrix fromOrthographic2D(double width,
                                        double height)

fromPerspective

public static Matrix fromPerspective(Angle horizontalFieldOfView,
                                     double viewportWidth,
                                     double viewportHeight,
                                     double near,
                                     double far)

fromPerspective

public static Matrix fromPerspective(double width,
                                     double height,
                                     double near,
                                     double far)

fromQuaternion

public static Matrix fromQuaternion(Quaternion quaternion)

fromRotationX

public static Matrix fromRotationX(Angle angle)

fromRotationXYZ

public static Matrix fromRotationXYZ(Angle xRotation,
                                     Angle yRotation,
                                     Angle zRotation)

fromRotationY

public static Matrix fromRotationY(Angle angle)

fromRotationZ

public static Matrix fromRotationZ(Angle angle)

fromScale

public static Matrix fromScale(double scale)

fromScale

public static Matrix fromScale(double scaleX,
                               double scaleY,
                               double scaleZ)

fromScale

public static Matrix fromScale(Vec4 scale)

fromSkew

public static Matrix fromSkew(Angle theta,
                              Angle phi)

fromTranslation

public static Matrix fromTranslation(double x,
                                     double y,
                                     double z)

fromTranslation

public static Matrix fromTranslation(Vec4 translation)

fromViewLookAt

public 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. The eye point, center point, and up vector are in model coordinates. The returned viewing matrix maps the reference center point to the negative Z axis, and the eye point to the origin, and the up vector to the positive Y axis. When this matrix is used to define an OGL viewing transform along with a typical projection matrix such as 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).

Parameters:
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.
Returns:
a viewing matrix in model coordinates defined by the specified eye point, reference center point, and up vector.
Throws:
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.

fromViewportToGeographic

public 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 .

Parameters:
sector - the geographic region the Cartesian region will be mapped to
x - x-coordinate of lower left hand corner of the Cartesian region
y - y-coordinate of lower left hand corner of the Cartesian region
width - width of the Cartesian region, extending to the right from the x-coordinate
height - height of the Cartesian region, extending up from the y-coordinate
Returns:
Matrix that will map from Cartesian region to the geographic region.
Throws:
IllegalArgumentException - if sector is null, or if width or height are less than zero.

getDeterminant

public final double getDeterminant()

getInverse

public final Matrix getInverse()

getKMLRotationX

public final Angle getKMLRotationX()

getKMLRotationY

public final Angle getKMLRotationY()

getKMLRotationZ

public final Angle getKMLRotationZ()

getM11

public final double getM11()

getM12

public final double getM12()

getM13

public final double getM13()

getM14

public final double getM14()

getM21

public final double getM21()

getM22

public final double getM22()

getM23

public final double getM23()

getM24

public final double getM24()

getM31

public final double getM31()

getM32

public final double getM32()

getM33

public final double getM33()

getM34

public final double getM34()

getM41

public final double getM41()

getM42

public final double getM42()

getM43

public final double getM43()

getM44

public final double getM44()

getRotationX

public final Angle getRotationX()

getRotationY

public final Angle getRotationY()

getRotationZ

public final Angle getRotationZ()

getTrace

public final double getTrace()

getTranslation

public final Vec4 getTranslation()

getTranspose

public final Matrix getTranspose()

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

m11

public final double m11()

m12

public final double m12()

m13

public final double m13()

m14

public final double m14()

m21

public final double m21()

m22

public final double m22()

m23

public final double m23()

m24

public final double m24()

m31

public final double m31()

m32

public final double m32()

m33

public final double m33()

m34

public final double m34()

m41

public final double m41()

m42

public final double m42()

m43

public final double m43()

m44

public final double m44()

multiply

public final Matrix multiply(Matrix matrix)

multiplyComponents

public final Matrix multiplyComponents(double value)

negate

public final Matrix negate()

subtract

public final Matrix subtract(Matrix matrix)

toArray

public final double[] toArray(double[] compArray,
                              int offset,
                              boolean rowMajor)

toString

public final String toString()
Overrides:
toString in class Object

transformBy3

public final Vec4 transformBy3(Matrix matrix,
                               double x,
                               double y,
                               double z)

NASA World Wind