package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.graphene/Ocgtk_graphene/Graphene/Wrappers/Matrix/index.html

Module Wrappers.Matrix

type t = [ `matrix ] Gobject.obj
val alloc : unit -> t

Create a new Matrix

val untransform_point : t -> [ `point ] Gobject.obj -> [ `rect ] Gobject.obj -> bool * [ `point ] Gobject.obj

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

val untransform_bounds : t -> [ `rect ] Gobject.obj -> [ `rect ] Gobject.obj -> [ `rect ] Gobject.obj

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

val unproject_point3d : t -> t -> [ `point3_d ] Gobject.obj -> [ `point3_d ] Gobject.obj

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

val transpose : t -> t

Transposes the given matrix.

val translate : t -> [ `point3_d ] Gobject.obj -> unit

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.

val transform_vec4 : t -> [ `vec4 ] Gobject.obj -> [ `vec4 ] Gobject.obj

Transforms the given #graphene_vec4_t using the matrix @m.

See also: graphene_simd4x4f_vec4_mul()

val transform_vec3 : t -> [ `vec3 ] Gobject.obj -> [ `vec3 ] Gobject.obj

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

val transform_sphere : t -> [ `sphere ] Gobject.obj -> [ `sphere ] Gobject.obj

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

val transform_rect : t -> [ `rect ] Gobject.obj -> [ `quad ] Gobject.obj

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

val transform_ray : t -> [ `ray ] Gobject.obj -> [ `ray ] Gobject.obj

Transform a #graphene_ray_t using the given matrix @m.

val transform_point3d : t -> [ `point3_d ] Gobject.obj -> [ `point3_d ] Gobject.obj

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

val transform_point : t -> [ `point ] Gobject.obj -> [ `point ] Gobject.obj

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

val transform_box : t -> [ `box ] Gobject.obj -> [ `box ] Gobject.obj

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.

val transform_bounds : t -> [ `rect ] Gobject.obj -> [ `rect ] Gobject.obj

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

val to_float : t -> float array

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

val to_2d : t -> bool * float * float * float * float * float * float

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

The returned values have the following layout:

|<!-- language="plain" --> ⎛ 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.

val skew_yz : t -> float -> unit

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

val skew_xz : t -> float -> unit

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

val skew_xy : t -> float -> unit

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

val scale : t -> float -> float -> float -> unit

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.

val rotate_z : t -> float -> unit

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

See also: graphene_matrix_rotate()

val rotate_y : t -> float -> unit

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

See also: graphene_matrix_rotate()

val rotate_x : t -> float -> unit

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

See also: graphene_matrix_rotate()

val rotate_quaternion : t -> [ `quaternion ] Gobject.obj -> unit

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.

val rotate_euler : t -> [ `euler ] Gobject.obj -> unit

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

val rotate : t -> float -> [ `vec3 ] Gobject.obj -> unit

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.

val project_rect_bounds : t -> [ `rect ] Gobject.obj -> [ `rect ] Gobject.obj

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.

val project_rect : t -> [ `rect ] Gobject.obj -> [ `quad ] Gobject.obj

Projects all corners of a #graphene_rect_t using the given matrix.

See also: graphene_matrix_project_point()

val project_point : t -> [ `point ] Gobject.obj -> [ `point ] Gobject.obj

Projects a #graphene_point_t using the matrix @m.

val print : t -> unit

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.

val perspective : t -> float -> t

Applies a perspective of @depth to the matrix.

val normalize : t -> t

Normalizes the given #graphene_matrix_t.

val near : t -> t -> float -> bool

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

val multiply : t -> t -> t

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)

val is_singular : t -> bool

Checks whether a matrix is singular.

val is_identity : t -> bool

Checks whether the given #graphene_matrix_t is the identity matrix.

val is_backface_visible : t -> bool

Checks whether a #graphene_matrix_t has a visible back face.

val is_2d : t -> bool

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

val inverse : t -> bool * t

Inverts the given matrix.

val interpolate : t -> t -> float -> t

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.

val init_translate : t -> [ `point3_d ] Gobject.obj -> t

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

val init_skew : t -> float -> float -> t

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

val init_scale : t -> float -> float -> float -> t

Initializes a #graphene_matrix_t with the given scaling factors.

val init_rotate : t -> float -> [ `vec3 ] Gobject.obj -> t

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

val init_perspective : t -> float -> float -> float -> float -> t

Initializes a #graphene_matrix_t with a perspective projection.

val init_ortho : t -> float -> float -> float -> float -> float -> float -> t

Initializes a #graphene_matrix_t with an orthographic projection.

val init_look_at : t -> [ `vec3 ] Gobject.obj -> [ `vec3 ] Gobject.obj -> [ `vec3 ] Gobject.obj -> t

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.

val init_identity : t -> t

Initializes a #graphene_matrix_t with the identity matrix.

val init_frustum : t -> float -> float -> float -> float -> float -> float -> t

Initializes a #graphene_matrix_t compatible with #graphene_frustum_t.

See also: graphene_frustum_init_from_matrix()

val init_from_vec4 : t -> [ `vec4 ] Gobject.obj -> [ `vec4 ] Gobject.obj -> [ `vec4 ] Gobject.obj -> [ `vec4 ] Gobject.obj -> t

Initializes a #graphene_matrix_t with the given four row vectors.

val init_from_matrix : t -> t -> t

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

val init_from_float : t -> float array -> t

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

val init_from_2d : t -> float -> float -> float -> float -> float -> float -> t

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

The arguments map to the following matrix layout:

|<!-- language="plain" --> ⎛ 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.

val get_z_translation : t -> float

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

val get_z_scale : t -> float

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

val get_y_translation : t -> float

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

val get_y_scale : t -> float

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

val get_x_translation : t -> float

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

val get_x_scale : t -> float

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

val get_value : t -> int -> int -> float

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

val get_row : t -> int -> [ `vec4 ] Gobject.obj

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

val equal_fast : t -> t -> bool

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:

|<!-- language="C" --> 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 } |

val equal : t -> t -> bool

Checks whether the two given #graphene_matrix_t matrices are equal.

val determinant : t -> float

Computes the determinant of the given matrix.

val decompose : t -> bool * [ `vec3 ] Gobject.obj * [ `vec3 ] Gobject.obj * [ `quaternion ] Gobject.obj * [ `vec3 ] Gobject.obj * [ `vec4 ] Gobject.obj

Decomposes a transformation matrix into its component transformations.

The algorithm for decomposing a matrix is taken from the CSS3 Transforms specification(http://dev.w3.org/csswg/css-transforms/); specifically, the decomposition code is based on the equivalent code published in "Graphics Gems II", edited by Jim Arvo, and available online(http://web.archive.org/web/20150512160205/http://tog.acm.org/resources/GraphicsGems/gemsii/unmatrix.c).