Package org.joml

Interface Matrix2fc

All Known Implementing Classes:
Matrix2f

public interface Matrix2fc
Interface to a read-only view of a 2x2 matrix of single-precision floats.
Author:
Joseph Burton
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Matrix2fc other, Matrix2f dest)
    Component-wise add this and other and store the result in dest.
    float
    Return the determinant of this matrix.
    boolean
    equals(Matrix2fc m, float 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.
    float[]
    get(float[] arr)
    Store this matrix into the supplied float array in column-major order.
    float[]
    get(float[] arr, int offset)
    Store this matrix into the supplied float array in column-major order at the given offset.
    float
    get(int column, int row)
    Get the matrix element value at the given column and row.
    com.google.gwt.typedarrays.shared.Float32Array
    get(int index, com.google.gwt.typedarrays.shared.Float32Array buffer)
    Store this matrix in column-major order into the supplied Float32Array at the given index.
    get(int index, ByteBuffer buffer)
    Store this matrix in column-major order into the supplied ByteBuffer starting at the specified absolute buffer position/index.
    get(int index, FloatBuffer buffer)
    Store this matrix in column-major order into the supplied FloatBuffer starting at the specified absolute buffer position/index.
    com.google.gwt.typedarrays.shared.Float32Array
    get(com.google.gwt.typedarrays.shared.Float32Array buffer)
    Store this matrix in column-major order into the supplied Float32Array.
    get(ByteBuffer buffer)
    Store this matrix in column-major order into the supplied ByteBuffer at the current buffer position.
    get(FloatBuffer buffer)
    Store this matrix in column-major order into the supplied FloatBuffer at the current buffer position.
    get(Matrix2f dest)
    Get the current values of this matrix and store them into dest.
    get(Matrix3f dest)
    Get the current values of this matrix and store them as the rotational component of dest.
    Get the current values of this matrix and store them as the rotational component of dest.
    getColumn(int column, Vector2f dest)
    Get the column at the given column index, starting with 0.
    float
    Get the angle of the rotation component of this matrix.
    getRow(int row, Vector2f dest)
    Get the row at the given row index, starting with 0.
    Get the scaling factors of this matrix for the three base axes.
    getToAddress(long address)
    Store this matrix in column-major order at the given off-heap address.
    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.
    getTransposed(int index, FloatBuffer buffer)
    Store the transpose of this matrix in column-major order into the supplied FloatBuffer starting at the specified absolute buffer position/index.
    Store the transpose of this matrix in column-major order into the supplied ByteBuffer at the current buffer position.
    Store the transpose of this matrix in column-major order into the supplied FloatBuffer at the current buffer position.
    Invert the this matrix and store the result in dest.
    boolean
    Determine whether all matrix elements are finite floating-point values, that is, they are not NaN and not infinity.
    lerp(Matrix2fc other, float t, Matrix2f dest)
    Linearly interpolate this and other using the given interpolation factor t and store the result in dest.
    float
    m00()
    Return the value of the matrix element at column 0 and row 0.
    float
    m01()
    Return the value of the matrix element at column 0 and row 1.
    float
    m10()
    Return the value of the matrix element at column 1 and row 0.
    float
    m11()
    Return the value of the matrix element at column 1 and row 1.
    mul(Matrix2fc right, Matrix2f dest)
    Multiply this matrix by the supplied right matrix and store the result in dest.
    Component-wise multiply this by other and store the result in dest.
    Pre-multiply this matrix by the supplied left matrix and store the result in dest.
    Compute a normal matrix from this matrix and store it into dest.
    Obtain the direction of +X before the transformation represented by this orthogonal matrix is applied.
    Obtain the direction of +Y before the transformation represented by this orthogonal matrix is applied.
    Obtain the direction of +X before the transformation represented by this matrix is applied.
    Obtain the direction of +Y before the transformation represented by this matrix is applied.
    rotate(float ang, Matrix2f dest)
    Apply rotation to this matrix by rotating the given amount of radians and store the result in dest.
    rotateLocal(float ang, Matrix2f dest)
    Pre-multiply a rotation to this matrix by rotating the given amount of radians and store the result in dest.
    scale(float x, float y, Matrix2f dest)
    Apply scaling to this matrix by scaling the base axes by the given x and y factors and store the result in dest.
    scale(float xy, Matrix2f dest)
    Apply scaling to this matrix by uniformly scaling all base axes by the given xy factor and store the result in 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.
    scaleLocal(float x, float y, Matrix2f 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.
    sub(Matrix2fc subtrahend, Matrix2f dest)
    Component-wise subtract subtrahend from this and store the result in dest.
    transform(float x, float y, Vector2f dest)
    Transform the vector (x, y) by this matrix and store the result in dest.
    Transform the given vector by this matrix.
    Transform the given vector by this matrix and store the result in dest.
    transformTranspose(float x, float y, Vector2f dest)
    Transform the vector (x, y) by the transpose of this matrix and store the result in dest.
    Transform the given vector by the transpose of this matrix.
    Transform the given vector by the transpose of this matrix and store the result in dest.
    Transpose this matrix and store the result in dest.
  • Method Details

    • m00

      float m00()
      Return the value of the matrix element at column 0 and row 0.
      Returns:
      the value of the matrix element
    • m01

      float m01()
      Return the value of the matrix element at column 0 and row 1.
      Returns:
      the value of the matrix element
    • m10

      float m10()
      Return the value of the matrix element at column 1 and row 0.
      Returns:
      the value of the matrix element
    • m11

      float m11()
      Return the value of the matrix element at column 1 and row 1.
      Returns:
      the value of the matrix element
    • mul

      Matrix2f mul(Matrix2fc right, Matrix2f dest)
      Multiply this matrix by the supplied right 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!

      Parameters:
      right - the right operand of the matrix multiplication
      dest - will hold the result
      Returns:
      dest
    • mulLocal

      Matrix2f mulLocal(Matrix2fc left, Matrix2f dest)
      Pre-multiply this matrix by the supplied left 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!

      Parameters:
      left - the left operand of the matrix multiplication
      dest - the destination matrix, which will hold the result
      Returns:
      dest
    • determinant

      float determinant()
      Return the determinant of this matrix.
      Returns:
      the determinant
    • invert

      Matrix2f invert(Matrix2f dest)
      Invert the this matrix and store the result in dest.
      Parameters:
      dest - will hold the result
      Returns:
      dest
    • transpose

      Matrix2f transpose(Matrix2f dest)
      Transpose this matrix and store the result in dest.
      Parameters:
      dest - will hold the result
      Returns:
      dest
    • get

      Matrix2f get(Matrix2f dest)
      Get the current values of this matrix and store them into dest.
      Parameters:
      dest - the destination matrix
      Returns:
      the passed in destination
    • get

      Get the current values of this matrix and store them as the rotational component of dest. All other values of dest will be set to 0.
      Parameters:
      dest - the destination matrix
      Returns:
      the passed in destination
      See Also:
    • get

      Matrix3f get(Matrix3f dest)
      Get the current values of this matrix and store them as the rotational component of dest. All other values of dest will be set to identity.
      Parameters:
      dest - the destination matrix
      Returns:
      the passed in destination
      See Also:
    • getRotation

      float getRotation()
      Get the angle of the rotation component of this matrix.

      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

      com.google.gwt.typedarrays.shared.Float32Array get(com.google.gwt.typedarrays.shared.Float32Array buffer)
      Store this matrix in column-major order into the supplied Float32Array.
      Parameters:
      buffer - will receive the values of this matrix in column-major order
      Returns:
      the passed in buffer
    • get

      com.google.gwt.typedarrays.shared.Float32Array get(int index, com.google.gwt.typedarrays.shared.Float32Array buffer)
      Store this matrix in column-major order into the supplied Float32Array at the given index.
      Parameters:
      index - the index at which to store this matrix in the supplied Float32Array
      buffer - will receive the values of this matrix in column-major order
      Returns:
      the passed in buffer
    • get

      FloatBuffer get(FloatBuffer buffer)
      Store this matrix in column-major order into the supplied FloatBuffer at the current buffer position.

      This method will not increment the position of the given FloatBuffer.

      In order to specify the offset into the FloatBuffer at which the matrix is stored, use get(int, FloatBuffer), 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

      FloatBuffer get(int index, FloatBuffer buffer)
      Store this matrix in column-major order into the supplied FloatBuffer starting at the specified absolute buffer position/index.

      This method will not increment the position of the given FloatBuffer.

      Parameters:
      index - the absolute position into the FloatBuffer
      buffer - will receive the values of this matrix in column-major order
      Returns:
      the passed in buffer
    • get

      ByteBuffer get(ByteBuffer buffer)
      Store this matrix in column-major order into the supplied ByteBuffer 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 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

      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.

      This method will not increment the position of the given ByteBuffer.

      Parameters:
      index - the absolute position into the ByteBuffer
      buffer - will receive the values of this matrix in column-major order
      Returns:
      the passed in buffer
    • getTransposed

      FloatBuffer getTransposed(FloatBuffer buffer)
      Store the transpose of this matrix in column-major order into the supplied FloatBuffer at the current buffer position.

      This method will not increment the position of 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 column-major order at its current position
      Returns:
      the passed in buffer
      See Also:
    • getTransposed

      FloatBuffer getTransposed(int index, FloatBuffer buffer)
      Store the transpose of this matrix in column-major order into the supplied FloatBuffer starting at the specified absolute buffer position/index.

      This method will not increment the position of the given FloatBuffer.

      Parameters:
      index - the absolute position into the FloatBuffer
      buffer - will receive the values of this matrix in column-major order
      Returns:
      the passed in buffer
    • getTransposed

      ByteBuffer getTransposed(ByteBuffer buffer)
      Store the transpose of this matrix in column-major order into the supplied ByteBuffer 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 getTransposed(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:
    • getTransposed

      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.

      This method will not increment the position of the given ByteBuffer.

      Parameters:
      index - the absolute position into the ByteBuffer
      buffer - will receive the values of this matrix in column-major order
      Returns:
      the passed in buffer
    • getToAddress

      Matrix2fc getToAddress(long address)
      Store this matrix in column-major order at the given off-heap address.

      This method will throw an UnsupportedOperationException when 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

      float[] get(float[] arr, int offset)
      Store this matrix into the supplied float array in column-major order at the given offset.
      Parameters:
      arr - the array to write the matrix values into
      offset - the offset into the array
      Returns:
      the passed in array
    • get

      float[] get(float[] arr)
      Store this matrix into the supplied float array in column-major order.

      In order to specify an explicit offset into the array, use the method get(float[], int).

      Parameters:
      arr - the array to write the matrix values into
      Returns:
      the passed in array
      See Also:
    • scale

      Matrix2f scale(Vector2fc xy, Matrix2f 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.

      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!

      Parameters:
      xy - the factors of the x and y component, respectively
      dest - will hold the result
      Returns:
      dest
    • scale

      Matrix2f scale(float x, float y, Matrix2f dest)
      Apply scaling to this 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 M * S. So when transforming a vector v with the new matrix by using M * S * v , the scaling will be applied first!

      Parameters:
      x - the factor of the x component
      y - the factor of the y component
      dest - will hold the result
      Returns:
      dest
    • scale

      Matrix2f scale(float xy, Matrix2f dest)
      Apply scaling to this matrix by uniformly scaling all base axes by the given xy 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!

      Parameters:
      xy - the factor for all components
      dest - will hold the result
      Returns:
      dest
      See Also:
    • scaleLocal

      Matrix2f scaleLocal(float x, float y, Matrix2f 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.

      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!

      Parameters:
      x - the factor of the x component
      y - the factor of the y component
      dest - will hold the result
      Returns:
      dest
    • transform

      Vector2f transform(Vector2f v)
      Transform the given vector by this matrix.
      Parameters:
      v - the vector to transform
      Returns:
      v
    • transform

      Vector2f transform(Vector2fc v, Vector2f dest)
      Transform the given vector by this matrix and store the result in dest.
      Parameters:
      v - the vector to transform
      dest - will hold the result
      Returns:
      dest
    • transform

      Vector2f transform(float x, float y, Vector2f dest)
      Transform the vector (x, y) by this matrix and store the result in dest.
      Parameters:
      x - the x coordinate of the vector to transform
      y - the y coordinate of the vector to transform
      dest - will hold the result
      Returns:
      dest
    • transformTranspose

      Vector2f transformTranspose(Vector2f v)
      Transform the given vector by the transpose of this matrix.
      Parameters:
      v - the vector to transform
      Returns:
      v
    • transformTranspose

      Vector2f transformTranspose(Vector2fc v, Vector2f dest)
      Transform the given vector by the transpose of this matrix and store the result in dest.
      Parameters:
      v - the vector to transform
      dest - will hold the result
      Returns:
      dest
    • transformTranspose

      Vector2f transformTranspose(float x, float y, Vector2f dest)
      Transform the vector (x, y) by the transpose of this matrix and store the result in dest.
      Parameters:
      x - the x coordinate of the vector to transform
      y - the y coordinate of the vector to transform
      dest - will hold the result
      Returns:
      dest
    • rotate

      Matrix2f rotate(float ang, Matrix2f dest)
      Apply rotation to this matrix by rotating the given amount of radians and store the result in dest.

      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

      Parameters:
      ang - the angle in radians
      dest - will hold the result
      Returns:
      dest
    • rotateLocal

      Matrix2f rotateLocal(float ang, Matrix2f dest)
      Pre-multiply a rotation to this matrix by rotating the given amount of radians and store the result in dest.

      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

      Parameters:
      ang - the angle in radians
      dest - will hold the result
      Returns:
      dest
    • getRow

      Vector2f getRow(int row, Vector2f dest) throws IndexOutOfBoundsException
      Get the row at the given row index, starting with 0.
      Parameters:
      row - the row index in [0..1]
      dest - will hold the row components
      Returns:
      the passed in destination
      Throws:
      IndexOutOfBoundsException - if row is not in [0..1]
    • getColumn

      Vector2f getColumn(int column, Vector2f dest) throws IndexOutOfBoundsException
      Get the column at the given column index, starting with 0.
      Parameters:
      column - the column index in [0..1]
      dest - will hold the column components
      Returns:
      the passed in destination
      Throws:
      IndexOutOfBoundsException - if column is not in [0..1]
    • get

      float 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

      Matrix2f normal(Matrix2f dest)
      Compute a normal matrix from this matrix and store it into dest.
      Parameters:
      dest - will hold the result
      Returns:
      dest
    • getScale

      Vector2f getScale(Vector2f dest)
      Get the scaling factors of this matrix for the three base axes.
      Parameters:
      dest - will hold the scaling factors for x and y
      Returns:
      dest
    • positiveX

      Vector2f positiveX(Vector2f dest)
      Obtain the direction of +X before the transformation represented by this matrix is applied.

      This method is equivalent to the following code:

       Matrix2f inv = new Matrix2f(this).invert();
       inv.transform(dir.set(1, 0)).normalize();
       
      If this is already an orthogonal matrix, then consider using normalizedPositiveX(Vector2f) instead.
      Parameters:
      dest - will hold the direction of +X
      Returns:
      dest
    • normalizedPositiveX

      Vector2f normalizedPositiveX(Vector2f dest)
      Obtain the direction of +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:

       Matrix2f inv = new Matrix2f(this).transpose();
       inv.transform(dir.set(1, 0));
       
      Parameters:
      dest - will hold the direction of +X
      Returns:
      dest
    • positiveY

      Vector2f positiveY(Vector2f dest)
      Obtain the direction of +Y before the transformation represented by this matrix is applied.

      This method is equivalent to the following code:

       Matrix2f inv = new Matrix2f(this).invert();
       inv.transform(dir.set(0, 1)).normalize();
       
      If this is already an orthogonal matrix, then consider using normalizedPositiveY(Vector2f) instead.
      Parameters:
      dest - will hold the direction of +Y
      Returns:
      dest
    • normalizedPositiveY

      Vector2f normalizedPositiveY(Vector2f dest)
      Obtain the direction of +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:

       Matrix2f inv = new Matrix2f(this).transpose();
       inv.transform(dir.set(0, 1));
       
      Parameters:
      dest - will hold the direction of +Y
      Returns:
      dest
    • add

      Matrix2f add(Matrix2fc other, Matrix2f dest)
      Component-wise add this and other and store the result in dest.
      Parameters:
      other - the other addend
      dest - will hold the result
      Returns:
      dest
    • sub

      Matrix2f sub(Matrix2fc subtrahend, Matrix2f dest)
      Component-wise subtract subtrahend from this and store the result in dest.
      Parameters:
      subtrahend - the subtrahend
      dest - will hold the result
      Returns:
      dest
    • mulComponentWise

      Matrix2f mulComponentWise(Matrix2fc other, Matrix2f dest)
      Component-wise multiply this by other and store the result in dest.
      Parameters:
      other - the other matrix
      dest - will hold the result
      Returns:
      dest
    • lerp

      Matrix2f lerp(Matrix2fc other, float t, Matrix2f dest)
      Linearly interpolate this 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.

      Parameters:
      other - the other matrix
      t - the interpolation factor between 0.0 and 1.0
      dest - will hold the result
      Returns:
      dest
    • equals

      boolean equals(Matrix2fc m, float 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.

      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.

      Parameters:
      m - the other matrix
      delta - the allowed maximum difference
      Returns:
      true whether all of the matrix elements are equal; false otherwise
    • isFinite

      boolean isFinite()
      Determine whether all matrix elements are finite floating-point values, that is, they are not NaN and not infinity.
      Returns:
      true if all components are finite floating-point values; false otherwise