Class Matrix

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Matrix extends ProxyInstance

A structure capable of holding a 4x4 matrix.

The contents of the graphene_matrix_t structure are private and should never be accessed directly.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocate a new Matrix.
    Matrix(Arena arena)
    Allocate a new Matrix.
    Create a Matrix proxy instance for the provided memory address.
    Allocate a new Matrix with the fields set to the provided values.
    Matrix(Simd4X4F value, Arena arena)
    Allocate a new Matrix with the fields set to the provided values.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Matrix
    Allocates a new graphene_matrix_t.
    boolean
    decompose(Vec3 translate, Vec3 scale, Quaternion rotate, Vec3 shear, Vec4 perspective)
    Decomposes a transformation matrix into its component transformations.
    float
    Computes the determinant of the given matrix.
    boolean
    Checks whether the two given graphene_matrix_t matrices are equal.
    boolean
    Checks whether the two given graphene_matrix_t matrices are byte-by-byte equal.
    void
    Frees the resources allocated by graphene_matrix_alloc().
    The memory layout of the native struct.
    void
    getRow(int index, Vec4 res)
    Retrieves the given row vector at index inside a matrix.
    static @Nullable Type
    Get the GType of the Matrix class.
    float
    getValue(int row, int col)
    Retrieves the value at the given row and col index.
    float
    Retrieves the scaling factor on the X axis in m.
    float
    Retrieves the translation component on the X axis from m.
    float
    Retrieves the scaling factor on the Y axis in m.
    float
    Retrieves the translation component on the Y axis from m.
    float
    Retrieves the scaling factor on the Z axis in m.
    float
    Retrieves the translation component on the Z axis from m.
    initFrom2d(double xx, double yx, double xy, double yy, double x0, double y0)
    Initializes a graphene_matrix_t from the values of an affine transformation matrix.
    initFromFloat(@Nullable float @Nullable [] v)
    Initializes a graphene_matrix_t with the given array of floating point values.
    Initializes a graphene_matrix_t using the values of the given matrix.
    initFromVec4(Vec4 v0, Vec4 v1, Vec4 v2, Vec4 v3)
    Initializes a graphene_matrix_t with the given four row vectors.
    initFrustum(float left, float right, float bottom, float top, float zNear, float zFar)
    Initializes a graphene_matrix_t compatible with graphene_frustum_t.
    Initializes a graphene_matrix_t with the identity matrix.
    initLookAt(Vec3 eye, Vec3 center, Vec3 up)
    Initializes a graphene_matrix_t so that it positions the "camera" at the given eye coordinates towards an object at the center coordinates.
    initOrtho(float left, float right, float top, float bottom, float zNear, float zFar)
    Initializes a graphene_matrix_t with an orthographic projection.
    initPerspective(float fovy, float aspect, float zNear, float zFar)
    Initializes a graphene_matrix_t with a perspective projection.
    initRotate(float angle, Vec3 axis)
    Initializes this Matrix to represent a rotation of angle degrees on the axis represented by the axis vector.
    initScale(float x, float y, float z)
    Initializes a graphene_matrix_t with the given scaling factors.
    initSkew(float xSkew, float ySkew)
    Initializes a graphene_matrix_t with a skew transformation with the given factors.
    Initializes a graphene_matrix_t with a translation to the given coordinates.
    void
    interpolate(Matrix b, double factor, Matrix res)
    Linearly interpolates the two given graphene_matrix_t by interpolating the decomposed transformations separately.
    boolean
    Inverts the given matrix.
    boolean
    Checks whether the given graphene_matrix_t is compatible with an a 2D affine transformation matrix.
    boolean
    Checks whether a graphene_matrix_t has a visible back face.
    boolean
    Checks whether the given graphene_matrix_t is the identity matrix.
    boolean
    Checks whether a matrix is singular.
    void
    Multiplies two graphene_matrix_t.
    boolean
    near(Matrix b, float epsilon)
    Compares the two given graphene_matrix_t matrices and checks whether their values are within the given epsilon of each other.
    void
    Normalizes the given graphene_matrix_t.
    void
    perspective(float depth, Matrix res)
    Applies a perspective of depth to the matrix.
    void
    Prints the contents of a matrix to the standard error stream.
    void
    Projects a graphene_point_t using the matrix m.
    void
    Projects all corners of a graphene_rect_t using the given matrix.
    void
    Projects a graphene_rect_t using the given matrix.
    @Nullable Simd4X4F
    Read the value of the field value.
    void
    rotate(float angle, Vec3 axis)
    Adds a rotation transformation to m, using the given angle and axis vector.
    void
    Adds a rotation transformation to m, using the given graphene_euler_t.
    void
    Adds a rotation transformation to m, using the given graphene_quaternion_t.
    void
    rotateX(float angle)
    Adds a rotation transformation around the X axis to m, using the given angle.
    void
    rotateY(float angle)
    Adds a rotation transformation around the Y axis to m, using the given angle.
    void
    rotateZ(float angle)
    Adds a rotation transformation around the Z axis to m, using the given angle.
    void
    scale(float factorX, float factorY, float factorZ)
    Adds a scaling transformation to m, using the three given factors.
    void
    skewXy(float factor)
    Adds a skew of factor on the X and Y axis to the given matrix.
    void
    skewXz(float factor)
    Adds a skew of factor on the X and Z axis to the given matrix.
    void
    skewYz(float factor)
    Adds a skew of factor on the Y and Z axis to the given matrix.
    boolean
    to2d(Out<Double> xx, Out<Double> yx, Out<Double> xy, Out<Double> yy, Out<Double> x0, Out<Double> y0)
    Converts a graphene_matrix_t to an affine transformation matrix, if the given matrix is compatible.
    void
    toFloat(@Nullable Out<float[]> v)
    Converts a graphene_matrix_t to an array of floating point values.
    void
    Transforms each corner of a graphene_rect_t using the given matrix m.
    void
    transformBox(Box b, Box res)
    Transforms the vertices of a graphene_box_t using the given matrix m.
    void
    Transforms the given graphene_point_t using the matrix m.
    void
    Transforms the given graphene_point3d_t using the matrix m.
    void
    transformRay(Ray r, Ray res)
    Transform a graphene_ray_t using the given matrix m.
    void
    Transforms each corner of a graphene_rect_t using the given matrix m.
    void
    Transforms a graphene_sphere_t using the given matrix m. The result is the bounding sphere containing the transformed sphere.
    void
    Transforms the given graphene_vec3_t using the matrix m.
    void
    Transforms the given graphene_vec4_t using the matrix m.
    void
    Adds a translation transformation to this Matrix using the coordinates of the given graphene_point3d_t.
    void
    Transposes the given matrix.
    void
    unprojectPoint3d(Matrix modelview, Point3D point, Point3D res)
    Unprojects the given point using the this Matrix matrix and a modelview matrix.
    void
    untransformBounds(Rect r, Rect bounds, Rect res)
    Undoes the transformation on the corners of a graphene_rect_t using the given matrix, within the given axis aligned rectangular bounds.
    boolean
    untransformPoint(Point p, Rect bounds, Point res)
    Undoes the transformation of a graphene_point_t using the given matrix, within the given axis aligned rectangular bounds.
    void
    writeValue(@Nullable Simd4X4F value)
    Write a value in the field value.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Matrix

      public Matrix(MemorySegment address)
      Create a Matrix proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Matrix

      public Matrix(Arena arena)
      Allocate a new Matrix.
      Parameters:
      arena - to control the memory allocation scope
    • Matrix

      public Matrix()
      Allocate a new Matrix. The memory is allocated with Arena.ofAuto().
    • Matrix

      public Matrix(Simd4X4F value, Arena arena)
      Allocate a new Matrix with the fields set to the provided values.
      Parameters:
      value - value for the field value
      arena - to control the memory allocation scope
    • Matrix

      public Matrix(Simd4X4F value)
      Allocate a new Matrix with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      value - value for the field value
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Matrix class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readValue

      public @Nullable Simd4X4F readValue()
      Read the value of the field value.
      Returns:
      The value of the field value
    • writeValue

      public void writeValue(@Nullable Simd4X4F value)
      Write a value in the field value.
      Parameters:
      value - The new value for the field value
    • alloc

      public static Matrix alloc()
      Allocates a new graphene_matrix_t.
      Returns:
      the newly allocated matrix
      Since:
      1.0
    • decompose

      public boolean decompose(Vec3 translate, Vec3 scale, Quaternion rotate, Vec3 shear, Vec4 perspective)

      Decomposes a transformation matrix into its component transformations.

      The algorithm for decomposing a matrix is taken from the CSS3 Transforms specification; specifically, the decomposition code is based on the equivalent code published in "Graphics Gems II", edited by Jim Arvo, and available online.

      Parameters:
      translate - the translation vector
      scale - the scale vector
      rotate - the rotation quaternion
      shear - the shear vector
      perspective - the perspective vector
      Returns:
      true if the matrix could be decomposed
    • determinant

      public float determinant()
      Computes the determinant of the given matrix.
      Returns:
      the value of the determinant
      Since:
      1.0
    • equal

      public boolean equal(Matrix b)
      Checks whether the two given graphene_matrix_t matrices are equal.
      Parameters:
      b - a graphene_matrix_t
      Returns:
      true if the two matrices are equal, and false otherwise
      Since:
      1.10
    • equalFast

      public boolean equalFast(Matrix b)

      Checks whether the two given graphene_matrix_t matrices are byte-by-byte equal.

      While this function is faster than graphene_matrix_equal(), it can also return false negatives, so it should be used in conjuction with either graphene_matrix_equal() or graphene_matrix_near(). For instance:

        if (graphene_matrix_equal_fast (a, b))
          {
            // matrices are definitely the same
          }
        else
          {
            if (graphene_matrix_equal (a, b))
              // matrices contain the same values within an epsilon of FLT_EPSILON
            else if (graphene_matrix_near (a, b, 0.0001))
              // matrices contain the same values within an epsilon of 0.0001
            else
              // matrices are not equal
          }
      
      Parameters:
      b - a graphene_matrix_t
      Returns:
      true if the matrices are equal. and false otherwise
      Since:
      1.10
    • free

      public void free()
      Frees the resources allocated by graphene_matrix_alloc().
      Since:
      1.0
    • getRow

      public void getRow(int index, Vec4 res)
      Retrieves the given row vector at index inside a matrix.
      Parameters:
      index - the index of the row vector, between 0 and 3
      res - return location for the graphene_vec4_t that is used to store the row vector
      Since:
      1.0
    • getValue

      public float getValue(int row, int col)
      Retrieves the value at the given row and col index.
      Parameters:
      row - the row index
      col - the column index
      Returns:
      the value at the given indices
      Since:
      1.0
    • getXScale

      public float getXScale()
      Retrieves the scaling factor on the X axis in m.
      Returns:
      the value of the scaling factor
      Since:
      1.0
    • getXTranslation

      public float getXTranslation()
      Retrieves the translation component on the X axis from m.
      Returns:
      the translation component
      Since:
      1.10
    • getYScale

      public float getYScale()
      Retrieves the scaling factor on the Y axis in m.
      Returns:
      the value of the scaling factor
      Since:
      1.0
    • getYTranslation

      public float getYTranslation()
      Retrieves the translation component on the Y axis from m.
      Returns:
      the translation component
      Since:
      1.10
    • getZScale

      public float getZScale()
      Retrieves the scaling factor on the Z axis in m.
      Returns:
      the value of the scaling factor
      Since:
      1.0
    • getZTranslation

      public float getZTranslation()
      Retrieves the translation component on the Z axis from m.
      Returns:
      the translation component
      Since:
      1.10
    • initFrom2d

      public Matrix initFrom2d(double xx, double yx, double xy, double yy, double x0, double y0)

      Initializes a graphene_matrix_t from the values of an affine transformation matrix.

      The arguments map to the following matrix layout:

        ⎛ xx  yx ⎞   ⎛  a   b  0 ⎞
        ⎜ xy  yy ⎟ = ⎜  c   d  0 ⎟
        ⎝ x0  y0 ⎠   ⎝ tx  ty  1 ⎠
      

      This function can be used to convert between an affine matrix type from other libraries and a graphene_matrix_t.

      Parameters:
      xx - the xx member
      yx - the yx member
      xy - the xy member
      yy - the yy member
      x0 - the x0 member
      y0 - the y0 member
      Returns:
      the initialized matrix
      Since:
      1.0
    • initFromFloat

      public Matrix initFromFloat(@Nullable float @Nullable [] v)
      Initializes a graphene_matrix_t with the given array of floating point values.
      Parameters:
      v - an array of at least 16 floating point values
      Returns:
      the initialized matrix
      Throws:
      IllegalArgumentException - when length of v is less than 16
      Since:
      1.0
    • initFromMatrix

      public Matrix initFromMatrix(Matrix src)
      Initializes a graphene_matrix_t using the values of the given matrix.
      Parameters:
      src - a graphene_matrix_t
      Returns:
      the initialized matrix
      Since:
      1.0
    • initFromVec4

      public Matrix initFromVec4(Vec4 v0, Vec4 v1, Vec4 v2, Vec4 v3)
      Initializes a graphene_matrix_t with the given four row vectors.
      Parameters:
      v0 - the first row vector
      v1 - the second row vector
      v2 - the third row vector
      v3 - the fourth row vector
      Returns:
      the initialized matrix
      Since:
      1.0
    • initFrustum

      public Matrix initFrustum(float left, float right, float bottom, float top, float zNear, float zFar)

      Initializes a graphene_matrix_t compatible with graphene_frustum_t.

      See also: graphene_frustum_init_from_matrix()

      Parameters:
      left - distance of the left clipping plane
      right - distance of the right clipping plane
      bottom - distance of the bottom clipping plane
      top - distance of the top clipping plane
      zNear - distance of the near clipping plane
      zFar - distance of the far clipping plane
      Returns:
      the initialized matrix
      Since:
      1.2
    • initIdentity

      public Matrix initIdentity()
      Initializes a graphene_matrix_t with the identity matrix.
      Returns:
      the initialized matrix
      Since:
      1.0
    • initLookAt

      public Matrix initLookAt(Vec3 eye, Vec3 center, Vec3 up)

      Initializes a graphene_matrix_t so that it positions the "camera" at the given eye coordinates towards an object at the center coordinates. The top of the camera is aligned to the direction of the up vector.

      Before the transform, the camera is assumed to be placed at the origin, looking towards the negative Z axis, with the top side of the camera facing in the direction of the Y axis and the right side in the direction of the X axis.

      In theory, one could use this Matrix to transform a model of such a camera into world-space. However, it is more common to use the inverse of this Matrix to transform another object from world coordinates to the view coordinates of the camera. Typically you would then apply the camera projection transform to get from view to screen coordinates.

      Parameters:
      eye - the vector describing the position to look from
      center - the vector describing the position to look at
      up - the vector describing the world's upward direction; usually, this is the graphene_vec3_y_axis() vector
      Returns:
      the initialized matrix
      Since:
      1.0
    • initOrtho

      public Matrix initOrtho(float left, float right, float top, float bottom, float zNear, float zFar)
      Initializes a graphene_matrix_t with an orthographic projection.
      Parameters:
      left - the left edge of the clipping plane
      right - the right edge of the clipping plane
      top - the top edge of the clipping plane
      bottom - the bottom edge of the clipping plane
      zNear - the distance of the near clipping plane
      zFar - the distance of the far clipping plane
      Returns:
      the initialized matrix
      Since:
      1.0
    • initPerspective

      public Matrix initPerspective(float fovy, float aspect, float zNear, float zFar)
      Initializes a graphene_matrix_t with a perspective projection.
      Parameters:
      fovy - the field of view angle, in degrees
      aspect - the aspect value
      zNear - the near Z plane
      zFar - the far Z plane
      Returns:
      the initialized matrix
      Since:
      1.0
    • initRotate

      public Matrix initRotate(float angle, Vec3 axis)
      Initializes this Matrix to represent a rotation of angle degrees on the axis represented by the axis vector.
      Parameters:
      angle - the rotation angle, in degrees
      axis - the axis vector as a graphene_vec3_t
      Returns:
      the initialized matrix
      Since:
      1.0
    • initScale

      public Matrix initScale(float x, float y, float z)
      Initializes a graphene_matrix_t with the given scaling factors.
      Parameters:
      x - the scale factor on the X axis
      y - the scale factor on the Y axis
      z - the scale factor on the Z axis
      Returns:
      the initialized matrix
      Since:
      1.0
    • initSkew

      public Matrix initSkew(float xSkew, float ySkew)
      Initializes a graphene_matrix_t with a skew transformation with the given factors.
      Parameters:
      xSkew - skew factor, in radians, on the X axis
      ySkew - skew factor, in radians, on the Y axis
      Returns:
      the initialized matrix
      Since:
      1.0
    • initTranslate

      public Matrix initTranslate(Point3D p)
      Initializes a graphene_matrix_t with a translation to the given coordinates.
      Parameters:
      p - the translation coordinates
      Returns:
      the initialized matrix
      Since:
      1.0
    • interpolate

      public void interpolate(Matrix b, double factor, Matrix res)

      Linearly interpolates the two given graphene_matrix_t by interpolating the decomposed transformations separately.

      If either matrix cannot be reduced to their transformations then the interpolation cannot be performed, and this function will return an identity matrix.

      Parameters:
      b - a graphene_matrix_t
      factor - the linear interpolation factor
      res - return location for the interpolated matrix
      Since:
      1.0
    • inverse

      public boolean inverse(Matrix res)
      Inverts the given matrix.
      Parameters:
      res - return location for the inverse matrix
      Returns:
      true if the matrix is invertible
      Since:
      1.0
    • is2d

      public boolean is2d()
      Checks whether the given graphene_matrix_t is compatible with an a 2D affine transformation matrix.
      Returns:
      true if the matrix is compatible with an affine transformation matrix
      Since:
      1.0
    • isBackfaceVisible

      public boolean isBackfaceVisible()
      Checks whether a graphene_matrix_t has a visible back face.
      Returns:
      true if the back face of the matrix is visible
      Since:
      1.0
    • isIdentity

      public boolean isIdentity()
      Checks whether the given graphene_matrix_t is the identity matrix.
      Returns:
      true if the matrix is the identity matrix
      Since:
      1.0
    • isSingular

      public boolean isSingular()
      Checks whether a matrix is singular.
      Returns:
      true if the matrix is singular
      Since:
      1.0
    • multiply

      public void multiply(Matrix b, Matrix res)

      Multiplies two graphene_matrix_t.

      Matrix multiplication is not commutative in general; the order of the factors matters. The product of this multiplication is (this Matrix × b)

      Parameters:
      b - a graphene_matrix_t
      res - return location for the matrix result
      Since:
      1.0
    • near

      public boolean near(Matrix b, float epsilon)
      Compares the two given graphene_matrix_t matrices and checks whether their values are within the given epsilon of each other.
      Parameters:
      b - a graphene_matrix_t
      epsilon - the threshold between the two matrices
      Returns:
      true if the two matrices are near each other, and false otherwise
      Since:
      1.10
    • normalize

      public void normalize(Matrix res)
      Normalizes the given graphene_matrix_t.
      Parameters:
      res - return location for the normalized matrix
      Since:
      1.0
    • perspective

      public void perspective(float depth, Matrix res)
      Applies a perspective of depth to the matrix.
      Parameters:
      depth - the depth of the perspective
      res - return location for the perspective matrix
      Since:
      1.0
    • print

      public void print()

      Prints the contents of a matrix to the standard error stream.

      This function is only useful for debugging; there are no guarantees made on the format of the output.

      Since:
      1.0
    • projectPoint

      public void projectPoint(Point p, Point res)
      Projects a graphene_point_t using the matrix m.
      Parameters:
      p - a graphene_point_t
      res - return location for the projected point
      Since:
      1.0
    • projectRect

      public void projectRect(Rect r, Quad res)

      Projects all corners of a graphene_rect_t using the given matrix.

      See also: graphene_matrix_project_point()

      Parameters:
      r - a graphene_rect_t
      res - return location for the projected rectangle
      Since:
      1.2
    • projectRectBounds

      public void projectRectBounds(Rect r, Rect res)

      Projects a graphene_rect_t using the given matrix.

      The resulting rectangle is the axis aligned bounding rectangle capable of fully containing the projected rectangle.

      Parameters:
      r - a graphene_rect_t
      res - return location for the projected rectangle
      Since:
      1.0
    • rotate

      public void rotate(float angle, Vec3 axis)

      Adds a rotation transformation to m, using the given angle and axis vector.

      This is the equivalent of calling graphene_matrix_init_rotate() and then multiplying the matrix this Matrix with the rotation matrix.

      Parameters:
      angle - the rotation angle, in degrees
      axis - the rotation axis, as a graphene_vec3_t
      Since:
      1.0
    • rotateEuler

      public void rotateEuler(Euler e)
      Adds a rotation transformation to m, using the given graphene_euler_t.
      Parameters:
      e - a rotation described by a graphene_euler_t
      Since:
      1.2
    • rotateQuaternion

      public void rotateQuaternion(Quaternion q)

      Adds a rotation transformation to m, using the given graphene_quaternion_t.

      This is the equivalent of calling graphene_quaternion_to_matrix() and then multiplying this Matrix with the rotation matrix.

      Parameters:
      q - a rotation described by a graphene_quaternion_t
      Since:
      1.2
    • rotateX

      public void rotateX(float angle)

      Adds a rotation transformation around the X axis to m, using the given angle.

      See also: graphene_matrix_rotate()

      Parameters:
      angle - the rotation angle, in degrees
      Since:
      1.0
    • rotateY

      public void rotateY(float angle)

      Adds a rotation transformation around the Y axis to m, using the given angle.

      See also: graphene_matrix_rotate()

      Parameters:
      angle - the rotation angle, in degrees
      Since:
      1.0
    • rotateZ

      public void rotateZ(float angle)

      Adds a rotation transformation around the Z axis to m, using the given angle.

      See also: graphene_matrix_rotate()

      Parameters:
      angle - the rotation angle, in degrees
      Since:
      1.0
    • scale

      public void scale(float factorX, float factorY, float factorZ)

      Adds a scaling transformation to m, using the three given factors.

      This is the equivalent of calling graphene_matrix_init_scale() and then multiplying the matrix this Matrix with the scale matrix.

      Parameters:
      factorX - scaling factor on the X axis
      factorY - scaling factor on the Y axis
      factorZ - scaling factor on the Z axis
      Since:
      1.0
    • skewXy

      public void skewXy(float factor)
      Adds a skew of factor on the X and Y axis to the given matrix.
      Parameters:
      factor - skew factor
      Since:
      1.0
    • skewXz

      public void skewXz(float factor)
      Adds a skew of factor on the X and Z axis to the given matrix.
      Parameters:
      factor - skew factor
      Since:
      1.0
    • skewYz

      public void skewYz(float factor)
      Adds a skew of factor on the Y and Z axis to the given matrix.
      Parameters:
      factor - skew factor
      Since:
      1.0
    • to2d

      public boolean to2d(Out<Double> xx, Out<Double> yx, Out<Double> xy, Out<Double> yy, Out<Double> x0, Out<Double> y0)

      Converts a graphene_matrix_t to an affine transformation matrix, if the given matrix is compatible.

      The returned values have the following layout:

        ⎛ xx  yx ⎞   ⎛  a   b  0 ⎞
        ⎜ xy  yy ⎟ = ⎜  c   d  0 ⎟
        ⎝ x0  y0 ⎠   ⎝ tx  ty  1 ⎠
      

      This function can be used to convert between a graphene_matrix_t and an affine matrix type from other libraries.

      Parameters:
      xx - return location for the xx member
      yx - return location for the yx member
      xy - return location for the xy member
      yy - return location for the yy member
      x0 - return location for the x0 member
      y0 - return location for the y0 member
      Returns:
      true if the matrix is compatible with an affine transformation matrix
      Since:
      1.0
    • toFloat

      public void toFloat(@Nullable Out<float[]> v)
      Converts a graphene_matrix_t to an array of floating point values.
      Parameters:
      v - return location for an array of floating point values. The array must be capable of holding at least 16 values.
      Since:
      1.0
    • transformBounds

      public void transformBounds(Rect r, Rect res)

      Transforms each corner of a graphene_rect_t using the given matrix m.

      The result is the axis aligned bounding rectangle containing the coplanar quadrilateral.

      See also: graphene_matrix_transform_point()

      Parameters:
      r - a graphene_rect_t
      res - return location for the bounds of the transformed rectangle
      Since:
      1.0
    • transformBox

      public void transformBox(Box b, Box res)

      Transforms the vertices of a graphene_box_t using the given matrix m.

      The result is the axis aligned bounding box containing the transformed vertices.

      Parameters:
      b - a graphene_box_t
      res - return location for the bounds of the transformed box
      Since:
      1.2
    • transformPoint

      public void transformPoint(Point p, Point res)

      Transforms the given graphene_point_t using the matrix m.

      Unlike graphene_matrix_transform_vec3(), this function will take into account the fourth row vector of the graphene_matrix_t when computing the dot product of each row vector of the matrix.

      See also: graphene_simd4x4f_point3_mul()

      Parameters:
      p - a graphene_point_t
      res - return location for the transformed graphene_point_t
      Since:
      1.0
    • transformPoint3d

      public void transformPoint3d(Point3D p, Point3D res)

      Transforms the given graphene_point3d_t using the matrix m.

      Unlike graphene_matrix_transform_vec3(), this function will take into account the fourth row vector of the graphene_matrix_t when computing the dot product of each row vector of the matrix.

      See also: graphene_simd4x4f_point3_mul()

      Parameters:
      p - a graphene_point3d_t
      res - return location for the result
      Since:
      1.2
    • transformRay

      public void transformRay(Ray r, Ray res)
      Transform a graphene_ray_t using the given matrix m.
      Parameters:
      r - a graphene_ray_t
      res - return location for the transformed ray
      Since:
      1.4
    • transformRect

      public void transformRect(Rect r, Quad res)

      Transforms each corner of a graphene_rect_t using the given matrix m.

      The result is a coplanar quadrilateral.

      See also: graphene_matrix_transform_point()

      Parameters:
      r - a graphene_rect_t
      res - return location for the transformed quad
      Since:
      1.0
    • transformSphere

      public void transformSphere(Sphere s, Sphere res)
      Transforms a graphene_sphere_t using the given matrix m. The result is the bounding sphere containing the transformed sphere.
      Parameters:
      s - a graphene_sphere_t
      res - return location for the bounds of the transformed sphere
      Since:
      1.2
    • transformVec3

      public void transformVec3(Vec3 v, Vec3 res)

      Transforms the given graphene_vec3_t using the matrix m.

      This function will multiply the X, Y, and Z row vectors of the matrix this Matrix with the corresponding components of the vector v. The W row vector will be ignored.

      See also: graphene_simd4x4f_vec3_mul()

      Parameters:
      v - a graphene_vec3_t
      res - return location for a graphene_vec3_t
      Since:
      1.0
    • transformVec4

      public void transformVec4(Vec4 v, Vec4 res)

      Transforms the given graphene_vec4_t using the matrix m.

      See also: graphene_simd4x4f_vec4_mul()

      Parameters:
      v - a graphene_vec4_t
      res - return location for a graphene_vec4_t
      Since:
      1.0
    • translate

      public void translate(Point3D pos)

      Adds a translation transformation to this Matrix using the coordinates of the given graphene_point3d_t.

      This is the equivalent of calling graphene_matrix_init_translate() and then multiplying this Matrix with the translation matrix.

      Parameters:
      pos - a graphene_point3d_t
      Since:
      1.0
    • transpose

      public void transpose(Matrix res)
      Transposes the given matrix.
      Parameters:
      res - return location for the transposed matrix
      Since:
      1.0
    • unprojectPoint3d

      public void unprojectPoint3d(Matrix modelview, Point3D point, Point3D res)
      Unprojects the given point using the this Matrix matrix and a modelview matrix.
      Parameters:
      modelview - a graphene_matrix_t for the modelview matrix; this is the inverse of the modelview used when projecting the point
      point - a graphene_point3d_t with the coordinates of the point
      res - return location for the unprojected point
      Since:
      1.2
    • untransformBounds

      public void untransformBounds(Rect r, Rect bounds, Rect res)
      Undoes the transformation on the corners of a graphene_rect_t using the given matrix, within the given axis aligned rectangular bounds.
      Parameters:
      r - a graphene_rect_t
      bounds - the bounds of the transformation
      res - return location for the untransformed rectangle
      Since:
      1.0
    • untransformPoint

      public boolean untransformPoint(Point p, Rect bounds, Point res)
      Undoes the transformation of a graphene_point_t using the given matrix, within the given axis aligned rectangular bounds.
      Parameters:
      p - a graphene_point_t
      bounds - the bounds of the transformation
      res - return location for the untransformed point
      Returns:
      true if the point was successfully untransformed
      Since:
      1.0