- java.lang.Object
-
- org.spongepowered.math.matrix.MatrixNd
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Matrixd
public class MatrixNd extends Object implements Matrixd, Serializable, Cloneable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static MatrixNd
IDENTITY_2
static MatrixNd
IDENTITY_3
static MatrixNd
IDENTITY_4
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MatrixNd
abs()
MatrixNd
add(MatrixNd m)
MatrixNd
ceil()
MatrixNd
clone()
VectorNd
column(int col)
static MatrixNd
createLookAt(int size, Vector3d eye, Vector3d at, Vector3d up)
Creates a "look at" matrix for the given eye point.static MatrixNd
createOrthographic(int size, double right, double left, double top, double bottom, double near, double far)
Creates an orthographic viewing frustum built from the provided valuesstatic MatrixNd
createOrthographic(int size, float right, float left, float top, float bottom, float near, float far)
Creates an orthographic viewing frustum built from the provided valuesstatic MatrixNd
createPerspective(int size, double fov, double aspect, double near, double far)
Creates a perspective projection matrix with the given (x) FOV, aspect, near and far planesstatic MatrixNd
createPerspective(int size, float fov, float aspect, float near, float far)
Creates a perspective projection matrix with the given (x) FOV, aspect, near and far planesstatic MatrixNd
createRotation(int size, Complexd rot)
static MatrixNd
createRotation(int size, Quaterniond rot)
static MatrixNd
createScaling(double... vec)
static MatrixNd
createScaling(VectorNd v)
static MatrixNd
createTranslation(double... vec)
static MatrixNd
createTranslation(VectorNd v)
double
determinant()
MatrixNd
div(double a)
MatrixNd
div(float a)
MatrixNd
div(MatrixNd m)
boolean
equals(Object other)
MatrixNd
floor()
double
get(int row, int col)
int
hashCode()
MatrixNd
invert()
MatrixNd
mul(double a)
MatrixNd
mul(float a)
MatrixNd
mul(MatrixNd m)
MatrixNd
negate()
MatrixNd
pow(double pow)
MatrixNd
pow(float pow)
MatrixNd
resize(int size)
MatrixNd
rotate(Complexd rot)
MatrixNd
rotate(Quaterniond rot)
MatrixNd
round()
VectorNd
row(int row)
MatrixNd
scale(double... v)
MatrixNd
scale(VectorNd v)
void
set(int row, int col, double val)
void
set(int row, int col, float val)
void
setIdentity()
void
setZero()
int
size()
MatrixNd
sub(MatrixNd m)
double[]
toArray()
double[]
toArray(boolean columnMajor)
MatrixNd
toDouble()
MatrixNf
toFloat()
Matrix2d
toMatrix2()
Matrix3d
toMatrix3()
Matrix4d
toMatrix4()
String
toString()
double
trace()
VectorNd
transform(double... vec)
VectorNd
transform(VectorNd v)
MatrixNd
translate(double... v)
MatrixNd
translate(VectorNd v)
MatrixNd
transpose()
-
-
-
Method Detail
-
size
public int size()
-
set
public void set(int row, int col, float val)
-
set
public void set(int row, int col, double val)
-
setIdentity
public final void setIdentity()
-
setZero
public void setZero()
-
resize
public MatrixNd resize(int size)
-
mul
public MatrixNd mul(float a)
-
div
public MatrixNd div(float a)
-
pow
public MatrixNd pow(float pow)
-
translate
public MatrixNd translate(double... v)
-
scale
public MatrixNd scale(double... v)
-
rotate
public MatrixNd rotate(Quaterniond rot)
-
transform
public VectorNd transform(double... vec)
-
determinant
public double determinant()
- Specified by:
determinant
in interfaceMatrixd
-
toMatrix2
public Matrix2d toMatrix2()
-
toMatrix3
public Matrix3d toMatrix3()
-
toMatrix4
public Matrix4d toMatrix4()
-
toArray
public double[] toArray()
-
createScaling
public static MatrixNd createScaling(double... vec)
-
createTranslation
public static MatrixNd createTranslation(double... vec)
-
createRotation
public static MatrixNd createRotation(int size, Quaterniond rot)
-
createLookAt
public static MatrixNd createLookAt(int size, Vector3d eye, Vector3d at, Vector3d up)
Creates a "look at" matrix for the given eye point.- Parameters:
size
- The size of the matrix, minimum of 4eye
- The position of the cameraat
- The point that the camera is looking atup
- The "up" vector- Returns:
- A rotational transform that corresponds to a camera looking at the given point
-
createPerspective
public static MatrixNd createPerspective(int size, float fov, float aspect, float near, float far)
Creates a perspective projection matrix with the given (x) FOV, aspect, near and far planes- Parameters:
size
- The size of the matrix, minimum of 4fov
- The field of view in the x directionaspect
- The aspect ratio, usually width/heightnear
- The near plane, cannot be 0far
- the far plane, zFar cannot equal zNear- Returns:
- A perspective projection matrix built from the given values
-
createPerspective
public static MatrixNd createPerspective(int size, double fov, double aspect, double near, double far)
Creates a perspective projection matrix with the given (x) FOV, aspect, near and far planes- Parameters:
size
- The size of the matrix, minimum of 4fov
- The field of view in the x directionaspect
- The aspect ratio, usually width/heightnear
- The near plane, cannot be 0far
- the far plane, zFar cannot equal zNear- Returns:
- A perspective projection matrix built from the given values
-
createOrthographic
public static MatrixNd createOrthographic(int size, float right, float left, float top, float bottom, float near, float far)
Creates an orthographic viewing frustum built from the provided values- Parameters:
size
- The size of the matrix, minimum of 4right
- the right most plane of the viewing frustumleft
- the left most plane of the viewing frustumtop
- the top plane of the viewing frustumbottom
- the bottom plane of the viewing frustumnear
- the near plane of the viewing frustumfar
- the far plane of the viewing frustum- Returns:
- A viewing frustum built from the provided values
-
createOrthographic
public static MatrixNd createOrthographic(int size, double right, double left, double top, double bottom, double near, double far)
Creates an orthographic viewing frustum built from the provided values- Parameters:
size
- The size of the matrix, minimum of 4right
- the right most plane of the viewing frustumleft
- the left most plane of the viewing frustumtop
- the top plane of the viewing frustumbottom
- the bottom plane of the viewing frustumnear
- the near plane of the viewing frustumfar
- the far plane of the viewing frustum- Returns:
- A viewing frustum built from the provided values
-
-