public class Matrix2d extends Object implements Externalizable, Matrix2dc
m00 m10
m01 m11
| Modifier and Type | Field and Description |
|---|---|
double |
m00 |
double |
m01 |
double |
m10 |
double |
m11 |
| Constructor and Description |
|---|
Matrix2d()
|
Matrix2d(DoubleBuffer buffer)
Create a new
Matrix2d by reading its 4 double components from the given DoubleBuffer
at the buffer's current position. |
Matrix2d(double m00,
double m01,
double m10,
double m11)
Create a new 2x2 matrix using the supplied double values.
|
Matrix2d(Matrix2dc mat)
Create a new
Matrix2d and make it a copy of the given matrix. |
Matrix2d(Matrix2fc mat)
Create a new
Matrix2d and initialize it with the values from the given matrix. |
Matrix2d(Matrix3dc mat)
|
Matrix2d(Matrix3fc mat)
|
Matrix2d(Vector2dc col0,
Vector2dc col1)
Create a new
Matrix2d and initialize its two columns using the supplied vectors. |
| Modifier and Type | Method and Description |
|---|---|
Matrix2d |
_m00(double m00)
Set the value of the matrix element at column 0 and row 0.
|
Matrix2d |
_m01(double m01)
Set the value of the matrix element at column 0 and row 1.
|
Matrix2d |
_m10(double m10)
Set the value of the matrix element at column 1 and row 0.
|
Matrix2d |
_m11(double m11)
Set the value of the matrix element at column 1 and row 1.
|
Matrix2d |
add(Matrix2dc other)
Component-wise add
this and other. |
Matrix2d |
add(Matrix2dc other,
Matrix2d dest)
Component-wise add
this and other and store the result in dest. |
double |
determinant()
Return the determinant of this matrix.
|
boolean |
equals(Matrix2dc m,
double delta)
Compare the matrix elements of
this matrix with the given matrix using the given delta
and return whether all of them are equal within a maximum difference of delta. |
boolean |
equals(Object obj) |
ByteBuffer |
get(ByteBuffer buffer)
Store this matrix in column-major order into the supplied
ByteBuffer at the current
buffer position. |
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.
|
DoubleBuffer |
get(DoubleBuffer buffer)
Store this matrix in column-major order into the supplied
DoubleBuffer at the current
buffer position. |
ByteBuffer |
get(int index,
ByteBuffer buffer)
Store this matrix in column-major order into the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
DoubleBuffer |
get(int index,
DoubleBuffer buffer)
Store this matrix in column-major order into the supplied
DoubleBuffer starting at the specified
absolute buffer position/index. |
double |
get(int column,
int row)
Get the matrix element value at the given column and row.
|
Matrix2d |
get(Matrix2d dest)
Get the current values of
this matrix and store them into
dest. |
Matrix3d |
get(Matrix3d dest)
Get the current values of
this matrix and store them as
the rotational component of dest. |
Matrix3x2d |
get(Matrix3x2d dest)
Get the current values of
this matrix and store them as
the rotational component of dest. |
Vector2d |
getColumn(int column,
Vector2d dest)
Get the column at the given
column index, starting with 0. |
double |
getRotation()
Get the angle of the rotation component of
this matrix. |
Vector2d |
getRow(int row,
Vector2d dest)
Get the row at the given
row index, starting with 0. |
Vector2d |
getScale(Vector2d dest)
Get the scaling factors of
this matrix for the three base axes. |
ByteBuffer |
getTransposed(ByteBuffer buffer)
Store the transpose of this matrix in column-major order into the supplied
ByteBuffer at the current
buffer position. |
DoubleBuffer |
getTransposed(DoubleBuffer buffer)
Store the transpose of this matrix in column-major order into the supplied
DoubleBuffer at the current
buffer position. |
ByteBuffer |
getTransposed(int index,
ByteBuffer buffer)
Store the transpose of this matrix in column-major order into the supplied
ByteBuffer starting at the specified
absolute buffer position/index. |
DoubleBuffer |
getTransposed(int index,
DoubleBuffer buffer)
Store the transpose of this matrix in column-major order into the supplied
DoubleBuffer starting at the specified
absolute buffer position/index. |
int |
hashCode() |
Matrix2d |
identity()
Set this matrix to the identity.
|
Matrix2d |
invert()
Invert this matrix.
|
Matrix2d |
invert(Matrix2d dest)
Invert the
this matrix and store the result in dest. |
Matrix2d |
lerp(Matrix2dc other,
double t)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in this. |
Matrix2d |
lerp(Matrix2dc other,
double t,
Matrix2d dest)
Linearly interpolate
this and other using the given interpolation factor t
and store the result in dest. |
double |
m00()
Return the value of the matrix element at column 0 and row 0.
|
Matrix2d |
m00(double m00)
Set the value of the matrix element at column 0 and row 0.
|
double |
m01()
Return the value of the matrix element at column 0 and row 1.
|
Matrix2d |
m01(double m01)
Set the value of the matrix element at column 0 and row 1.
|
double |
m10()
Return the value of the matrix element at column 1 and row 0.
|
Matrix2d |
m10(double m10)
Set the value of the matrix element at column 1 and row 0.
|
double |
m11()
Return the value of the matrix element at column 1 and row 1.
|
Matrix2d |
m11(double m11)
Set the value of the matrix element at column 1 and row 1.
|
Matrix2d |
mul(Matrix2dc right)
Multiply this matrix by the supplied
right matrix. |
Matrix2d |
mul(Matrix2dc right,
Matrix2d dest)
Multiply this matrix by the supplied
right matrix and store the result in dest. |
Matrix2d |
mul(Matrix2fc right)
Multiply this matrix by the supplied
right matrix. |
Matrix2d |
mul(Matrix2fc right,
Matrix2d dest)
Multiply this matrix by the supplied
right matrix and store the result in dest. |
Matrix2d |
mulComponentWise(Matrix2dc other)
Component-wise multiply
this by other. |
Matrix2d |
mulComponentWise(Matrix2dc other,
Matrix2d dest)
Component-wise multiply
this by other and store the result in dest. |
Matrix2d |
mulLocal(Matrix2dc left)
Pre-multiply this matrix by the supplied
left matrix and store the result in this. |
Matrix2d |
mulLocal(Matrix2dc left,
Matrix2d dest)
Pre-multiply this matrix by the supplied
left matrix and store the result in dest. |
Matrix2d |
normal()
Set
this matrix to its own normal matrix. |
Matrix2d |
normal(Matrix2d dest)
Compute a normal matrix from
this matrix and store it into dest. |
Vector2d |
normalizedPositiveX(Vector2d dir)
Obtain the direction of
+X before the transformation represented by this orthogonal matrix is applied. |
Vector2d |
normalizedPositiveY(Vector2d dir)
Obtain the direction of
+Y before the transformation represented by this orthogonal matrix is applied. |
Vector2d |
positiveX(Vector2d dir)
Obtain the direction of
+X before the transformation represented by this matrix is applied. |
Vector2d |
positiveY(Vector2d dir)
Obtain the direction of
+Y before the transformation represented by this matrix is applied. |
void |
readExternal(ObjectInput in) |
Matrix2d |
rotate(double angle)
Apply rotation about the origin to this matrix by rotating the given amount of radians.
|
Matrix2d |
rotate(double angle,
Matrix2d dest)
Apply rotation to this matrix by rotating the given amount of radians
and store the result in
dest. |
Matrix2d |
rotateLocal(double angle)
Pre-multiply a rotation to this matrix by rotating the given amount of radians about the origin.
|
Matrix2d |
rotateLocal(double angle,
Matrix2d dest)
Pre-multiply a rotation to this matrix by rotating the given amount of radians
and store the result in
dest. |
Matrix2d |
rotation(double angle)
Set this matrix to a rotation matrix which rotates the given radians about the origin.
|
Matrix2d |
scale(double xy)
Apply scaling to this matrix by uniformly scaling all base axes by the given
xy factor. |
Matrix2d |
scale(double x,
double y)
Apply scaling to this matrix by scaling the base axes by the given x and
y factors.
|
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 in
dest. |
Matrix2d |
scale(double xy,
Matrix2d dest)
Apply scaling to this matrix by uniformly scaling all base axes by the given
xy factor
and store the result in dest. |
Matrix2d |
scale(Vector2dc xy)
Apply scaling to this matrix by scaling the base axes by the given
xy.x and
xy.y factors, respectively. |
Matrix2d |
scale(Vector2dc xy,
Matrix2d dest)
Apply scaling to
this matrix by scaling the base axes by the given xy.x and
xy.y factors, respectively and store the result in dest. |
Matrix2d |
scaleLocal(double x,
double y)
Pre-multiply scaling to this matrix by scaling the base axes by the given x and
y factors.
|
Matrix2d |
scaleLocal(double x,
double y,
Matrix2d dest)
Pre-multiply scaling to
this matrix by scaling the base axes by the given x and
y factors and store the result in dest. |
Matrix2d |
scaling(double factor)
Set this matrix to be a simple scale matrix, which scales all axes uniformly by the given factor.
|
Matrix2d |
scaling(double x,
double y)
Set this matrix to be a simple scale matrix.
|
Matrix2d |
scaling(Vector2dc xy)
Set this matrix to be a simple scale matrix which scales the base axes by
xy.x and xy.y respectively. |
Matrix2d |
set(ByteBuffer buffer)
Set the values of this matrix by reading 4 double values from the given
ByteBuffer in column-major order,
starting at its current position. |
Matrix2d |
set(double[] m)
Set the values in this matrix based on the supplied double array.
|
Matrix2d |
set(DoubleBuffer buffer)
Set the values of this matrix by reading 4 double values from the given
DoubleBuffer in column-major order,
starting at its current position. |
Matrix2d |
set(double m00,
double m01,
double m10,
double m11)
Set the values within this matrix to the supplied double values.
|
Matrix2d |
set(int column,
int row,
double value)
Set the matrix element at the given column and row to the specified value.
|
Matrix2d |
set(Matrix2dc m)
Set the elements of this matrix to the ones in
m. |
Matrix2d |
set(Matrix2fc m)
Set the elements of this matrix to the ones in
m. |
Matrix2d |
set(Matrix3dc m)
Set the elements of this matrix to the upper left 2x2 of the given
Matrix3dc. |
Matrix2d |
set(Matrix3fc m)
Set the elements of this matrix to the upper left 2x2 of the given
Matrix3dc. |
Matrix2d |
set(Matrix3x2dc m)
Set the elements of this matrix to the left 2x2 submatrix of
m. |
Matrix2d |
set(Matrix3x2fc m)
Set the elements of this matrix to the left 2x2 submatrix of
m. |
Matrix2d |
set(Vector2dc col0,
Vector2dc col1)
Set the two columns of this matrix to the supplied vectors, respectively.
|
Matrix2d |
setColumn(int column,
double x,
double y)
Set the column at the given
column index, starting with 0. |
Matrix2d |
setColumn(int column,
Vector2dc src)
Set the column at the given
column index, starting with 0. |
Matrix2d |
setRow(int row,
double x,
double y)
Set the row at the given
row index, starting with 0. |
Matrix2d |
setRow(int row,
Vector2dc src)
Set the row at the given
row index, starting with 0. |
Matrix2d |
sub(Matrix2dc subtrahend)
Component-wise subtract
subtrahend from this. |
Matrix2d |
sub(Matrix2dc other,
Matrix2d dest)
Component-wise subtract
subtrahend from this and store the result in dest. |
Matrix2d |
swap(Matrix2d other)
Exchange the values of
this matrix with the given other matrix. |
String |
toString()
Return a string representation of this matrix.
|
String |
toString(NumberFormat formatter)
Return a string representation of this matrix by formatting the matrix elements with the given
NumberFormat. |
Vector2d |
transform(double x,
double y,
Vector2d dest)
Transform the vector
(x, y) by this matrix and store the result in dest. |
Vector2d |
transform(Vector2d v)
Transform the given vector by this matrix.
|
Vector2d |
transform(Vector2dc v,
Vector2d dest)
Transform the given vector by this matrix and store the result in
dest. |
Vector2d |
transformTranspose(double x,
double y,
Vector2d dest)
Transform the vector
(x, y) by the transpose of this matrix and store the result in dest. |
Vector2d |
transformTranspose(Vector2d v)
Transform the given vector by the transpose of this matrix.
|
Vector2d |
transformTranspose(Vector2dc v,
Vector2d dest)
Transform the given vector by the transpose of this matrix and store the result in
dest. |
Matrix2d |
transpose()
Transpose this matrix.
|
Matrix2d |
transpose(Matrix2d dest)
Transpose
this matrix and store the result in dest. |
void |
writeExternal(ObjectOutput out) |
Matrix2d |
zero()
Set all values within this matrix to zero.
|
public double m00
public double m01
public double m10
public double m11
public Matrix2d()
public Matrix2d(Matrix2dc mat)
Matrix2d and make it a copy of the given matrix.mat - the Matrix2dc to copy the values frompublic Matrix2d(Matrix2fc mat)
Matrix2d and initialize it with the values from the given matrix.mat - the matrix to initialize this matrix withpublic Matrix2d(double m00,
double m01,
double m10,
double m11)
m00 - the value of m00m01 - the value of m01m10 - the value of m10m11 - the value of m11public Matrix2d(DoubleBuffer buffer)
Matrix2d by reading its 4 double components from the given DoubleBuffer
at the buffer's current position.
That DoubleBuffer is expected to hold the values in column-major order.
The buffer's position will not be changed by this method.
buffer - the DoubleBuffer to read the matrix values frompublic double m00()
Matrix2dcpublic double m01()
Matrix2dcpublic double m10()
Matrix2dcpublic double m11()
Matrix2dcpublic Matrix2d m00(double m00)
m00 - the new valuepublic Matrix2d m01(double m01)
m01 - the new valuepublic Matrix2d m10(double m10)
m10 - the new valuepublic Matrix2d m11(double m11)
m11 - the new valuepublic Matrix2d _m00(double m00)
m00 - the new valuepublic Matrix2d _m01(double m01)
m01 - the new valuepublic Matrix2d _m10(double m10)
m10 - the new valuepublic Matrix2d _m11(double m11)
m11 - the new valuepublic Matrix2d set(Matrix2dc m)
m.m - the matrix to copy the elements frompublic Matrix2d set(Matrix2fc m)
m.m - the matrix to copy the elements frompublic Matrix2d set(Matrix3x2dc m)
m.m - the matrix to copy the elements frompublic Matrix2d set(Matrix3x2fc m)
m.m - the matrix to copy the elements frompublic Matrix2d set(Matrix3dc m)
Matrix3dc.m - the Matrix3dc to copy the values frompublic Matrix2d set(Matrix3fc m)
Matrix3dc.m - the Matrix3fc to copy the values frompublic Matrix2d mul(Matrix2dc right)
right matrix.
If M is this matrix and R the right matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the
transformation of the right matrix will be applied first!
right - the right operand of the matrix multiplicationpublic Matrix2d mul(Matrix2dc right, Matrix2d dest)
Matrix2dcright matrix and store the result in dest.
If M is this matrix and R the right matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the
transformation of the right matrix will be applied first!
public Matrix2d mul(Matrix2fc right)
right matrix.
If M is this matrix and R the right matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the
transformation of the right matrix will be applied first!
right - the right operand of the matrix multiplicationpublic Matrix2d mul(Matrix2fc right, Matrix2d dest)
Matrix2dcright matrix and store the result in dest.
If M is this matrix and R the right matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v, the
transformation of the right matrix will be applied first!
public Matrix2d mulLocal(Matrix2dc left)
left matrix and store the result in this.
If M is this matrix and L the left matrix,
then the new matrix will be L * M. So when transforming a
vector v with the new matrix by using L * M * v, the
transformation of this matrix will be applied first!
left - the left operand of the matrix multiplicationpublic Matrix2d mulLocal(Matrix2dc left, Matrix2d dest)
Matrix2dcleft matrix and store the result in dest.
If M is this matrix and L the left matrix,
then the new matrix will be L * M. So when transforming a
vector v with the new matrix by using L * M * v, the
transformation of this matrix will be applied first!
public Matrix2d set(double m00, double m01, double m10, double m11)
m00, m10
m01, m11
m00 - the new value of m00m01 - the new value of m01m10 - the new value of m10m11 - the new value of m11public Matrix2d set(double[] m)
0, 2
1, 3
This method only uses the first 4 values, all others are ignored.
m - the array to read the matrix values frompublic Matrix2d set(Vector2dc col0, Vector2dc col1)
col0 - the first columncol1 - the second columnpublic double determinant()
Matrix2dcdeterminant in interface Matrix2dcpublic Matrix2d invert()
public Matrix2d invert(Matrix2d dest)
Matrix2dcthis matrix and store the result in dest.public Matrix2d transpose()
public Matrix2d transpose(Matrix2d dest)
Matrix2dcthis matrix and store the result in dest.public String toString()
This method creates a new DecimalFormat on every invocation with the format string "0.000E0;-".
public String toString(NumberFormat formatter)
NumberFormat.formatter - the NumberFormat used to format the matrix values withpublic Matrix2d get(Matrix2d dest)
this matrix and store them into
dest.
This is the reverse method of set(Matrix2dc) and allows to obtain
intermediate calculation results when chaining multiple transformations.
get in interface Matrix2dcdest - the destination matrixset(Matrix2dc)public Matrix3x2d get(Matrix3x2d dest)
Matrix2dcthis matrix and store them as
the rotational component of dest. All other values of dest will
be set to 0.get in interface Matrix2dcdest - the destination matrixMatrix3x2d.set(Matrix2dc)public Matrix3d get(Matrix3d dest)
Matrix2dcthis matrix and store them as
the rotational component of dest. All other values of dest will
be set to identity.get in interface Matrix2dcdest - the destination matrixMatrix3d.set(Matrix2dc)public double getRotation()
Matrix2dcthis matrix.
This method assumes that there is a valid rotation to be returned, i.e. that
atan2(-m10, m00) == atan2(m01, m11).
getRotation in interface Matrix2dcpublic DoubleBuffer get(DoubleBuffer buffer)
Matrix2dcDoubleBuffer at the current
buffer position.
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 Matrix2dc.get(int, DoubleBuffer), taking
the absolute position as parameter.
get in interface Matrix2dcbuffer - will receive the values of this matrix in column-major order at its current positionMatrix2dc.get(int, DoubleBuffer)public DoubleBuffer get(int index, DoubleBuffer buffer)
Matrix2dcDoubleBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given DoubleBuffer.
public ByteBuffer get(ByteBuffer buffer)
Matrix2dcByteBuffer at the current
buffer position.
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 Matrix2dc.get(int, ByteBuffer), taking
the absolute position as parameter.
get in interface Matrix2dcbuffer - will receive the values of this matrix in column-major order at its current positionMatrix2dc.get(int, ByteBuffer)public ByteBuffer get(int index, ByteBuffer buffer)
Matrix2dcByteBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
public DoubleBuffer getTransposed(DoubleBuffer buffer)
Matrix2dcDoubleBuffer at the current
buffer position.
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 Matrix2dc.getTransposed(int, DoubleBuffer), taking
the absolute position as parameter.
getTransposed in interface Matrix2dcbuffer - will receive the values of this matrix in column-major order at its current positionMatrix2dc.getTransposed(int, DoubleBuffer)public DoubleBuffer getTransposed(int index, DoubleBuffer buffer)
Matrix2dcDoubleBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given DoubleBuffer.
getTransposed in interface Matrix2dcindex - the absolute position into the DoubleBufferbuffer - will receive the values of this matrix in column-major orderpublic ByteBuffer getTransposed(ByteBuffer buffer)
Matrix2dcByteBuffer at the current
buffer position.
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 Matrix2dc.getTransposed(int, ByteBuffer), taking
the absolute position as parameter.
getTransposed in interface Matrix2dcbuffer - will receive the values of this matrix in column-major order at its current positionMatrix2dc.getTransposed(int, ByteBuffer)public ByteBuffer getTransposed(int index, ByteBuffer buffer)
Matrix2dcByteBuffer starting at the specified
absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
getTransposed in interface Matrix2dcindex - the absolute position into the ByteBufferbuffer - will receive the values of this matrix in column-major orderpublic double[] get(double[] arr,
int offset)
Matrix2dcpublic double[] get(double[] arr)
Matrix2dc
In order to specify an explicit offset into the array, use the method Matrix2dc.get(double[], int).
get in interface Matrix2dcarr - the array to write the matrix values intoMatrix2dc.get(double[], int)public Matrix2d set(DoubleBuffer buffer)
DoubleBuffer in column-major order,
starting at its current position.
The DoubleBuffer is expected to contain the values in column-major order.
The position of the DoubleBuffer will not be changed by this method.
buffer - the DoubleBuffer to read the matrix values from in column-major orderpublic Matrix2d set(ByteBuffer buffer)
ByteBuffer in column-major order,
starting at its current position.
The ByteBuffer is expected to contain the values in column-major order.
The position of the ByteBuffer will not be changed by this method.
buffer - the ByteBuffer to read the matrix values from in column-major orderpublic Matrix2d zero()
public Matrix2d identity()
public Matrix2d scale(Vector2dc xy, Matrix2d dest)
Matrix2dcthis matrix by scaling the base axes by the given xy.x and
xy.y factors, respectively and store the result in dest.
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v
, the scaling will be applied first!
public Matrix2d scale(Vector2dc xy)
xy.x and
xy.y factors, respectively.
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v, the
scaling will be applied first!
xy - the factors of the x and y component, respectivelypublic Matrix2d scale(double x, double y, Matrix2d dest)
Matrix2dcdest.
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v
, the scaling will be applied first!
public Matrix2d scale(double x, double y)
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v
, the scaling will be applied first!
x - the factor of the x componenty - the factor of the y componentpublic Matrix2d scale(double xy, Matrix2d dest)
Matrix2dcxy factor
and store the result in dest.
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v
, the scaling will be applied first!
scale in interface Matrix2dcxy - the factor for all componentsdest - will hold the resultMatrix2dc.scale(double, double, Matrix2d)public Matrix2d scale(double xy)
xy factor.
If M is this matrix and S the scaling matrix,
then the new matrix will be M * S. So when transforming a
vector v with the new matrix by using M * S * v
, the scaling will be applied first!
xy - the factor for all componentsscale(double, double)public Matrix2d scaleLocal(double x, double y, Matrix2d dest)
Matrix2dcthis matrix by scaling the base axes by the given x and
y factors and store the result in dest.
If M is this matrix and S the scaling matrix,
then the new matrix will be S * M. So when transforming a
vector v with the new matrix by using S * M * v
, the scaling will be applied last!
scaleLocal in interface Matrix2dcx - the factor of the x componenty - the factor of the y componentdest - will hold the resultpublic Matrix2d scaleLocal(double x, double y)
If M is this matrix and S the scaling matrix,
then the new matrix will be S * M. So when transforming a
vector v with the new matrix by using S * M * v, the
scaling will be applied last!
x - the factor of the x componenty - the factor of the y componentpublic Matrix2d scaling(double factor)
The resulting matrix can be multiplied against another transformation matrix to obtain an additional scaling.
In order to post-multiply a scaling transformation directly to a
matrix, use scale() instead.
factor - the scale factor in x and yscale(double)public Matrix2d scaling(double x, double y)
x - the scale in xy - the scale in ypublic Matrix2d scaling(Vector2dc xy)
xy.x and xy.y respectively.
The resulting matrix can be multiplied against another transformation matrix to obtain an additional scaling.
In order to post-multiply a scaling transformation directly to a
matrix use scale() instead.
xy - the scale in x and y respectivelyscale(Vector2dc)public Matrix2d rotation(double angle)
The produced rotation will rotate a vector counter-clockwise around the origin.
The resulting matrix can be multiplied against another transformation matrix to obtain an additional rotation.
In order to post-multiply a rotation transformation directly to a
matrix, use rotate() instead.
angle - the angle in radiansrotate(double)public Vector2d transform(Vector2d v)
Matrix2dcpublic Vector2d transform(Vector2dc v, Vector2d dest)
Matrix2dcdest.public Vector2d transform(double x, double y, Vector2d dest)
Matrix2dc(x, y) by this matrix and store the result in dest.public Vector2d transformTranspose(Vector2d v)
Matrix2dctransformTranspose in interface Matrix2dcv - the vector to transformpublic Vector2d transformTranspose(Vector2dc v, Vector2d dest)
Matrix2dcdest.transformTranspose in interface Matrix2dcv - the vector to transformdest - will hold the resultpublic Vector2d transformTranspose(double x, double y, Vector2d dest)
Matrix2dc(x, y) by the transpose of this matrix and store the result in dest.transformTranspose in interface Matrix2dcx - the x coordinate of the vector to transformy - the y coordinate of the vector to transformdest - will hold the resultpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException
readExternal in interface ExternalizableIOExceptionpublic Matrix2d rotate(double angle)
The produced rotation will rotate a vector counter-clockwise around the origin.
If M is this matrix and R the rotation matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v
, the rotation will be applied first!
Reference: http://en.wikipedia.org
angle - the angle in radianspublic Matrix2d rotate(double angle, Matrix2d dest)
Matrix2dcdest.
The produced rotation will rotate a vector counter-clockwise around the origin.
If M is this matrix and R the rotation matrix,
then the new matrix will be M * R. So when transforming a
vector v with the new matrix by using M * R * v
, the rotation will be applied first!
Reference: http://en.wikipedia.org
public Matrix2d rotateLocal(double angle)
The produced rotation will rotate a vector counter-clockwise around the origin.
If M is this matrix and R the rotation matrix,
then the new matrix will be R * M. So when transforming a
vector v with the new matrix by using R * M * v, the
rotation will be applied last!
In order to set the matrix to a rotation matrix without pre-multiplying the rotation
transformation, use rotation().
Reference: http://en.wikipedia.org
angle - the angle in radians to rotate about the X axisrotation(double)public Matrix2d rotateLocal(double angle, Matrix2d dest)
Matrix2dcdest.
The produced rotation will rotate a vector counter-clockwise around the origin.
If M is this matrix and R the rotation matrix,
then the new matrix will be R * M. So when transforming a
vector v with the new matrix by using R * M * v, the
rotation will be applied last!
Reference: http://en.wikipedia.org
rotateLocal in interface Matrix2dcangle - the angle in radiansdest - will hold the resultpublic Vector2d getRow(int row, Vector2d dest) throws IndexOutOfBoundsException
Matrix2dcrow index, starting with 0.getRow in interface Matrix2dcrow - the row index in [0..1]dest - will hold the row componentsIndexOutOfBoundsException - if row is not in [0..1]public Matrix2d setRow(int row, Vector2dc src) throws IndexOutOfBoundsException
row index, starting with 0.row - the row index in [0..1]src - the row components to setIndexOutOfBoundsException - if row is not in [0..1]public Matrix2d setRow(int row, double x, double y) throws IndexOutOfBoundsException
row index, starting with 0.row - the row index in [0..1]x - the first element in the rowy - the second element in the rowIndexOutOfBoundsException - if row is not in [0..1]public Vector2d getColumn(int column, Vector2d dest) throws IndexOutOfBoundsException
Matrix2dccolumn index, starting with 0.getColumn in interface Matrix2dccolumn - the column index in [0..1]dest - will hold the column componentsIndexOutOfBoundsException - if column is not in [0..1]public Matrix2d setColumn(int column, Vector2dc src) throws IndexOutOfBoundsException
column index, starting with 0.column - the column index in [0..1]src - the column components to setIndexOutOfBoundsException - if column is not in [0..1]public Matrix2d setColumn(int column, double x, double y) throws IndexOutOfBoundsException
column index, starting with 0.column - the column index in [0..1]x - the first element in the columny - the second element in the columnIndexOutOfBoundsException - if column is not in [0..1]public double get(int column,
int row)
Matrix2dcpublic Matrix2d set(int column, int row, double value)
column - the colum index in [0..1]row - the row index in [0..1]value - the valuepublic Matrix2d normal()
this matrix to its own normal matrix.
Please note that, if this is an orthogonal matrix or a matrix whose columns are orthogonal vectors,
then this method need not be invoked, since in that case this itself is its normal matrix.
In this case, use set(Matrix2dc) to set a given Matrix2d to this matrix.
set(Matrix2dc)public Matrix2d normal(Matrix2d dest)
this matrix and store it into dest.
Please note that, if this is an orthogonal matrix or a matrix whose columns are orthogonal vectors,
then this method need not be invoked, since in that case this itself is its normal matrix.
In this case, use set(Matrix2dc) to set a given Matrix2d to this matrix.
normal in interface Matrix2dcdest - will hold the resultset(Matrix2dc)public Vector2d getScale(Vector2d dest)
Matrix2dcthis matrix for the three base axes.public Vector2d positiveX(Vector2d dir)
Matrix2dc+X before the transformation represented by this matrix is applied.
This method is equivalent to the following code:
Matrix2d inv = new Matrix2d(this).invert(); inv.transform(dir.set(1, 0)).normalize();If
this is already an orthogonal matrix, then consider using Matrix2dc.normalizedPositiveX(Vector2d) instead.public Vector2d normalizedPositiveX(Vector2d dir)
Matrix2dc+X before the transformation represented by this orthogonal matrix is applied.
This method only produces correct results if this is an orthogonal matrix.
This method is equivalent to the following code:
Matrix2d inv = new Matrix2d(this).transpose(); inv.transform(dir.set(1, 0));
normalizedPositiveX in interface Matrix2dcdir - will hold the direction of +Xpublic Vector2d positiveY(Vector2d dir)
Matrix2dc+Y before the transformation represented by this matrix is applied.
This method is equivalent to the following code:
Matrix2d inv = new Matrix2d(this).invert(); inv.transform(dir.set(0, 1)).normalize();If
this is already an orthogonal matrix, then consider using Matrix2dc.normalizedPositiveY(Vector2d) instead.public Vector2d normalizedPositiveY(Vector2d dir)
Matrix2dc+Y before the transformation represented by this orthogonal matrix is applied.
This method only produces correct results if this is an orthogonal matrix.
This method is equivalent to the following code:
Matrix2d inv = new Matrix2d(this).transpose(); inv.transform(dir.set(0, 1));
normalizedPositiveY in interface Matrix2dcdir - will hold the direction of +Ypublic boolean equals(Matrix2dc m, double delta)
Matrix2dcthis matrix with the given matrix using the given delta
and return whether all of them are equal within a maximum difference of delta.
Please note that this method is not used by any data structure such as ArrayList HashSet or HashMap
and their operations, such as ArrayList.contains(Object) or HashSet.remove(Object), since those
data structures only use the Object.equals(Object) and Object.hashCode() methods.
public Matrix2d swap(Matrix2d other)
this matrix with the given other matrix.other - the other matrix to exchange the values withpublic Matrix2d add(Matrix2dc other)
this and other.other - the other addendpublic Matrix2d add(Matrix2dc other, Matrix2d dest)
Matrix2dcthis and other and store the result in dest.public Matrix2d sub(Matrix2dc subtrahend)
subtrahend from this.subtrahend - the subtrahendpublic Matrix2d sub(Matrix2dc other, Matrix2d dest)
Matrix2dcsubtrahend from this and store the result in dest.public Matrix2d mulComponentWise(Matrix2dc other)
this by other.other - the other matrixpublic Matrix2d mulComponentWise(Matrix2dc other, Matrix2d dest)
Matrix2dcthis by other and store the result in dest.mulComponentWise in interface Matrix2dcother - the other matrixdest - will hold the resultpublic Matrix2d lerp(Matrix2dc other, double t)
this and other using the given interpolation factor t
and store the result in this.
If t is 0.0 then the result is this. If the interpolation factor is 1.0
then the result is other.
other - the other matrixt - the interpolation factor between 0.0 and 1.0public Matrix2d lerp(Matrix2dc other, double t, Matrix2d dest)
Matrix2dcthis and other using the given interpolation factor t
and store the result in dest.
If t is 0.0 then the result is this. If the interpolation factor is 1.0
then the result is other.
Copyright © 2015–2019 JOML. All rights reserved.