Matrix2d

Contains the definition of a 2x2 matrix of doubles, and associated functions to transform it. The matrix is column-major to match OpenGL's interpretation, and it looks like this: <p> m00 m10<br> m01 m11<br>

@author Joseph Burton

public
struct Matrix2d {}

Constructors

this
this(Matrix2d mat)

Create a new {@link Matrix2d} and make it a copy of the given matrix.

this
this(Matrix3d mat)

Create a new {@link Matrix2d} and make it a copy of the upper left 2x2 of the given {@link Matrix3d}.

this
this(double m00, double m01, double m10, double m11)

Create a new 2x2 matrix using the supplied double values. The order of the parameter is column-major, so the first two parameters specify the two elements of the first column.

this
this(Vector2d col0, Vector2d col1)

Create a new {@link Matrix2d} and initialize its two columns using the supplied vectors.

Members

Functions

_m00
Matrix2d _m00(double m00)

Set the value of the matrix element at column 0 and row 0.

_m01
Matrix2d _m01(double m01)

Set the value of the matrix element at column 0 and row 1.

_m10
Matrix2d _m10(double m10)

Set the value of the matrix element at column 1 and row 0.

_m11
Matrix2d _m11(double m11)

Set the value of the matrix element at column 1 and row 1.

add
Matrix2d add(Matrix2d other)

Component-wise add <code>this</code> and <code>other</code>.

add
Matrix2d add(Matrix2d other, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
determinant
double determinant()
Undocumented in source. Be warned that the author may not have intended to support it.
equals
bool equals(Matrix2d m, double delta)
Undocumented in source. Be warned that the author may not have intended to support it.
get
Matrix2d get(Matrix2d dest)

Get the current values of <code>this</code> matrix and store them into <code>dest</code>. <p> This is the reverse method of {@link #set(Matrix2d)} and allows to obtain intermediate calculation results when chaining multiple transformations.

get
Matrix3x2d get(Matrix3x2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
get
Matrix3d get(Matrix3d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
get
double get(int column, int row)
Undocumented in source. Be warned that the author may not have intended to support it.
getColumn
Vector2d getColumn(int column, Vector2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
getRotation
double getRotation()
Undocumented in source. Be warned that the author may not have intended to support it.
getRow
Vector2d getRow(int row, Vector2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
getScale
Vector2d getScale(Vector2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
hashCode
int hashCode()
Undocumented in source. Be warned that the author may not have intended to support it.
identity
Matrix2d identity()

Set this matrix to the identity.

invert
Matrix2d invert()

Invert this matrix.

invert
Matrix2d invert(Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
isFinite
bool isFinite()
Undocumented in source. Be warned that the author may not have intended to support it.
lerp
Matrix2d lerp(Matrix2d other, double t)

Linearly interpolate <code>this</code> and <code>other</code> using the given interpolation factor <code>t</code> and store the result in <code>this</code>. <p> If <code>t</code> is <code>0.0</code> then the result is <code>this</code>. If the interpolation factor is <code>1.0</code> then the result is <code>other</code>.

lerp
Matrix2d lerp(Matrix2d other, double t, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
mul
Matrix2d mul(Matrix2d right)

Multiply this matrix by the supplied <code>right</code> matrix. <p> If <code>M</code> is <code>this</code> matrix and <code>R</code> the <code>right</code> matrix, then the new matrix will be <code>M * R</code>. So when transforming a vector <code>v</code> with the new matrix by using <code>M * R * v</code>, the transformation of the right matrix will be applied first!

mul
Matrix2d mul(Matrix2d right, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
mulComponentWise
Matrix2d mulComponentWise(Matrix2d other)

Component-wise multiply <code>this</code> by <code>other</code>.

mulComponentWise
Matrix2d mulComponentWise(Matrix2d other, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
mulLocal
Matrix2d mulLocal(Matrix2d left)

Pre-multiply this matrix by the supplied <code>left</code> matrix and store the result in <code>this</code>. <p> If <code>M</code> is <code>this</code> matrix and <code>L</code> the <code>left</code> matrix, then the new matrix will be <code>L * M</code>. So when transforming a vector <code>v</code> with the new matrix by using <code>L * M * v</code>, the transformation of <code>this</code> matrix will be applied first!

mulLocal
Matrix2d mulLocal(Matrix2d left, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
normal
Matrix2d normal()

Set <code>this</code> matrix to its own normal matrix. <p> Please note that, if <code>this</code> is an orthogonal matrix or a matrix whose columns are orthogonal vectors, then this method <i>need not</i> be invoked, since in that case <code>this</code> itself is its normal matrix. In this case, use {@link #set(Matrix2d)} to set a given Matrix2d to this matrix.

normal
Matrix2d normal(Matrix2d dest)

Compute a normal matrix from <code>this</code> matrix and store it into <code>dest</code>. <p> Please note that, if <code>this</code> is an orthogonal matrix or a matrix whose columns are orthogonal vectors, then this method <i>need not</i> be invoked, since in that case <code>this</code> itself is its normal matrix. In this case, use {@link #set(Matrix2d)} to set a given Matrix2d to this matrix.

normalizedPositiveX
Vector2d normalizedPositiveX(Vector2d dir)
Undocumented in source. Be warned that the author may not have intended to support it.
normalizedPositiveY
Vector2d normalizedPositiveY(Vector2d dir)
Undocumented in source. Be warned that the author may not have intended to support it.
positiveX
Vector2d positiveX(Vector2d dir)
Undocumented in source. Be warned that the author may not have intended to support it.
positiveY
Vector2d positiveY(Vector2d dir)
Undocumented in source. Be warned that the author may not have intended to support it.
rotate
Matrix2d rotate(double angle)

Apply rotation about the origin to this matrix by rotating the given amount of radians. <p> The produced rotation will rotate a vector counter-clockwise around the origin. <p> If <code>M</code> is <code>this</code> matrix and <code>R</code> the rotation matrix, then the new matrix will be <code>M * R</code>. So when transforming a vector <code>v</code> with the new matrix by using <code>M * R * v</code> , the rotation will be applied first! <p> Reference: <a href="https://en.wikipedia.org/wiki/Rotation_matrix#In_two_dimensions">http://en.wikipedia.org</a>

rotate
Matrix2d rotate(double angle, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
rotateLocal
Matrix2d rotateLocal(double angle)

Pre-multiply a rotation to this matrix by rotating the given amount of radians about the origin. <p> The produced rotation will rotate a vector counter-clockwise around the origin. <p> If <code>M</code> is <code>this</code> matrix and <code>R</code> the rotation matrix, then the new matrix will be <code>R * M</code>. So when transforming a vector <code>v</code> with the new matrix by using <code>R * M * v</code>, the rotation will be applied last! <p> In order to set the matrix to a rotation matrix without pre-multiplying the rotation transformation, use {@link #rotation(double) rotation()}. <p> Reference: <a href="https://en.wikipedia.org/wiki/Rotation_matrix#In_two_dimensions">http://en.wikipedia.org</a>

rotateLocal
Matrix2d rotateLocal(double angle, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
rotation
Matrix2d rotation(double angle)

Set this matrix to a rotation matrix which rotates the given radians about the origin. <p> The produced rotation will rotate a vector counter-clockwise around the origin. <p> The resulting matrix can be multiplied against another transformation matrix to obtain an additional rotation. <p> In order to post-multiply a rotation transformation directly to a matrix, use {@link #rotate(double) rotate()} instead.

scale
Matrix2d scale(Vector2d xy, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
scale
Matrix2d scale(Vector2d xy)

Apply scaling to this matrix by scaling the base axes by the given <code>xy.x</code> and <code>xy.y</code> factors, respectively. <p> If <code>M</code> is <code>this</code> matrix and <code>S</code> the scaling matrix, then the new matrix will be <code>M * S</code>. So when transforming a vector <code>v</code> with the new matrix by using <code>M * S * v</code>, the scaling will be applied first!

scale
Matrix2d scale(double x, double y, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
scale
Matrix2d scale(double x, double y)

Apply scaling to this matrix by scaling the base axes by the given x and y factors. <p> If <code>M</code> is <code>this</code> matrix and <code>S</code> the scaling matrix, then the new matrix will be <code>M * S</code>. So when transforming a vector <code>v</code> with the new matrix by using <code>M * S * v</code> , the scaling will be applied first!

scale
Matrix2d scale(double xy, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
scale
Matrix2d scale(double xy)

Apply scaling to this matrix by uniformly scaling all base axes by the given <code>xy</code> factor. <p> If <code>M</code> is <code>this</code> matrix and <code>S</code> the scaling matrix, then the new matrix will be <code>M * S</code>. So when transforming a vector <code>v</code> with the new matrix by using <code>M * S * v</code> , the scaling will be applied first!

scaleLocal
Matrix2d scaleLocal(double x, double y, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
scaleLocal
Matrix2d scaleLocal(double x, double y)

Pre-multiply scaling to this matrix by scaling the base axes by the given x and y factors. <p> If <code>M</code> is <code>this</code> matrix and <code>S</code> the scaling matrix, then the new matrix will be <code>S * M</code>. So when transforming a vector <code>v</code> with the new matrix by using <code>S * M * v</code>, the scaling will be applied last!

scaling
Matrix2d scaling(double factor)

Set this matrix to be a simple scale matrix, which scales all axes uniformly by the given factor. <p> The resulting matrix can be multiplied against another transformation matrix to obtain an additional scaling. <p> In order to post-multiply a scaling transformation directly to a matrix, use {@link #scale(double) scale()} instead.

scaling
Matrix2d scaling(double x, double y)

Set this matrix to be a simple scale matrix.

scaling
Matrix2d scaling(Vector2d xy)

Set this matrix to be a simple scale matrix which scales the base axes by <code>xy.x</code> and <code>xy.y</code> respectively. <p> The resulting matrix can be multiplied against another transformation matrix to obtain an additional scaling. <p> In order to post-multiply a scaling transformation directly to a matrix use {@link #scale(Vector2d) scale()} instead.

set
Matrix2d set(Matrix2d m)

Set the elements of this matrix to the ones in <code>m</code>.

set
Matrix2d set(Matrix3x2d m)

Set the elements of this matrix to the left 2x2 submatrix of <code>m</code>.

set
Matrix2d set(Matrix3d m)

Set the elements of this matrix to the upper left 2x2 of the given {@link Matrix3d}.

set
Matrix2d set(double m00, double m01, double m10, double m11)

Set the values within this matrix to the supplied double values. The result looks like this: <p> m00, m10<br> m01, m11<br>

set
Matrix2d set(Vector2d col0, Vector2d col1)

Set the two columns of this matrix to the supplied vectors, respectively.

set
Matrix2d set(int column, int row, double value)

Set the matrix element at the given column and row to the specified value.

setColumn
Matrix2d setColumn(int column, Vector2d src)

Set the column at the given <code>column</code> index, starting with <code>0</code>.

setColumn
Matrix2d setColumn(int column, double x, double y)

Set the column at the given <code>column</code> index, starting with <code>0</code>.

setRow
Matrix2d setRow(int row, Vector2d src)

Set the row at the given <code>row</code> index, starting with <code>0</code>.

setRow
Matrix2d setRow(int row, double x, double y)

Set the row at the given <code>row</code> index, starting with <code>0</code>.

setm00
Matrix2d setm00(double m00)

Set the value of the matrix element at column 0 and row 0.

setm01
Matrix2d setm01(double m01)

Set the value of the matrix element at column 0 and row 1.

setm10
Matrix2d setm10(double m10)

Set the value of the matrix element at column 1 and row 0.

setm11
Matrix2d setm11(double m11)

Set the value of the matrix element at column 1 and row 1.

sub
Matrix2d sub(Matrix2d subtrahend)

Component-wise subtract <code>subtrahend</code> from <code>this</code>.

sub
Matrix2d sub(Matrix2d other, Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
swap
Matrix2d swap(Matrix2d other)

Exchange the values of <code>this</code> matrix with the given <code>other</code> matrix.

transform
Vector2d transform(Vector2d v)
Undocumented in source. Be warned that the author may not have intended to support it.
transform
Vector2d transform(Vector2d v, Vector2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
transform
Vector2d transform(double x, double y, Vector2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
transformTranspose
Vector2d transformTranspose(Vector2d v)
Undocumented in source. Be warned that the author may not have intended to support it.
transformTranspose
Vector2d transformTranspose(Vector2d v, Vector2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
transformTranspose
Vector2d transformTranspose(double x, double y, Vector2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
transpose
Matrix2d transpose()

Transpose this matrix.

transpose
Matrix2d transpose(Matrix2d dest)
Undocumented in source. Be warned that the author may not have intended to support it.
zero
Matrix2d zero()

Set all values within this matrix to zero.

Variables

m00
double m00;
Undocumented in source.
m01
double m01;
Undocumented in source.
m10
double m10;
Undocumented in source.
m11
double m11;
Undocumented in source.

Meta