Interface Matrix2dc
-
- All Known Implementing Classes:
Matrix2d
public interface Matrix2dcInterface to a read-only view of a 2x2 matrix of double-precision floats.- Author:
- Joseph Burton
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Matrix2dadd(Matrix2dc other, Matrix2d dest)Component-wise addthisandotherand store the result indest.doubledeterminant()Return the determinant of this matrix.booleanequals(Matrix2dc m, double delta)Compare the matrix elements ofthismatrix with the given matrix using the givendeltaand return whether all of them are equal within a maximum difference ofdelta.double[]get(double[] arr)Store this matrix into the supplied double array in column-major order.double[]get(double[] arr, int offset)Store this matrix into the supplied double array in column-major order at the given offset.doubleget(int column, int row)Get the matrix element value at the given column and row.java.nio.ByteBufferget(int index, java.nio.ByteBuffer buffer)Store this matrix in column-major order into the suppliedByteBufferstarting at the specified absolute buffer position/index.java.nio.DoubleBufferget(int index, java.nio.DoubleBuffer buffer)Store this matrix in column-major order into the suppliedDoubleBufferstarting at the specified absolute buffer position/index.java.nio.ByteBufferget(java.nio.ByteBuffer buffer)Store this matrix in column-major order into the suppliedByteBufferat the current bufferposition.java.nio.DoubleBufferget(java.nio.DoubleBuffer buffer)Store this matrix in column-major order into the suppliedDoubleBufferat the current bufferposition.Matrix2dget(Matrix2d dest)Get the current values ofthismatrix and store them intodest.Matrix3dget(Matrix3d dest)Get the current values ofthismatrix and store them as the rotational component ofdest.Matrix3x2dget(Matrix3x2d dest)Get the current values ofthismatrix and store them as the rotational component ofdest.Vector2dgetColumn(int column, Vector2d dest)Get the column at the givencolumnindex, starting with0.java.nio.ByteBuffergetFloats(int index, java.nio.ByteBuffer buffer)Store the elements of this matrix as float values in column-major order into the suppliedByteBufferstarting at the specified absolute buffer position/index.java.nio.ByteBuffergetFloats(java.nio.ByteBuffer buffer)Store the elements of this matrix as float values in column-major order into the suppliedByteBufferat the current bufferposition.doublegetRotation()Get the angle of the rotation component ofthismatrix.Vector2dgetRow(int row, Vector2d dest)Get the row at the givenrowindex, starting with0.Vector2dgetScale(Vector2d dest)Get the scaling factors ofthismatrix for the three base axes.Matrix2dcgetToAddress(long address)Store this matrix in column-major order at the given off-heap address.java.nio.ByteBuffergetTransposed(int index, java.nio.ByteBuffer buffer)Store this matrix in row-major order into the suppliedByteBufferstarting at the specified absolute buffer position/index.java.nio.DoubleBuffergetTransposed(int index, java.nio.DoubleBuffer buffer)Store this matrix in row-major order into the suppliedDoubleBufferstarting at the specified absolute buffer position/index.java.nio.FloatBuffergetTransposed(int index, java.nio.FloatBuffer buffer)Store this matrix in row-major order into the suppliedFloatBufferstarting at the specified absolute buffer position/index.java.nio.ByteBuffergetTransposed(java.nio.ByteBuffer buffer)Store this matrix in row-major order into the suppliedByteBufferat the current bufferposition.java.nio.DoubleBuffergetTransposed(java.nio.DoubleBuffer buffer)Store this matrix in row-major order into the suppliedDoubleBufferat the current bufferposition.java.nio.FloatBuffergetTransposed(java.nio.FloatBuffer buffer)Store this matrix in row-major order into the suppliedFloatBufferat the current bufferposition.java.nio.ByteBuffergetTransposedFloats(int index, java.nio.ByteBuffer buffer)Store this matrix in row-major order into the suppliedByteBufferstarting at the specified absolute buffer position/index.java.nio.ByteBuffergetTransposedFloats(java.nio.ByteBuffer buffer)Store this matrix as float values in row-major order into the suppliedByteBufferat the current bufferposition.Matrix2dinvert(Matrix2d dest)Invert thethismatrix and store the result indest.booleanisFinite()Determine whether all matrix elements are finite floating-point values, that is, they are notNaNand notinfinity.Matrix2dlerp(Matrix2dc other, double t, Matrix2d dest)Linearly interpolatethisandotherusing the given interpolation factortand store the result indest.doublem00()Return the value of the matrix element at column 0 and row 0.doublem01()Return the value of the matrix element at column 0 and row 1.doublem10()Return the value of the matrix element at column 1 and row 0.doublem11()Return the value of the matrix element at column 1 and row 1.Matrix2dmul(Matrix2dc right, Matrix2d dest)Multiply this matrix by the suppliedrightmatrix and store the result indest.Matrix2dmul(Matrix2fc right, Matrix2d dest)Multiply this matrix by the suppliedrightmatrix and store the result indest.Matrix2dmulComponentWise(Matrix2dc other, Matrix2d dest)Component-wise multiplythisbyotherand store the result indest.Matrix2dmulLocal(Matrix2dc left, Matrix2d dest)Pre-multiply this matrix by the suppliedleftmatrix and store the result indest.Matrix2dnormal(Matrix2d dest)Compute a normal matrix fromthismatrix and store it intodest.Vector2dnormalizedPositiveX(Vector2d dest)Obtain the direction of+Xbefore the transformation represented bythisorthogonal matrix is applied.Vector2dnormalizedPositiveY(Vector2d dest)Obtain the direction of+Ybefore the transformation represented bythisorthogonal matrix is applied.Vector2dpositiveX(Vector2d dest)Obtain the direction of+Xbefore the transformation represented bythismatrix is applied.Vector2dpositiveY(Vector2d dest)Obtain the direction of+Ybefore the transformation represented bythismatrix is applied.Matrix2drotate(double ang, Matrix2d dest)Apply rotation to this matrix by rotating the given amount of radians and store the result indest.Matrix2drotateLocal(double ang, Matrix2d dest)Pre-multiply a rotation to this matrix by rotating the given amount of radians and store the result indest.Matrix2dscale(double x, double y, Matrix2d dest)Apply scaling to this matrix by scaling the base axes by the given x and y factors and store the result indest.Matrix2dscale(double xy, Matrix2d dest)Apply scaling to this matrix by uniformly scaling all base axes by the givenxyfactor and store the result indest.Matrix2dscale(Vector2dc xy, Matrix2d dest)Apply scaling tothismatrix by scaling the base axes by the givenxy.xandxy.yfactors, respectively and store the result indest.Matrix2dscaleLocal(double x, double y, Matrix2d dest)Pre-multiply scaling tothismatrix by scaling the base axes by the given x and y factors and store the result indest.Matrix2dsub(Matrix2dc subtrahend, Matrix2d dest)Component-wise subtractsubtrahendfromthisand store the result indest.Vector2dtransform(double x, double y, Vector2d dest)Transform the vector(x, y)by this matrix and store the result indest.Vector2dtransform(Vector2d v)Transform the given vector by this matrix.Vector2dtransform(Vector2dc v, Vector2d dest)Transform the given vector by this matrix and store the result indest.Vector2dtransformTranspose(double x, double y, Vector2d dest)Transform the vector(x, y)by the transpose of this matrix and store the result indest.Vector2dtransformTranspose(Vector2d v)Transform the given vector by the transpose of this matrix.Vector2dtransformTranspose(Vector2dc v, Vector2d dest)Transform the given vector by the transpose of this matrix and store the result indest.Matrix2dtranspose(Matrix2d dest)Transposethismatrix and store the result indest.
-
-
-
Method Detail
-
m00
double m00()
Return the value of the matrix element at column 0 and row 0.- Returns:
- the value of the matrix element
-
m01
double m01()
Return the value of the matrix element at column 0 and row 1.- Returns:
- the value of the matrix element
-
m10
double m10()
Return the value of the matrix element at column 1 and row 0.- Returns:
- the value of the matrix element
-
m11
double m11()
Return the value of the matrix element at column 1 and row 1.- Returns:
- the value of the matrix element
-
mul
Matrix2d mul(Matrix2dc right, Matrix2d dest)
Multiply this matrix by the suppliedrightmatrix and store the result indest.If
Misthismatrix andRtherightmatrix, then the new matrix will beM * R. So when transforming a vectorvwith the new matrix by usingM * R * v, the transformation of the right matrix will be applied first!- Parameters:
right- the right operand of the matrix multiplicationdest- will hold the result- Returns:
- dest
-
mul
Matrix2d mul(Matrix2fc right, Matrix2d dest)
Multiply this matrix by the suppliedrightmatrix and store the result indest.If
Misthismatrix andRtherightmatrix, then the new matrix will beM * R. So when transforming a vectorvwith the new matrix by usingM * R * v, the transformation of the right matrix will be applied first!- Parameters:
right- the right operand of the matrix multiplicationdest- will hold the result- Returns:
- dest
-
mulLocal
Matrix2d mulLocal(Matrix2dc left, Matrix2d dest)
Pre-multiply this matrix by the suppliedleftmatrix and store the result indest.If
Misthismatrix andLtheleftmatrix, then the new matrix will beL * M. So when transforming a vectorvwith the new matrix by usingL * M * v, the transformation ofthismatrix will be applied first!- Parameters:
left- the left operand of the matrix multiplicationdest- the destination matrix, which will hold the result- Returns:
- dest
-
determinant
double determinant()
Return the determinant of this matrix.- Returns:
- the determinant
-
invert
Matrix2d invert(Matrix2d dest)
Invert thethismatrix and store the result indest.- Parameters:
dest- will hold the result- Returns:
- dest
-
transpose
Matrix2d transpose(Matrix2d dest)
Transposethismatrix and store the result indest.- Parameters:
dest- will hold the result- Returns:
- dest
-
get
Matrix2d get(Matrix2d dest)
Get the current values ofthismatrix and store them intodest.- Parameters:
dest- the destination matrix- Returns:
- the passed in destination
-
get
Matrix3x2d get(Matrix3x2d dest)
Get the current values ofthismatrix and store them as the rotational component ofdest. All other values ofdestwill be set to 0.- Parameters:
dest- the destination matrix- Returns:
- the passed in destination
- See Also:
Matrix3x2d.set(Matrix2dc)
-
get
Matrix3d get(Matrix3d dest)
Get the current values ofthismatrix and store them as the rotational component ofdest. All other values ofdestwill be set to identity.- Parameters:
dest- the destination matrix- Returns:
- the passed in destination
- See Also:
Matrix3d.set(Matrix2dc)
-
getRotation
double getRotation()
Get the angle of the rotation component ofthismatrix.This method assumes that there is a valid rotation to be returned, i.e. that
atan2(-m10, m00) == atan2(m01, m11).- Returns:
- the angle
-
get
java.nio.DoubleBuffer get(java.nio.DoubleBuffer buffer)
Store this matrix in column-major order into the suppliedDoubleBufferat the current bufferposition.This method will not increment the position of the given DoubleBuffer.
In order to specify the offset into the DoubleBuffer at which the matrix is stored, use
get(int, DoubleBuffer), taking the absolute position as parameter.- Parameters:
buffer- will receive the values of this matrix in column-major order at its current position- Returns:
- the passed in buffer
- See Also:
get(int, DoubleBuffer)
-
get
java.nio.DoubleBuffer get(int index, java.nio.DoubleBuffer buffer)Store this matrix in column-major order into the suppliedDoubleBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given DoubleBuffer.
- Parameters:
index- the absolute position into the DoubleBufferbuffer- will receive the values of this matrix in column-major order- Returns:
- the passed in buffer
-
get
java.nio.ByteBuffer get(java.nio.ByteBuffer buffer)
Store this matrix in column-major order into the suppliedByteBufferat the current bufferposition.This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which the matrix is stored, use
get(int, ByteBuffer), taking the absolute position as parameter.- Parameters:
buffer- will receive the values of this matrix in column-major order at its current position- Returns:
- the passed in buffer
- See Also:
get(int, ByteBuffer)
-
get
java.nio.ByteBuffer get(int index, java.nio.ByteBuffer buffer)Store this matrix in column-major order into the suppliedByteBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
- Parameters:
index- the absolute position into the ByteBufferbuffer- will receive the values of this matrix in column-major order- Returns:
- the passed in buffer
-
getFloats
java.nio.ByteBuffer getFloats(java.nio.ByteBuffer buffer)
Store the elements of this matrix as float values in column-major order into the suppliedByteBufferat the current bufferposition.This method will not increment the position of the given ByteBuffer.
Please note that due to this matrix storing double values those values will potentially lose precision when they are converted to float values before being put into the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which the matrix is stored, use
getFloats(int, ByteBuffer), taking the absolute position as parameter.- Parameters:
buffer- will receive the elements of this matrix as float values in column-major order at its current position- Returns:
- the passed in buffer
- See Also:
getFloats(int, ByteBuffer)
-
getFloats
java.nio.ByteBuffer getFloats(int index, java.nio.ByteBuffer buffer)Store the elements of this matrix as float values in column-major order into the suppliedByteBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
Please note that due to this matrix storing double values those values will potentially lose precision when they are converted to float values before being put into the given ByteBuffer.
- Parameters:
index- the absolute position into the ByteBufferbuffer- will receive the elements of this matrix as float values in column-major order- Returns:
- the passed in buffer
-
getTransposed
java.nio.DoubleBuffer getTransposed(java.nio.DoubleBuffer buffer)
Store this matrix in row-major order into the suppliedDoubleBufferat the current bufferposition.This method will not increment the position of the given DoubleBuffer.
In order to specify the offset into the DoubleBuffer at which the matrix is stored, use
getTransposed(int, DoubleBuffer), taking the absolute position as parameter.- Parameters:
buffer- will receive the values of this matrix in row-major order at its current position- Returns:
- the passed in buffer
- See Also:
getTransposed(int, DoubleBuffer)
-
getTransposed
java.nio.DoubleBuffer getTransposed(int index, java.nio.DoubleBuffer buffer)Store this matrix in row-major order into the suppliedDoubleBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given DoubleBuffer.
- Parameters:
index- the absolute position into the DoubleBufferbuffer- will receive the values of this matrix in row-major order- Returns:
- the passed in buffer
-
getTransposed
java.nio.ByteBuffer getTransposed(java.nio.ByteBuffer buffer)
Store this matrix in row-major order into the suppliedByteBufferat the current bufferposition.This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which the matrix is stored, use
getTransposed(int, ByteBuffer), taking the absolute position as parameter.- Parameters:
buffer- will receive the values of this matrix in row-major order at its current position- Returns:
- the passed in buffer
- See Also:
getTransposed(int, ByteBuffer)
-
getTransposed
java.nio.ByteBuffer getTransposed(int index, java.nio.ByteBuffer buffer)Store this matrix in row-major order into the suppliedByteBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
- Parameters:
index- the absolute position into the ByteBufferbuffer- will receive the values of this matrix in row-major order- Returns:
- the passed in buffer
-
getTransposed
java.nio.FloatBuffer getTransposed(java.nio.FloatBuffer buffer)
Store this matrix in row-major order into the suppliedFloatBufferat the current bufferposition.This method will not increment the position of the given FloatBuffer.
Please note that due to this matrix storing double values those values will potentially lose precision when they are converted to float values before being put into the given FloatBuffer.
In order to specify the offset into the FloatBuffer at which the matrix is stored, use
getTransposed(int, FloatBuffer), taking the absolute position as parameter.- Parameters:
buffer- will receive the values of this matrix in row-major order at its current position- Returns:
- the passed in buffer
- See Also:
getTransposed(int, FloatBuffer)
-
getTransposed
java.nio.FloatBuffer getTransposed(int index, java.nio.FloatBuffer buffer)Store this matrix in row-major order into the suppliedFloatBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given FloatBuffer.
Please note that due to this matrix storing double values those values will potentially lose precision when they are converted to float values before being put into the given FloatBuffer.
- Parameters:
index- the absolute position into the FloatBufferbuffer- will receive the values of this matrix in row-major order- Returns:
- the passed in buffer
-
getTransposedFloats
java.nio.ByteBuffer getTransposedFloats(java.nio.ByteBuffer buffer)
Store this matrix as float values in row-major order into the suppliedByteBufferat the current bufferposition.This method will not increment the position of the given ByteBuffer.
Please note that due to this matrix storing double values those values will potentially lose precision when they are converted to float values before being put into the given FloatBuffer.
In order to specify the offset into the ByteBuffer at which the matrix is stored, use
getTransposedFloats(int, ByteBuffer), taking the absolute position as parameter.- Parameters:
buffer- will receive the values of this matrix as float values in row-major order at its current position- Returns:
- the passed in buffer
- See Also:
getTransposedFloats(int, ByteBuffer)
-
getTransposedFloats
java.nio.ByteBuffer getTransposedFloats(int index, java.nio.ByteBuffer buffer)Store this matrix in row-major order into the suppliedByteBufferstarting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
Please note that due to this matrix storing double values those values will potentially lose precision when they are converted to float values before being put into the given FloatBuffer.
- Parameters:
index- the absolute position into the ByteBufferbuffer- will receive the values of this matrix as float values in row-major order- Returns:
- the passed in buffer
-
getToAddress
Matrix2dc getToAddress(long address)
Store this matrix in column-major order at the given off-heap address.This method will throw an
UnsupportedOperationExceptionwhen JOML is used with `-Djoml.nounsafe`.This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.
- Parameters:
address- the off-heap address where to store this matrix- Returns:
- this
-
get
double[] get(double[] arr, int offset)Store this matrix into the supplied double array in column-major order at the given offset.- Parameters:
arr- the array to write the matrix values intooffset- the offset into the array- Returns:
- the passed in array
-
get
double[] get(double[] arr)
Store this matrix into the supplied double array in column-major order.In order to specify an explicit offset into the array, use the method
get(double[], int).- Parameters:
arr- the array to write the matrix values into- Returns:
- the passed in array
- See Also:
get(double[], int)
-
scale
Matrix2d scale(Vector2dc xy, Matrix2d dest)
Apply scaling tothismatrix by scaling the base axes by the givenxy.xandxy.yfactors, respectively and store the result indest.If
Misthismatrix andSthe scaling matrix, then the new matrix will beM * S. So when transforming a vectorvwith the new matrix by usingM * S * v, the scaling will be applied first!- Parameters:
xy- the factors of the x and y component, respectivelydest- will hold the result- Returns:
- dest
-
scale
Matrix2d scale(double x, double y, Matrix2d dest)
Apply scaling to this matrix by scaling the base axes by the given x and y factors and store the result indest.If
Misthismatrix andSthe scaling matrix, then the new matrix will beM * S. So when transforming a vectorvwith the new matrix by usingM * S * v, the scaling will be applied first!- Parameters:
x- the factor of the x componenty- the factor of the y componentdest- will hold the result- Returns:
- dest
-
scale
Matrix2d scale(double xy, Matrix2d dest)
Apply scaling to this matrix by uniformly scaling all base axes by the givenxyfactor and store the result indest.If
Misthismatrix andSthe scaling matrix, then the new matrix will beM * S. So when transforming a vectorvwith the new matrix by usingM * S * v, the scaling will be applied first!- Parameters:
xy- the factor for all componentsdest- will hold the result- Returns:
- dest
- See Also:
scale(double, double, Matrix2d)
-
scaleLocal
Matrix2d scaleLocal(double x, double y, Matrix2d dest)
Pre-multiply scaling tothismatrix by scaling the base axes by the given x and y factors and store the result indest.If
Misthismatrix andSthe scaling matrix, then the new matrix will beS * M. So when transforming a vectorvwith the new matrix by usingS * M * v, the scaling will be applied last!- Parameters:
x- the factor of the x componenty- the factor of the y componentdest- will hold the result- Returns:
- dest
-
transform
Vector2d transform(Vector2d v)
Transform the given vector by this matrix.- Parameters:
v- the vector to transform- Returns:
- v
-
transform
Vector2d transform(Vector2dc v, Vector2d dest)
Transform the given vector by this matrix and store the result indest.- Parameters:
v- the vector to transformdest- will hold the result- Returns:
- dest
-
transform
Vector2d transform(double x, double y, Vector2d dest)
Transform the vector(x, y)by this matrix and store the result indest.- Parameters:
x- the x coordinate of the vector to transformy- the y coordinate of the vector to transformdest- will hold the result- Returns:
- dest
-
transformTranspose
Vector2d transformTranspose(Vector2d v)
Transform the given vector by the transpose of this matrix.- Parameters:
v- the vector to transform- Returns:
- v
-
transformTranspose
Vector2d transformTranspose(Vector2dc v, Vector2d dest)
Transform the given vector by the transpose of this matrix and store the result indest.- Parameters:
v- the vector to transformdest- will hold the result- Returns:
- dest
-
transformTranspose
Vector2d transformTranspose(double x, double y, Vector2d dest)
Transform the vector(x, y)by the transpose of this matrix and store the result indest.- Parameters:
x- the x coordinate of the vector to transformy- the y coordinate of the vector to transformdest- will hold the result- Returns:
- dest
-
rotate
Matrix2d rotate(double ang, Matrix2d dest)
Apply rotation to this matrix by rotating the given amount of radians and store the result indest.The produced rotation will rotate a vector counter-clockwise around the origin.
If
Misthismatrix andRthe rotation matrix, then the new matrix will beM * R. So when transforming a vectorvwith the new matrix by usingM * R * v, the rotation will be applied first!Reference: http://en.wikipedia.org
- Parameters:
ang- the angle in radiansdest- will hold the result- Returns:
- dest
-
rotateLocal
Matrix2d rotateLocal(double ang, Matrix2d dest)
Pre-multiply a rotation to this matrix by rotating the given amount of radians and store the result indest.The produced rotation will rotate a vector counter-clockwise around the origin.
If
Misthismatrix andRthe rotation matrix, then the new matrix will beR * M. So when transforming a vectorvwith the new matrix by usingR * M * v, the rotation will be applied last!Reference: http://en.wikipedia.org
- Parameters:
ang- the angle in radiansdest- will hold the result- Returns:
- dest
-
getRow
Vector2d getRow(int row, Vector2d dest) throws java.lang.IndexOutOfBoundsException
Get the row at the givenrowindex, starting with0.- Parameters:
row- the row index in[0..1]dest- will hold the row components- Returns:
- the passed in destination
- Throws:
java.lang.IndexOutOfBoundsException- ifrowis not in[0..1]
-
getColumn
Vector2d getColumn(int column, Vector2d dest) throws java.lang.IndexOutOfBoundsException
Get the column at the givencolumnindex, starting with0.- Parameters:
column- the column index in[0..1]dest- will hold the column components- Returns:
- the passed in destination
- Throws:
java.lang.IndexOutOfBoundsException- ifcolumnis not in[0..1]
-
get
double get(int column, int row)Get the matrix element value at the given column and row.- Parameters:
column- the colum index in[0..1]row- the row index in[0..1]- Returns:
- the element value
-
normal
Matrix2d normal(Matrix2d dest)
Compute a normal matrix fromthismatrix and store it intodest.- Parameters:
dest- will hold the result- Returns:
- dest
-
getScale
Vector2d getScale(Vector2d dest)
Get the scaling factors ofthismatrix for the three base axes.- Parameters:
dest- will hold the scaling factors forxandy- Returns:
- dest
-
positiveX
Vector2d positiveX(Vector2d dest)
Obtain the direction of+Xbefore the transformation represented bythismatrix is applied.This method is equivalent to the following code:
Matrix2d inv = new Matrix2d(this).invert(); inv.transform(dir.set(1, 0)).normalize();
Ifthisis already an orthogonal matrix, then consider usingnormalizedPositiveX(Vector2d)instead.- Parameters:
dest- will hold the direction of+X- Returns:
- dest
-
normalizedPositiveX
Vector2d normalizedPositiveX(Vector2d dest)
Obtain the direction of+Xbefore the transformation represented bythisorthogonal matrix is applied. This method only produces correct results ifthisis an orthogonal matrix.This method is equivalent to the following code:
Matrix2d inv = new Matrix2d(this).transpose(); inv.transform(dir.set(1, 0));
- Parameters:
dest- will hold the direction of+X- Returns:
- dest
-
positiveY
Vector2d positiveY(Vector2d dest)
Obtain the direction of+Ybefore the transformation represented bythismatrix is applied.This method is equivalent to the following code:
Matrix2d inv = new Matrix2d(this).invert(); inv.transform(dir.set(0, 1)).normalize();
Ifthisis already an orthogonal matrix, then consider usingnormalizedPositiveY(Vector2d)instead.- Parameters:
dest- will hold the direction of+Y- Returns:
- dest
-
normalizedPositiveY
Vector2d normalizedPositiveY(Vector2d dest)
Obtain the direction of+Ybefore the transformation represented bythisorthogonal matrix is applied. This method only produces correct results ifthisis an orthogonal matrix.This method is equivalent to the following code:
Matrix2d inv = new Matrix2d(this).transpose(); inv.transform(dir.set(0, 1));
- Parameters:
dest- will hold the direction of+Y- Returns:
- dest
-
add
Matrix2d add(Matrix2dc other, Matrix2d dest)
Component-wise addthisandotherand store the result indest.- Parameters:
other- the other addenddest- will hold the result- Returns:
- dest
-
sub
Matrix2d sub(Matrix2dc subtrahend, Matrix2d dest)
Component-wise subtractsubtrahendfromthisand store the result indest.- Parameters:
subtrahend- the subtrahenddest- will hold the result- Returns:
- dest
-
mulComponentWise
Matrix2d mulComponentWise(Matrix2dc other, Matrix2d dest)
Component-wise multiplythisbyotherand store the result indest.- Parameters:
other- the other matrixdest- will hold the result- Returns:
- dest
-
lerp
Matrix2d lerp(Matrix2dc other, double t, Matrix2d dest)
Linearly interpolatethisandotherusing the given interpolation factortand store the result indest.If
tis0.0then the result isthis. If the interpolation factor is1.0then the result isother.- Parameters:
other- the other matrixt- the interpolation factor between 0.0 and 1.0dest- will hold the result- Returns:
- dest
-
equals
boolean equals(Matrix2dc m, double delta)
Compare the matrix elements ofthismatrix with the given matrix using the givendeltaand return whether all of them are equal within a maximum difference ofdelta.Please note that this method is not used by any data structure such as
ArrayListHashSetorHashMapand their operations, such asArrayList.contains(Object)orHashSet.remove(Object), since those data structures only use theObject.equals(Object)andObject.hashCode()methods.- Parameters:
m- the other matrixdelta- the allowed maximum difference- Returns:
truewhether all of the matrix elements are equal;falseotherwise
-
isFinite
boolean isFinite()
Determine whether all matrix elements are finite floating-point values, that is, they are notNaNand notinfinity.- Returns:
trueif all components are finite floating-point values;falseotherwise
-
-