Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GrapheneMatrixLayout

[12:14] static extends: object

Generated struct layout helper for GIR record Matrix.

Methods

  • layout ()

    Returns the Panama struct layout for Matrix.

class: GrapheneMatrix

[29:7] extends: object

A structure capable of holding a 4x4 matrix. The contents of the #graphene_matrix_t structure are private and should never be accessed directly.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • GrapheneMatrix (Handle = null)

    Allocates a new #graphene_matrix_t.

    • @p Handle is an optional native handle or wrapper whose handle to adopt; when the native constructor is called.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • decompose ()

    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.

    • @p translate is the translation vector.
    • @p scale is the scale vector.
    • @p rotate is the rotation quaternion.
    • @p shear is the shear vector.
    • @p perspective is the perspective vector.
    • @r true if the matrix could be decomposed.
  • determinant ()

    Computes the determinant of the given matrix.

    • @r the value of the determinant.
  • equal (object b)

    Checks whether the two given #graphene_matrix_t matrices are equal.

    • @p b is a #graphene_matrix_t.
    • @r true if the two matrices are equal, and false otherwise.
  • equal_fast (object 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 } ]|

    • @p b is a #graphene_matrix_t.
    • @r true if the matrices are equal. and false otherwise.
  • free ()

    Frees the resources allocated by graphene_matrix_alloc().

    • @r None.
  • get_row (int index_)

    Retrieves the given row vector at @index_ inside a matrix.

    • @p index_ is the index of the row vector, between 0 and 3.
    • @p res is return location for the #graphene_vec4_t that is used to store the row vector.
    • @r None.
  • get_value (int row, int col)

    Retrieves the value at the given @row and @col index.

    • @p row is the row index.
    • @p col is the column index.
    • @r the value at the given indices.
  • get_x_scale ()

    Retrieves the scaling factor on the X axis in @m.

    • @r the value of the scaling factor.
  • get_x_translation ()

    Retrieves the translation component on the X axis from @m.

    • @r the translation component.
  • get_y_scale ()

    Retrieves the scaling factor on the Y axis in @m.

    • @r the value of the scaling factor.
  • get_y_translation ()

    Retrieves the translation component on the Y axis from @m.

    • @r the translation component.
  • get_z_scale ()

    Retrieves the scaling factor on the Z axis in @m.

    • @r the value of the scaling factor.
  • get_z_translation ()

    Retrieves the translation component on the Z axis from @m.

    • @r the translation component.
  • init_from_2d (double xx, double yx, double xy, double yy, double x_0, double y_0)

    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.

    • @p xx is the xx member.
    • @p yx is the yx member.
    • @p xy is the xy member.
    • @p yy is the yy member.
    • @p x_0 is the x0 member.
    • @p y_0 is the y0 member.
    • @r the initialized matrix.
  • init_from_float (list v)

    Initializes a #graphene_matrix_t with the given array of floating point values.

    • @p v is an array of at least 16 floating point values.
    • @r the initialized matrix.
  • init_from_matrix (object src)

    Initializes a #graphene_matrix_t using the values of the given matrix.

    • @p src is a #graphene_matrix_t.
    • @r the initialized matrix.
  • init_from_vec4 (object v0, object v1, object v2, object v3)

    Initializes a #graphene_matrix_t with the given four row vectors.

    • @p v0 is the first row vector.
    • @p v1 is the second row vector.
    • @p v2 is the third row vector.
    • @p v3 is the fourth row vector.
    • @r the initialized matrix.
  • init_frustum (double left, double right, double bottom, double top, double z_near, double z_far)

    Initializes a #graphene_matrix_t compatible with #graphene_frustum_t. See also: graphene_frustum_init_from_matrix()

    • @p left is distance of the left clipping plane.
    • @p right is distance of the right clipping plane.
    • @p bottom is distance of the bottom clipping plane.
    • @p top is distance of the top clipping plane.
    • @p z_near is distance of the near clipping plane.
    • @p z_far is distance of the far clipping plane.
    • @r the initialized matrix.
  • init_identity ()

    Initializes a #graphene_matrix_t with the identity matrix.

    • @r the initialized matrix.
  • init_look_at (object eye, object center, object 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 @m to transform a model of such a camera into world-space. However, it is more common to use the inverse of @m 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.

    • @p eye is the vector describing the position to look from.
    • @p center is the vector describing the position to look at.
    • @p up is the vector describing the world's upward direction; usually, this is the graphene_vec3_y_axis() vector.
    • @r the initialized matrix.
  • init_ortho (double left, double right, double top, double bottom, double z_near, double z_far)

    Initializes a #graphene_matrix_t with an orthographic projection.

    • @p left is the left edge of the clipping plane.
    • @p right is the right edge of the clipping plane.
    • @p top is the top edge of the clipping plane.
    • @p bottom is the bottom edge of the clipping plane.
    • @p z_near is the distance of the near clipping plane.
    • @p z_far is the distance of the far clipping plane.
    • @r the initialized matrix.
  • init_perspective (double fovy, double aspect, double z_near, double z_far)

    Initializes a #graphene_matrix_t with a perspective projection.

    • @p fovy is the field of view angle, in degrees.
    • @p aspect is the aspect value.
    • @p z_near is the near Z plane.
    • @p z_far is the far Z plane.
    • @r the initialized matrix.
  • init_rotate (double angle, object axis)

    Initializes @m to represent a rotation of @angle degrees on the axis represented by the @axis vector.

    • @p angle is the rotation angle, in degrees.
    • @p axis is the axis vector as a #graphene_vec3_t.
    • @r the initialized matrix.
  • init_scale (double x, double y, double z)

    Initializes a #graphene_matrix_t with the given scaling factors.

    • @p x is the scale factor on the X axis.
    • @p y is the scale factor on the Y axis.
    • @p z is the scale factor on the Z axis.
    • @r the initialized matrix.
  • init_skew (double x_skew, double y_skew)

    Initializes a #graphene_matrix_t with a skew transformation with the given factors.

    • @p x_skew is skew factor, in radians, on the X axis.
    • @p y_skew is skew factor, in radians, on the Y axis.
    • @r the initialized matrix.
  • init_translate (object p)

    Initializes a #graphene_matrix_t with a translation to the given coordinates.

    • @p p is the translation coordinates.
    • @r the initialized matrix.
  • interpolate (object b, double factor)

    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.

    • @p b is a #graphene_matrix_t.
    • @p factor is the linear interpolation factor.
    • @p res is return location for the interpolated matrix.
    • @r None.
  • inverse ()

    Inverts the given matrix.

    • @p res is return location for the inverse matrix.
    • @r true if the matrix is invertible.
  • is_2d ()

    Checks whether the given #graphene_matrix_t is compatible with an a 2D affine transformation matrix.

    • @r true if the matrix is compatible with an affine transformation matrix.
  • is_backface_visible ()

    Checks whether a #graphene_matrix_t has a visible back face.

    • @r true if the back face of the matrix is visible.
  • is_identity ()

    Checks whether the given #graphene_matrix_t is the identity matrix.

    • @r true if the matrix is the identity matrix.
  • is_singular ()

    Checks whether a matrix is singular.

    • @r true if the matrix is singular.
  • multiply (object b)

    Multiplies two #graphene_matrix_t. Matrix multiplication is not commutative in general; the order of the factors matters. The product of this multiplication is (@a × @b)

    • @p b is a #graphene_matrix_t.
    • @p res is return location for the matrix result.
    • @r None.
  • near (object b, double epsilon)

    Compares the two given #graphene_matrix_t matrices and checks whether their values are within the given @epsilon of each other.

    • @p b is a #graphene_matrix_t.
    • @p epsilon is the threshold between the two matrices.
    • @r true if the two matrices are near each other, and false otherwise.
  • normalize ()

    Normalizes the given #graphene_matrix_t.

    • @p res is return location for the normalized matrix.
    • @r None.
  • perspective (double depth)

    Applies a perspective of @depth to the matrix.

    • @p depth is the depth of the perspective.
    • @p res is return location for the perspective matrix.
    • @r None.
  • 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.

    • @r None.
  • project_point (object p)

    Projects a #graphene_point_t using the matrix @m.

    • @p p is a #graphene_point_t.
    • @p res is return location for the projected point.
    • @r None.
  • project_rect_bounds (object r)

    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.

    • @p r is a #graphene_rect_t.
    • @p res is return location for the projected rectangle.
    • @r None.
  • rotate (double angle, object 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 @m with the rotation matrix.

    • @p angle is the rotation angle, in degrees.
    • @p axis is the rotation axis, as a #graphene_vec3_t.
    • @r None.
  • rotate_euler (object e)

    Adds a rotation transformation to @m, using the given #graphene_euler_t.

    • @p e is a rotation described by a #graphene_euler_t.
    • @r None.
  • rotate_quaternion (object 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 @m with the rotation matrix.

    • @p q is a rotation described by a #graphene_quaternion_t.
    • @r None.
  • rotate_x (double angle)

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

    • @angle. See also: graphene_matrix_rotate()
    • @p angle is the rotation angle, in degrees.
    • @r None.
  • rotate_y (double angle)

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

    • @angle. See also: graphene_matrix_rotate()
    • @p angle is the rotation angle, in degrees.
    • @r None.
  • rotate_z (double angle)

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

    • @angle. See also: graphene_matrix_rotate()
    • @p angle is the rotation angle, in degrees.
    • @r None.
  • scale (double factor_x, double factor_y, double factor_z)

    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 @m with the scale matrix.

    • @p factor_x is scaling factor on the X axis.
    • @p factor_y is scaling factor on the Y axis.
    • @p factor_z is scaling factor on the Z axis.
    • @r None.
  • skew_xy (double factor)

    Adds a skew of @factor on the X and Y axis to the given matrix.

    • @p factor is skew factor.
    • @r None.
  • skew_xz (double factor)

    Adds a skew of @factor on the X and Z axis to the given matrix.

    • @p factor is skew factor.
    • @r None.
  • skew_yz (double factor)

    Adds a skew of @factor on the Y and Z axis to the given matrix.

    • @p factor is skew factor.
    • @r None.
  • to_2d ()

    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.

    • @p xx is return location for the xx member.
    • @p yx is return location for the yx member.
    • @p xy is return location for the xy member.
    • @p yy is return location for the yy member.
    • @p x_0 is return location for the x0 member.
    • @p y_0 is return location for the y0 member.
    • @r true if the matrix is compatible with an affine transformation matrix.
  • to_float ()

    Converts a #graphene_matrix_t to an array of floating point values.

    • @p v is return location for an array of floating point values. The array must be capable of holding at least 16 values..
    • @r None.
  • transform_bounds (object r)

    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()

    • @p r is a #graphene_rect_t.
    • @p res is return location for the bounds of the transformed rectangle.
    • @r None.
  • transform_box (object b)

    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.

    • @p b is a #graphene_box_t.
    • @p res is return location for the bounds of the transformed box.
    • @r None.
  • transform_point (object p)

    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()

    • @p p is a #graphene_point_t.
    • @p res is return location for the transformed #graphene_point_t.
    • @r None.
  • transform_point3d (object p)

    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()

    • @p p is a #graphene_point3d_t.
    • @p res is return location for the result.
    • @r None.
  • transform_ray (object r)

    Transform a #graphene_ray_t using the given matrix @m.

    • @p r is a #graphene_ray_t.
    • @p res is return location for the transformed ray.
    • @r None.
  • transform_sphere (object s)

    Transforms a #graphene_sphere_t using the given matrix @m. The result is the bounding sphere containing the transformed sphere.

    • @p s is a #graphene_sphere_t.
    • @p res is return location for the bounds of the transformed sphere.
    • @r None.
  • transform_vec3 (object v)

    Transforms the given #graphene_vec3_t using the matrix @m. This function will multiply the X, Y, and Z row vectors of the matrix @m with the corresponding components of the vector @v. The W row vector will be ignored. See also: graphene_simd4x4f_vec3_mul()

    • @p v is a #graphene_vec3_t.
    • @p res is return location for a #graphene_vec3_t.
    • @r None.
  • transform_vec4 (object v)

    Transforms the given #graphene_vec4_t using the matrix @m. See also: graphene_simd4x4f_vec4_mul()

    • @p v is a #graphene_vec4_t.
    • @p res is return location for a #graphene_vec4_t.
    • @r None.
  • translate (object pos)

    Adds a translation transformation to @m using the coordinates of the given #graphene_point3d_t. This is the equivalent of calling graphene_matrix_init_translate() and then multiplying @m with the translation matrix.

    • @p pos is a #graphene_point3d_t.
    • @r None.
  • transpose ()

    Transposes the given matrix.

    • @p res is return location for the transposed matrix.
    • @r None.
  • unproject_point3d (object modelview, object point)

    Unprojects the given @point using the @projection matrix and a @modelview matrix.

    • @p modelview is a #graphene_matrix_t for the modelview matrix; this is the inverse of the modelview used when projecting the point.
    • @p point is a #graphene_point3d_t with the coordinates of the point.
    • @p res is return location for the unprojected point.
    • @r None.
  • untransform_bounds (object r, object bounds)

    Undoes the transformation on the corners of a #graphene_rect_t using the given matrix, within the given axis aligned rectangular @bounds.

    • @p r is a #graphene_rect_t.
    • @p bounds is the bounds of the transformation.
    • @p res is return location for the untransformed rectangle.
    • @r None.
  • untransform_point (object p, object bounds)

    Undoes the transformation of a #graphene_point_t using the given matrix, within the given axis aligned rectangular @bounds.

    • @p p is a #graphene_point_t.
    • @p bounds is the bounds of the transformation.
    • @p res is return location for the untransformed point.
    • @r true if the point was successfully untransformed.