A 3D box, described as the volume between a minimum and
a maximum vertices.
Allocates a new #graphene_box_t.
The contents of the returned structure are undefined.
the newly allocated #graphene_box_t structure.
Use graphene_box_free() to free the resources allocated by this function
Checks whether the #graphene_box_t @a contains the given
#graphene_box_t @b.
`true` if the box is contained in the given box
a #graphene_box_t
a #graphene_box_t
Checks whether @box contains the given @point.
`true` if the point is contained in the given box
a #graphene_box_t
the coordinates to check
Checks whether the two given boxes are equal.
`true` if the boxes are equal
a #graphene_box_t
a #graphene_box_t
Expands the dimensions of @box to include the coordinates at @point.
a #graphene_box_t
the coordinates of the point to include
return location for the expanded box
Expands the dimensions of @box by the given @scalar value.
If @scalar is positive, the #graphene_box_t will grow; if @scalar is
negative, the #graphene_box_t will shrink.
a #graphene_box_t
a scalar value
return location for the expanded box
Expands the dimensions of @box to include the coordinates of the
given vector.
a #graphene_box_t
the coordinates of the point to include, as a #graphene_vec3_t
return location for the expanded box
Frees the resources allocated by graphene_box_alloc().
a #graphene_box_t
Computes the bounding #graphene_sphere_t capable of containing the given
#graphene_box_t.
a #graphene_box_t
return location for the bounding sphere
Retrieves the coordinates of the center of a #graphene_box_t.
a #graphene_box_t
return location for the coordinates of
the center
Retrieves the size of the @box on the Z axis.
the depth of the box
a #graphene_box_t
Retrieves the size of the @box on the Y axis.
the height of the box
a #graphene_box_t
Retrieves the coordinates of the maximum point of the given
#graphene_box_t.
a #graphene_box_t
return location for the maximum point
Retrieves the coordinates of the minimum point of the given
#graphene_box_t.
a #graphene_box_t
return location for the minimum point
Retrieves the size of the box on all three axes, and stores
it into the given @size vector.
a #graphene_box_t
return location for the size
Computes the vertices of the given #graphene_box_t.
a #graphene_box_t
return location for an array
of 8 #graphene_vec3_t
Retrieves the size of the @box on the X axis.
the width of the box
a #graphene_box_t
Initializes the given #graphene_box_t with two vertices.
the initialized #graphene_box_t
the #graphene_box_t to initialize
the coordinates of the minimum vertex
the coordinates of the maximum vertex
Initializes the given #graphene_box_t with the vertices of
another #graphene_box_t.
the initialized #graphene_box_t
the #graphene_box_t to initialize
a #graphene_box_t
Initializes the given #graphene_box_t with the given array
of vertices.
If @n_points is 0, the returned box is initialized with
graphene_box_empty().
the initialized #graphene_box_t
the #graphene_box_t to initialize
the number #graphene_point3d_t in the @points array
an array of #graphene_point3d_t
Initializes the given #graphene_box_t with two vertices
stored inside #graphene_vec3_t.
the initialized #graphene_box_t
the #graphene_box_t to initialize
the coordinates of the minimum vertex
the coordinates of the maximum vertex
Initializes the given #graphene_box_t with the given array
of vertices.
If @n_vectors is 0, the returned box is initialized with
graphene_box_empty().
the initialized #graphene_box_t
the #graphene_box_t to initialize
the number #graphene_point3d_t in the @vectors array
an array of #graphene_vec3_t
Intersects the two given #graphene_box_t.
If the two boxes do not intersect, @res will contain a degenerate box
initialized with graphene_box_empty().
true if the two boxes intersect
a #graphene_box_t
a #graphene_box_t
return location for the result
Unions the two given #graphene_box_t.
a #graphene_box_t
the box to union to @a
return location for the result
A degenerate #graphene_box_t that can only be expanded.
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A degenerate #graphene_box_t that cannot be expanded.
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A #graphene_box_t with the minimum vertex set at (-1, -1, -1) and the
maximum vertex set at (0, 0, 0).
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A #graphene_box_t with the minimum vertex set at (0, 0, 0) and the
maximum vertex set at (1, 1, 1).
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A #graphene_box_t with the minimum vertex set at (-1, -1, -1) and the
maximum vertex set at (1, 1, 1).
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A #graphene_box_t with both the minimum and maximum vertices set at (0, 0, 0).
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
Encodes the given components into a value that can be used for
version checks.
a major version
a minor version
a micro version
Describe a rotation using Euler angles.
The contents of the #graphene_euler_t structure are private
and should never be accessed directly.
Allocates a new #graphene_euler_t.
The contents of the returned structure are undefined.
the newly allocated #graphene_euler_t
Checks if two #graphene_euler_t are equal.
`true` if the two #graphene_euler_t are equal
a #graphene_euler_t
a #graphene_euler_t
Frees the resources allocated by graphene_euler_alloc().
a #graphene_euler_t
Retrieves the first component of the Euler angle vector,
depending on the order of rotation.
See also: graphene_euler_get_x()
the first component of the Euler angle vector, in radians
a #graphene_euler_t
Retrieves the second component of the Euler angle vector,
depending on the order of rotation.
See also: graphene_euler_get_y()
the second component of the Euler angle vector, in radians
a #graphene_euler_t
Retrieves the third component of the Euler angle vector,
depending on the order of rotation.
See also: graphene_euler_get_z()
the third component of the Euler angle vector, in radians
a #graphene_euler_t
Retrieves the order used to apply the rotations described in the
#graphene_euler_t structure, when converting to and from other
structures, like #graphene_quaternion_t and #graphene_matrix_t.
This function does not return the %GRAPHENE_EULER_ORDER_DEFAULT
enumeration value; it will return the effective order of rotation
instead.
the order used to apply the rotations
a #graphene_euler_t
Retrieves the rotation angle on the X axis, in degrees.
the rotation angle
a #graphene_euler_t
Retrieves the rotation angle on the Y axis, in degrees.
the rotation angle
a #graphene_euler_t
Retrieves the rotation angle on the Z axis, in degrees.
the rotation angle
a #graphene_euler_t
Initializes a #graphene_euler_t using the given angles.
The order of the rotations is %GRAPHENE_EULER_ORDER_DEFAULT.
the initialized #graphene_euler_t
the #graphene_euler_t to initialize
rotation angle on the X axis, in degrees
rotation angle on the Y axis, in degrees
rotation angle on the Z axis, in degrees
Initializes a #graphene_euler_t using the angles and order of
another #graphene_euler_t.
If the #graphene_euler_t @src is %NULL, this function is equivalent
to calling graphene_euler_init() with all angles set to 0.
the initialized #graphene_euler_t
the #graphene_euler_t to initialize
a #graphene_euler_t
Initializes a #graphene_euler_t using the given rotation matrix.
If the #graphene_matrix_t @m is %NULL, the #graphene_euler_t will
be initialized with all angles set to 0.
the initialized #graphene_euler_t
the #graphene_euler_t to initialize
a rotation matrix
the order used to apply the rotations
Initializes a #graphene_euler_t using the given normalized quaternion.
If the #graphene_quaternion_t @q is %NULL, the #graphene_euler_t will
be initialized with all angles set to 0.
the initialized #graphene_euler_t
a #graphene_euler_t
a normalized #graphene_quaternion_t
the order used to apply the rotations
Initializes a #graphene_euler_t using the given angles
and order of rotation.
the initialized #graphene_euler_t
the #graphene_euler_t to initialize
rotation angle on the X axis, in radians
rotation angle on the Y axis, in radians
rotation angle on the Z axis, in radians
order of rotations
Initializes a #graphene_euler_t using the angles contained in a
#graphene_vec3_t.
If the #graphene_vec3_t @v is %NULL, the #graphene_euler_t will be
initialized with all angles set to 0.
the initialized #graphene_euler_t
the #graphene_euler_t to initialize
a #graphene_vec3_t containing the rotation
angles in degrees
the order used to apply the rotations
Initializes a #graphene_euler_t with the given angles and @order.
the initialized #graphene_euler_t
the #graphene_euler_t to initialize
rotation angle on the X axis, in degrees
rotation angle on the Y axis, in degrees
rotation angle on the Z axis, in degrees
the order used to apply the rotations
Reorders a #graphene_euler_t using @order.
This function is equivalent to creating a #graphene_quaternion_t from the
given #graphene_euler_t, and then converting the quaternion into another
#graphene_euler_t.
a #graphene_euler_t
the new order
return location for the reordered
#graphene_euler_t
Converts a #graphene_euler_t into a transformation matrix expressing
the extrinsic composition of rotations described by the Euler angles.
The rotations are applied over the reference frame axes in the order
associated with the #graphene_euler_t; for instance, if the order
used to initialize @e is %GRAPHENE_EULER_ORDER_XYZ:
* the first rotation moves the body around the X axis with
an angle φ
* the second rotation moves the body around the Y axis with
an angle of ϑ
* the third rotation moves the body around the Z axis with
an angle of ψ
The rotation sign convention is right-handed, to preserve compatibility
between Euler-based, quaternion-based, and angle-axis-based rotations.
a #graphene_euler_t
return location for a #graphene_matrix_t
Converts a #graphene_euler_t into a #graphene_quaternion_t.
a #graphene_euler_t
return location for a #graphene_quaternion_t
Retrieves the angles of a #graphene_euler_t and initializes a
#graphene_vec3_t with them.
a #graphene_euler_t
return location for a #graphene_vec3_t
Specify the order of the rotations on each axis.
The %GRAPHENE_EULER_ORDER_DEFAULT value is special, and is used
as an alias for one of the other orders.
Rotate in the default order; the
default order is one of the following enumeration values
Rotate in the X, Y, and Z order. Deprecated in
Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SXYZ
Rotate in the Y, Z, and X order. Deprecated in
Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SYZX
Rotate in the Z, X, and Y order. Deprecated in
Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SZXY
Rotate in the X, Z, and Y order. Deprecated in
Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SXZY
Rotate in the Y, X, and Z order. Deprecated in
Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SYXZ
Rotate in the Z, Y, and X order. Deprecated in
Graphene 1.10, it's an alias for %GRAPHENE_EULER_ORDER_SZYX
Defines a static rotation along the X, Y, and Z axes (Since: 1.10)
Defines a static rotation along the X, Y, and X axes (Since: 1.10)
Defines a static rotation along the X, Z, and Y axes (Since: 1.10)
Defines a static rotation along the X, Z, and X axes (Since: 1.10)
Defines a static rotation along the Y, Z, and X axes (Since: 1.10)
Defines a static rotation along the Y, Z, and Y axes (Since: 1.10)
Defines a static rotation along the Y, X, and Z axes (Since: 1.10)
Defines a static rotation along the Y, X, and Y axes (Since: 1.10)
Defines a static rotation along the Z, X, and Y axes (Since: 1.10)
Defines a static rotation along the Z, X, and Z axes (Since: 1.10)
Defines a static rotation along the Z, Y, and X axes (Since: 1.10)
Defines a static rotation along the Z, Y, and Z axes (Since: 1.10)
Defines a relative rotation along the Z, Y, and X axes (Since: 1.10)
Defines a relative rotation along the X, Y, and X axes (Since: 1.10)
Defines a relative rotation along the Y, Z, and X axes (Since: 1.10)
Defines a relative rotation along the X, Z, and X axes (Since: 1.10)
Defines a relative rotation along the X, Z, and Y axes (Since: 1.10)
Defines a relative rotation along the Y, Z, and Y axes (Since: 1.10)
Defines a relative rotation along the Z, X, and Y axes (Since: 1.10)
Defines a relative rotation along the Y, X, and Y axes (Since: 1.10)
Defines a relative rotation along the Y, X, and Z axes (Since: 1.10)
Defines a relative rotation along the Z, X, and Z axes (Since: 1.10)
Defines a relative rotation along the X, Y, and Z axes (Since: 1.10)
Defines a relative rotation along the Z, Y, and Z axes (Since: 1.10)
A 3D volume delimited by 2D clip planes.
The contents of the `graphene_frustum_t` are private, and should not be
modified directly.
Allocates a new #graphene_frustum_t structure.
The contents of the returned structure are undefined.
the newly allocated #graphene_frustum_t
structure. Use graphene_frustum_free() to free the resources
allocated by this function.
Checks whether a point is inside the volume defined by the given
#graphene_frustum_t.
`true` if the point is inside the frustum
a #graphene_frustum_t
a #graphene_point3d_t
Checks whether the two given #graphene_frustum_t are equal.
`true` if the given frustums are equal
a #graphene_frustum_t
a #graphene_frustum_t
Frees the resources allocated by graphene_frustum_alloc().
a #graphene_frustum_t
Retrieves the planes that define the given #graphene_frustum_t.
a #graphene_frustum_t
return location for an array
of 6 #graphene_plane_t
Initializes the given #graphene_frustum_t using the provided
clipping planes.
the initialized frustum
the #graphene_frustum_t to initialize
a clipping plane
a clipping plane
a clipping plane
a clipping plane
a clipping plane
a clipping plane
Initializes the given #graphene_frustum_t using the clipping
planes of another #graphene_frustum_t.
the initialized frustum
the #graphene_frustum_t to initialize
a #graphene_frustum_t
Initializes a #graphene_frustum_t using the given @matrix.
the initialized frustum
a #graphene_frustum_t
a #graphene_matrix_t
Checks whether the given @box intersects a plane of
a #graphene_frustum_t.
`true` if the box intersects the frustum
a #graphene_frustum_t
a #graphene_box_t
Checks whether the given @sphere intersects a plane of
a #graphene_frustum_t.
`true` if the sphere intersects the frustum
a #graphene_frustum_t
a #graphene_sphere_t
A structure capable of holding a 4x4 matrix.
The contents of the #graphene_matrix_t structure are private and
should never be accessed directly.
Allocates a new #graphene_matrix_t.
the newly allocated matrix
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).
`true` if the matrix could be decomposed
a #graphene_matrix_t
the translation vector
the scale vector
the rotation quaternion
the shear vector
the perspective vector
Computes the determinant of the given matrix.
the value of the determinant
a #graphene_matrix_t
Checks whether the two given #graphene_matrix_t matrices are equal.
`true` if the two matrices are equal, and `false` otherwise
a #graphene_matrix_t
a #graphene_matrix_t
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
}
]|
`true` if the matrices are equal. and `false` otherwise
a #graphene_matrix_t
a #graphene_matrix_t
Frees the resources allocated by graphene_matrix_alloc().
a #graphene_matrix_t
Retrieves the given row vector at @index_ inside a matrix.
a #graphene_matrix_t
the index of the row vector, between 0 and 3
return location for the #graphene_vec4_t
that is used to store the row vector
Retrieves the value at the given @row and @col index.
the value at the given indices
a #graphene_matrix_t
the row index
the column index
Retrieves the scaling factor on the X axis in @m.
the value of the scaling factor
a #graphene_matrix_t
Retrieves the translation component on the X axis from @m.
the translation component
a #graphene_matrix_t
Retrieves the scaling factor on the Y axis in @m.
the value of the scaling factor
a #graphene_matrix_t
Retrieves the translation component on the Y axis from @m.
the translation component
a #graphene_matrix_t
Retrieves the scaling factor on the Z axis in @m.
the value of the scaling factor
a #graphene_matrix_t
Retrieves the translation component on the Z axis from @m.
the translation component
a #graphene_matrix_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.
the initialized matrix
a #graphene_matrix_t
the xx member
the yx member
the xy member
the yy member
the x0 member
the y0 member
Initializes a #graphene_matrix_t with the given array of floating
point values.
the initialized matrix
a #graphene_matrix_t
an array of at least 16 floating
point values
Initializes a #graphene_matrix_t using the values of the
given matrix.
the initialized matrix
a #graphene_matrix_t
a #graphene_matrix_t
Initializes a #graphene_matrix_t with the given four row
vectors.
the initialized matrix
a #graphene_matrix_t
the first row vector
the second row vector
the third row vector
the fourth row vector
Initializes a #graphene_matrix_t compatible with #graphene_frustum_t.
See also: graphene_frustum_init_from_matrix()
the initialized matrix
a #graphene_matrix_t
distance of the left clipping plane
distance of the right clipping plane
distance of the bottom clipping plane
distance of the top clipping plane
distance of the near clipping plane
distance of the far clipping plane
Initializes a #graphene_matrix_t with the identity matrix.
the initialized matrix
a #graphene_matrix_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.
the initialized matrix
a #graphene_matrix_t
the vector describing the position to look from
the vector describing the position to look at
the vector describing the world's upward direction; usually,
this is the graphene_vec3_y_axis() vector
Initializes a #graphene_matrix_t with an orthographic projection.
the initialized matrix
a #graphene_matrix_t
the left edge of the clipping plane
the right edge of the clipping plane
the top edge of the clipping plane
the bottom edge of the clipping plane
the distance of the near clipping plane
the distance of the far clipping plane
Initializes a #graphene_matrix_t with a perspective projection.
the initialized matrix
a #graphene_matrix_t
the field of view angle, in degrees
the aspect value
the near Z plane
the far Z plane
Initializes @m to represent a rotation of @angle degrees on
the axis represented by the @axis vector.
the initialized matrix
a #graphene_matrix_t
the rotation angle, in degrees
the axis vector as a #graphene_vec3_t
Initializes a #graphene_matrix_t with the given scaling factors.
the initialized matrix
a #graphene_matrix_t
the scale factor on the X axis
the scale factor on the Y axis
the scale factor on the Z axis
Initializes a #graphene_matrix_t with a skew transformation
with the given factors.
the initialized matrix
a #graphene_matrix_t
skew factor, in radians, on the X axis
skew factor, in radians, on the Y axis
Initializes a #graphene_matrix_t with a translation to the
given coordinates.
the initialized matrix
a #graphene_matrix_t
the translation coordinates
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.
a #graphene_matrix_t
a #graphene_matrix_t
the linear interpolation factor
return location for the
interpolated matrix
Inverts the given matrix.
`true` if the matrix is invertible
a #graphene_matrix_t
return location for the
inverse matrix
Checks whether the given #graphene_matrix_t is compatible with an
a 2D affine transformation matrix.
`true` if the matrix is compatible with an affine
transformation matrix
a #graphene_matrix_t
Checks whether a #graphene_matrix_t has a visible back face.
`true` if the back face of the matrix is visible
a #graphene_matrix_t
Checks whether the given #graphene_matrix_t is the identity matrix.
`true` if the matrix is the identity matrix
a #graphene_matrix_t
Checks whether a matrix is singular.
`true` if the matrix is singular
a #graphene_matrix_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)
a #graphene_matrix_t
a #graphene_matrix_t
return location for the matrix
result
Compares the two given #graphene_matrix_t matrices and checks
whether their values are within the given @epsilon of each
other.
`true` if the two matrices are near each other, and
`false` otherwise
a #graphene_matrix_t
a #graphene_matrix_t
the threshold between the two matrices
Normalizes the given #graphene_matrix_t.
a #graphene_matrix_t
return location for the normalized matrix
Applies a perspective of @depth to the matrix.
a #graphene_matrix_t
the depth of the perspective
return location for the
perspective matrix
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.
The matrix to print
Projects a #graphene_point_t using the matrix @m.
a #graphene_matrix_t
a #graphene_point_t
return location for the projected
point
Projects all corners of a #graphene_rect_t using the given matrix.
See also: graphene_matrix_project_point()
a #graphene_matrix_t
a #graphene_rect_t
return location for the projected
rectangle
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.
a #graphene_matrix_t
a #graphene_rect_t
return location for the projected
rectangle
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.
a #graphene_matrix_t
the rotation angle, in degrees
the rotation axis, as a #graphene_vec3_t
Adds a rotation transformation to @m, using the given
#graphene_euler_t.
a #graphene_matrix_t
a rotation described by a #graphene_euler_t
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.
a #graphene_matrix_t
a rotation described by a #graphene_quaternion_t
Adds a rotation transformation around the X axis to @m, using
the given @angle.
See also: graphene_matrix_rotate()
a #graphene_matrix_t
the rotation angle, in degrees
Adds a rotation transformation around the Y axis to @m, using
the given @angle.
See also: graphene_matrix_rotate()
a #graphene_matrix_t
the rotation angle, in degrees
Adds a rotation transformation around the Z axis to @m, using
the given @angle.
See also: graphene_matrix_rotate()
a #graphene_matrix_t
the rotation angle, in degrees
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.
a #graphene_matrix_t
scaling factor on the X axis
scaling factor on the Y axis
scaling factor on the Z axis
Adds a skew of @factor on the X and Y axis to the given matrix.
a #graphene_matrix_t
skew factor
Adds a skew of @factor on the X and Z axis to the given matrix.
a #graphene_matrix_t
skew factor
Adds a skew of @factor on the Y and Z axis to the given matrix.
a #graphene_matrix_t
skew factor
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.
`true` if the matrix is compatible with an affine
transformation matrix
a #graphene_matrix_t
return location for the xx member
return location for the yx member
return location for the xy member
return location for the yy member
return location for the x0 member
return location for the y0 member
Converts a #graphene_matrix_t to an array of floating point
values.
a #graphene_matrix_t
return location
for an array of floating point values. The array must be capable
of holding at least 16 values.
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()
a #graphene_matrix_t
a #graphene_rect_t
return location for the bounds
of the transformed rectangle
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.
a #graphene_matrix_t
a #graphene_box_t
return location for the bounds
of the transformed box
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()
a #graphene_matrix_t
a #graphene_point_t
return location for the
transformed #graphene_point_t
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()
a #graphene_matrix_t
a #graphene_point3d_t
return location for the result
Transform a #graphene_ray_t using the given matrix @m.
a #graphene_matrix_t
a #graphene_ray_t
return location for the
transformed ray
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()
a #graphene_matrix_t
a #graphene_rect_t
return location for the
transformed quad
Transforms a #graphene_sphere_t using the given matrix @m. The
result is the bounding sphere containing the transformed sphere.
a #graphene_matrix_t
a #graphene_sphere_t
return location for the bounds
of the transformed sphere
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()
a #graphene_matrix_t
a #graphene_vec3_t
return location for a #graphene_vec3_t
Transforms the given #graphene_vec4_t using the matrix @m.
See also: graphene_simd4x4f_vec4_mul()
a #graphene_matrix_t
a #graphene_vec4_t
return location for a #graphene_vec4_t
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.
a #graphene_matrix_t
a #graphene_point3d_t
Transposes the given matrix.
a #graphene_matrix_t
return location for the
transposed matrix
Unprojects the given @point using the @projection matrix and
a @modelview matrix.
a #graphene_matrix_t for the projection matrix
a #graphene_matrix_t for the modelview matrix; this is
the inverse of the modelview used when projecting the point
a #graphene_point3d_t with the coordinates of the point
return location for the unprojected
point
Undoes the transformation on the corners of a #graphene_rect_t using the
given matrix, within the given axis aligned rectangular @bounds.
a #graphene_matrix_t
a #graphene_rect_t
the bounds of the transformation
return location for the
untransformed rectangle
Undoes the transformation of a #graphene_point_t using the
given matrix, within the given axis aligned rectangular @bounds.
`true` if the point was successfully untransformed
a #graphene_matrix_t
a #graphene_point_t
the bounds of the transformation
return location for the
untransformed point
Initializes a #graphene_point3d_t to the given coordinates when declaring it.
the X coordinate
the Y coordinate
the Z coordinate
Initializes a #graphene_point_t with the given coordinates
when declaring it, e.g:
|[<!-- language="C" -->
graphene_point_t p = GRAPHENE_POINT_INIT (10.f, 10.f);
]|
the X coordinate
the Y coordinate
A 2D plane that extends infinitely in a 3D volume.
The contents of the `graphene_plane_t` are private, and should not be
modified directly.
Allocates a new #graphene_plane_t structure.
The contents of the returned structure are undefined.
the newly allocated #graphene_plane_t.
Use graphene_plane_free() to free the resources allocated by
this function
Computes the distance of @point from a #graphene_plane_t.
the distance of the given #graphene_point3d_t from the plane
a #graphene_plane_t
a #graphene_point3d_t
Checks whether the two given #graphene_plane_t are equal.
`true` if the given planes are equal
a #graphene_plane_t
a #graphene_plane_t
Frees the resources allocated by graphene_plane_alloc().
a #graphene_plane_t
Retrieves the distance along the normal vector of the
given #graphene_plane_t from the origin.
the constant value of the plane
a #graphene_plane_t
Retrieves the normal vector pointing towards the origin of the
given #graphene_plane_t.
a #graphene_plane_t
return location for the normal vector
Initializes the given #graphene_plane_t using the given @normal vector
and @constant values.
the initialized plane
the #graphene_plane_t to initialize
a unit length normal vector defining the plane
pointing towards the origin; if unset, we use the X axis by default
the distance from the origin to the plane along the
normal vector; the sign determines the half-space occupied by the
plane
Initializes the given #graphene_plane_t using the normal
vector and constant of another #graphene_plane_t.
the initialized plane
the #graphene_plane_t to initialize
a #graphene_plane_t
Initializes the given #graphene_plane_t using the given normal vector
and an arbitrary co-planar point.
the initialized plane
the #graphene_plane_t to initialize
a normal vector defining the plane pointing towards the origin
a #graphene_point3d_t
Initializes the given #graphene_plane_t using the 3 provided co-planar
points.
The winding order is counter-clockwise, and determines which direction
the normal vector will point.
the initialized plane
the #graphene_plane_t to initialize
a #graphene_point3d_t
a #graphene_point3d_t
a #graphene_point3d_t
Initializes the given #graphene_plane_t using the components of
the given #graphene_vec4_t vector.
the initialized plane
the #graphene_plane_t to initialize
a #graphene_vec4_t containing the normal vector in its first
three components, and the distance in its fourth component
Negates the normal vector and constant of a #graphene_plane_t, effectively
mirroring the plane across the origin.
a #graphene_plane_t
return location for the negated plane
Normalizes the vector of the given #graphene_plane_t,
and adjusts the constant accordingly.
a #graphene_plane_t
return location for the normalized plane
Transforms a #graphene_plane_t @p using the given @matrix
and @normal_matrix.
If @normal_matrix is %NULL, a transformation matrix for the plane
normal will be computed from @matrix. If you are transforming
multiple planes using the same @matrix it's recommended to compute
the normal matrix beforehand to avoid incurring in the cost of
recomputing it every time.
a #graphene_plane_t
a #graphene_matrix_t
a #graphene_matrix_t
the transformed plane
A point with two coordinates.
the X coordinate of the point
the Y coordinate of the point
Allocates a new #graphene_point_t structure.
The coordinates of the returned point are (0, 0).
It's possible to chain this function with graphene_point_init()
or graphene_point_init_from_point(), e.g.:
|[<!-- language="C" -->
graphene_point_t *
point_new (float x, float y)
{
return graphene_point_init (graphene_point_alloc (), x, y);
}
graphene_point_t *
point_copy (const graphene_point_t *p)
{
return graphene_point_init_from_point (graphene_point_alloc (), p);
}
]|
the newly allocated #graphene_point_t.
Use graphene_point_free() to free the resources allocated by
this function.
Computes the distance between @a and @b.
the distance between the two points
a #graphene_point_t
a #graphene_point_t
distance component on the X axis
distance component on the Y axis
Checks if the two points @a and @b point to the same
coordinates.
This function accounts for floating point fluctuations; if
you want to control the fuzziness of the match, you can use
graphene_point_near() instead.
`true` if the points have the same coordinates
a #graphene_point_t
a #graphene_point_t
Frees the resources allocated by graphene_point_alloc().
a #graphene_point_t
Initializes @p to the given @x and @y coordinates.
It's safe to call this function multiple times.
the initialized point
a #graphene_point_t
the X coordinate
the Y coordinate
Initializes @p with the same coordinates of @src.
the initialized point
a #graphene_point_t
the #graphene_point_t to use
Initializes @p with the coordinates inside the given #graphene_vec2_t.
the initialized point
the #graphene_point_t to initialize
a #graphene_vec2_t
Linearly interpolates the coordinates of @a and @b using the
given @factor.
a #graphene_point_t
a #graphene_point_t
the linear interpolation factor
return location for the interpolated
point
Checks whether the two points @a and @b are within
the threshold of @epsilon.
`true` if the distance is within @epsilon
a #graphene_point_t
a #graphene_point_t
threshold between the two points
Stores the coordinates of the given #graphene_point_t into a
#graphene_vec2_t.
a #graphene_point_t
return location for the vertex
Returns a point fixed at (0, 0).
a fixed point
A point with three components: X, Y, and Z.
the X coordinate
the Y coordinate
the Z coordinate
Allocates a #graphene_point3d_t structure.
the newly allocated structure.
Use graphene_point3d_free() to free the resources
allocated by this function.
Computes the cross product of the two given #graphene_point3d_t.
a #graphene_point3d_t
a #graphene_point3d_t
return location for the cross
product
Computes the distance between the two given #graphene_point3d_t.
the distance between two points
a #graphene_point3d_t
a #graphene_point3d_t
return location for the distance
components on the X, Y, and Z axis
Computes the dot product of the two given #graphene_point3d_t.
the value of the dot product
a #graphene_point3d_t
a #graphene_point3d_t
Checks whether two given points are equal.
`true` if the points are equal
a #graphene_point3d_t
a #graphene_point3d_t
Frees the resources allocated via graphene_point3d_alloc().
a #graphene_point3d_t
Initializes a #graphene_point3d_t with the given coordinates.
the initialized #graphene_point3d_t
the #graphene_point3d_t to initialize
the X coordinate of the point
the Y coordinate of the point
the Z coordinate of the point
Initializes a #graphene_point3d_t using the coordinates of
another #graphene_point3d_t.
the initialized point
a #graphene_point3d_t
a #graphene_point3d_t
Initializes a #graphene_point3d_t using the components
of a #graphene_vec3_t.
the initialized #graphene_point3d_t
a #graphene_point3d_t
a #graphene_vec3_t
Linearly interpolates each component of @a and @b using the
provided @factor, and places the result in @res.
a #graphene_point3d_t
a #graphene_point3d_t
the interpolation factor
the return location for the
interpolated #graphene_point3d_t
Computes the length of the vector represented by the
coordinates of the given #graphene_point3d_t.
the length of the vector represented by the point
a #graphene_point3d_t
Checks whether the two points are near each other, within
an @epsilon factor.
`true` if the points are near each other
a #graphene_point3d_t
a #graphene_point3d_t
fuzzyness factor
Computes the normalization of the vector represented by the
coordinates of the given #graphene_point3d_t.
a #graphene_point3d_t
return location for the normalized
#graphene_point3d_t
Normalizes the coordinates of a #graphene_point3d_t using the
given viewport and clipping planes.
The coordinates of the resulting #graphene_point3d_t will be
in the [ -1, 1 ] range.
a #graphene_point3d_t
a #graphene_rect_t representing a viewport
the coordinate of the near clipping plane, or 0 for
the default near clipping plane
the coordinate of the far clipping plane, or 1 for the
default far clipping plane
the return location for the
normalized #graphene_point3d_t
Scales the coordinates of the given #graphene_point3d_t by
the given @factor.
a #graphene_point3d_t
the scaling factor
return location for the scaled point
Stores the coordinates of a #graphene_point3d_t into a
#graphene_vec3_t.
a #graphene_point3d_t
return location for a #graphene_vec3_t
Retrieves a constant point with all three coordinates set to 0.
a zero point
A 4 vertex quadrilateral, as represented by four #graphene_point_t.
The contents of a #graphene_quad_t are private and should never be
accessed directly.
Allocates a new #graphene_quad_t instance.
The contents of the returned instance are undefined.
the newly created #graphene_quad_t instance
Computes the bounding rectangle of @q and places it into @r.
a #graphene_quad_t
return location for a #graphene_rect_t
Checks if the given #graphene_quad_t contains the given #graphene_point_t.
`true` if the point is inside the #graphene_quad_t
a #graphene_quad_t
a #graphene_point_t
Frees the resources allocated by graphene_quad_alloc()
a #graphene_quad_t
Retrieves the point of a #graphene_quad_t at the given index.
a #graphene_point_t
a #graphene_quad_t
the index of the point to retrieve
Initializes a #graphene_quad_t with the given points.
the initialized #graphene_quad_t
the #graphene_quad_t to initialize
the first point of the quadrilateral
the second point of the quadrilateral
the third point of the quadrilateral
the fourth point of the quadrilateral
Initializes a #graphene_quad_t using an array of points.
the initialized #graphene_quad_t
the #graphene_quad_t to initialize
an array of 4 #graphene_point_t
Initializes a #graphene_quad_t using the four corners of the
given #graphene_rect_t.
the initialized #graphene_quad_t
the #graphene_quad_t to initialize
a #graphene_rect_t
A quaternion.
The contents of the #graphene_quaternion_t structure are private
and should never be accessed directly.
Allocates a new #graphene_quaternion_t.
The contents of the returned value are undefined.
the newly allocated #graphene_quaternion_t
Adds two #graphene_quaternion_t @a and @b.
a #graphene_quaternion_t
a #graphene_quaternion_t
the result of the operation
Computes the dot product of two #graphene_quaternion_t.
the value of the dot products
a #graphene_quaternion_t
a #graphene_quaternion_t
Checks whether the given quaternions are equal.
`true` if the quaternions are equal
a #graphene_quaternion_t
a #graphene_quaternion_t
Releases the resources allocated by graphene_quaternion_alloc().
a #graphene_quaternion_t
Initializes a #graphene_quaternion_t using the given four values.
the initialized quaternion
a #graphene_quaternion_t
the first component of the quaternion
the second component of the quaternion
the third component of the quaternion
the fourth component of the quaternion
Initializes a #graphene_quaternion_t using an @angle on a
specific @axis.
the initialized quaternion
a #graphene_quaternion_t
the rotation on a given axis, in degrees
the axis of rotation, expressed as a vector
Initializes a #graphene_quaternion_t using the values of
the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles)
on each axis.
See also: graphene_quaternion_init_from_euler()
the initialized quaternion
a #graphene_quaternion_t
rotation angle on the X axis (yaw), in degrees
rotation angle on the Y axis (pitch), in degrees
rotation angle on the Z axis (roll), in degrees
Initializes a #graphene_quaternion_t using the given #graphene_euler_t.
the initialized #graphene_quaternion_t
the #graphene_quaternion_t to initialize
a #graphene_euler_t
Initializes a #graphene_quaternion_t using the rotation components
of a transformation matrix.
the initialized quaternion
a #graphene_quaternion_t
a #graphene_matrix_t
Initializes a #graphene_quaternion_t with the values from @src.
the initialized quaternion
a #graphene_quaternion_t
a #graphene_quaternion_t
Initializes a #graphene_quaternion_t using the values of
the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles)
on each axis.
See also: graphene_quaternion_init_from_euler()
the initialized quaternion
a #graphene_quaternion_t
rotation angle on the X axis (yaw), in radians
rotation angle on the Y axis (pitch), in radians
rotation angle on the Z axis (roll), in radians
Initializes a #graphene_quaternion_t with the values from @src.
the initialized quaternion
a #graphene_quaternion_t
a #graphene_vec4_t
Initializes a #graphene_quaternion_t using the identity
transformation.
the initialized quaternion
a #graphene_quaternion_t
Inverts a #graphene_quaternion_t, and returns the conjugate
quaternion of @q.
a #graphene_quaternion_t
return location for the inverted
quaternion
Multiplies two #graphene_quaternion_t @a and @b.
a #graphene_quaternion_t
a #graphene_quaternion_t
the result of the operation
Normalizes a #graphene_quaternion_t.
a #graphene_quaternion_t
return location for the normalized
quaternion
Scales all the elements of a #graphene_quaternion_t @q using
the given scalar factor.
a #graphene_quaternion_t
a scaling factor
the result of the operation
Interpolates between the two given quaternions using a spherical
linear interpolation, or [SLERP](http://en.wikipedia.org/wiki/Slerp),
using the given interpolation @factor.
a #graphene_quaternion_t
a #graphene_quaternion_t
the linear interpolation factor
return location for the interpolated
quaternion
Converts a quaternion into an @angle, @axis pair.
a #graphene_quaternion_t
return location for the angle, in degrees
return location for the rotation axis
Converts a #graphene_quaternion_t to its corresponding rotations
on the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles)
on each axis.
a #graphene_quaternion_t
return location for the rotation angle on
the X axis (yaw), in degrees
return location for the rotation angle on
the Y axis (pitch), in degrees
return location for the rotation angle on
the Z axis (roll), in degrees
Converts a quaternion into a transformation matrix expressing
the rotation defined by the #graphene_quaternion_t.
a #graphene_quaternion_t
a #graphene_matrix_t
Converts a #graphene_quaternion_t to its corresponding rotations
on the [Euler angles](http://en.wikipedia.org/wiki/Euler_angles)
on each axis.
a #graphene_quaternion_t
return location for the rotation angle on
the X axis (yaw), in radians
return location for the rotation angle on
the Y axis (pitch), in radians
return location for the rotation angle on
the Z axis (roll), in radians
Copies the components of a #graphene_quaternion_t into a
#graphene_vec4_t.
a #graphene_quaternion_t
return location for a
#graphene_vec4_t
Initializes a #graphene_rect_t when declaring it.
the X coordinate of the origin
the Y coordinate of the origin
the width
the height
A ray emitted from an origin in a given direction.
The contents of the `graphene_ray_t` structure are private, and should not
be modified directly.
Allocates a new #graphene_ray_t structure.
The contents of the returned structure are undefined.
the newly allocated #graphene_ray_t.
Use graphene_ray_free() to free the resources allocated by
this function
Checks whether the two given #graphene_ray_t are equal.
`true` if the given rays are equal
a #graphene_ray_t
a #graphene_ray_t
Frees the resources allocated by graphene_ray_alloc().
a #graphene_ray_t
Computes the point on the given #graphene_ray_t that is closest to the
given point @p.
a #graphene_ray_t
a #graphene_point3d_t
return location for the closest point3d
Retrieves the direction of the given #graphene_ray_t.
a #graphene_ray_t
return location for the direction
Computes the distance of the origin of the given #graphene_ray_t from the
given plane.
If the ray does not intersect the plane, this function returns `INFINITY`.
the distance of the origin of the ray from the plane
a #graphene_ray_t
a #graphene_plane_t
Computes the distance of the closest approach between the
given #graphene_ray_t @r and the point @p.
The closest approach to a ray from a point is the distance
between the point and the projection of the point on the
ray itself.
the distance of the point
a #graphene_ray_t
a #graphene_point3d_t
Retrieves the origin of the given #graphene_ray_t.
a #graphene_ray_t
return location for the origin
Retrieves the coordinates of a point at the distance @t along the
given #graphene_ray_t.
a #graphene_ray_t
the distance along the ray
return location for the position
Initializes the given #graphene_ray_t using the given @origin
and @direction values.
the initialized ray
the #graphene_ray_t to initialize
the origin of the ray
the direction vector
Initializes the given #graphene_ray_t using the origin and direction
values of another #graphene_ray_t.
the initialized ray
the #graphene_ray_t to initialize
a #graphene_ray_t
Initializes the given #graphene_ray_t using the given vectors.
the initialized ray
the #graphene_ray_t to initialize
a #graphene_vec3_t
a #graphene_vec3_t
Intersects the given #graphene_ray_t @r with the given
#graphene_box_t @b.
the type of intersection
a #graphene_ray_t
a #graphene_box_t
the distance of the point on the ray that intersects the box
Intersects the given #graphene_ray_t @r with the given
#graphene_sphere_t @s.
the type of intersection
a #graphene_ray_t
a #graphene_sphere_t
the distance of the point on the ray that intersects the sphere
Intersects the given #graphene_ray_t @r with the given
#graphene_triangle_t @t.
the type of intersection
a #graphene_ray_t
a #graphene_triangle_t
the distance of the point on the ray that intersects the triangle
Checks whether the given #graphene_ray_t @r intersects the
given #graphene_box_t @b.
See also: graphene_ray_intersect_box()
`true` if the ray intersects the box
a #graphene_ray_t
a #graphene_box_t
Checks if the given #graphene_ray_t @r intersects the
given #graphene_sphere_t @s.
See also: graphene_ray_intersect_sphere()
`true` if the ray intersects the sphere
a #graphene_ray_t
a #graphene_sphere_t
Checks whether the given #graphene_ray_t @r intersects the
given #graphene_triangle_t @b.
See also: graphene_ray_intersect_triangle()
`true` if the ray intersects the triangle
a #graphene_ray_t
a #graphene_triangle_t
The type of intersection.
No intersection
The ray is entering the intersected
object
The ray is leaving the intersected
object
The location and size of a rectangle region.
The width and height of a #graphene_rect_t can be negative; for instance,
a #graphene_rect_t with an origin of [ 0, 0 ] and a size of [ 10, 10 ] is
equivalent to a #graphene_rect_t with an origin of [ 10, 10 ] and a size
of [ -10, -10 ].
Application code can normalize rectangles using graphene_rect_normalize();
this function will ensure that the width and height of a rectangle are
positive values. All functions taking a #graphene_rect_t as an argument
will internally operate on a normalized copy; all functions returning a
#graphene_rect_t will always return a normalized rectangle.
the coordinates of the origin of the rectangle
the size of the rectangle
Checks whether a #graphene_rect_t contains the given coordinates.
`true` if the rectangle contains the point
a #graphene_rect_t
a #graphene_point_t
Checks whether a #graphene_rect_t fully contains the given
rectangle.
`true` if the rectangle @a fully contains @b
a #graphene_rect_t
a #graphene_rect_t
Checks whether the two given rectangle are equal.
`true` if the rectangles are equal
a #graphene_rect_t
a #graphene_rect_t
Expands a #graphene_rect_t to contain the given #graphene_point_t.
a #graphene_rect_t
a #graphene_point_t
return location for the expanded rectangle
Frees the resources allocated by graphene_rect_alloc().
a #graphene_rect_t
Compute the area of given normalized rectangle.
the area of the normalized rectangle
a #graphene_rect_t
Retrieves the coordinates of the bottom-left corner of the given rectangle.
a #graphene_rect_t
return location for a #graphene_point_t
Retrieves the coordinates of the bottom-right corner of the given rectangle.
a #graphene_rect_t
return location for a #graphene_point_t
Retrieves the coordinates of the center of the given rectangle.
a #graphene_rect_t
return location for a #graphene_point_t
Retrieves the normalized height of the given rectangle.
the normalized height of the rectangle
a #graphene_rect_t
Retrieves the coordinates of the top-left corner of the given rectangle.
a #graphene_rect_t
return location for a #graphene_point_t
Retrieves the coordinates of the top-right corner of the given rectangle.
a #graphene_rect_t
return location for a #graphene_point_t
Computes the four vertices of a #graphene_rect_t.
a #graphene_rect_t
return location for an array
of 4 #graphene_vec2_t
Retrieves the normalized width of the given rectangle.
the normalized width of the rectangle
a #graphene_rect_t
Retrieves the normalized X coordinate of the origin of the given
rectangle.
the normalized X coordinate of the rectangle
a #graphene_rect_t
Retrieves the normalized Y coordinate of the origin of the given
rectangle.
the normalized Y coordinate of the rectangle
a #graphene_rect_t
Initializes the given #graphene_rect_t with the given values.
This function will implicitly normalize the #graphene_rect_t
before returning.
the initialized rectangle
a #graphene_rect_t
the X coordinate of the @graphene_rect_t.origin
the Y coordinate of the @graphene_rect_t.origin
the width of the @graphene_rect_t.size
the height of the @graphene_rect_t.size
Initializes @r using the given @src rectangle.
This function will implicitly normalize the #graphene_rect_t
before returning.
the initialized rectangle
a #graphene_rect_t
a #graphene_rect_t
Changes the given rectangle to be smaller, or larger depending on the
given inset parameters.
To create an inset rectangle, use positive @d_x or @d_y values; to
create a larger, encompassing rectangle, use negative @d_x or @d_y
values.
The origin of the rectangle is offset by @d_x and @d_y, while the size
is adjusted by `(2 * @d_x, 2 * @d_y)`. If @d_x and @d_y are positive
values, the size of the rectangle is decreased; if @d_x and @d_y are
negative values, the size of the rectangle is increased.
If the size of the resulting inset rectangle has a negative width or
height then the size will be set to zero.
the inset rectangle
a #graphene_rect_t
the horizontal inset
the vertical inset
Changes the given rectangle to be smaller, or larger depending on the
given inset parameters.
To create an inset rectangle, use positive @d_x or @d_y values; to
create a larger, encompassing rectangle, use negative @d_x or @d_y
values.
The origin of the rectangle is offset by @d_x and @d_y, while the size
is adjusted by `(2 * @d_x, 2 * @d_y)`. If @d_x and @d_y are positive
values, the size of the rectangle is decreased; if @d_x and @d_y are
negative values, the size of the rectangle is increased.
If the size of the resulting inset rectangle has a negative width or
height then the size will be set to zero.
a #graphene_rect_t
the horizontal inset
the vertical inset
return location for the inset rectangle
Linearly interpolates the origin and size of the two given
rectangles.
a #graphene_rect_t
a #graphene_rect_t
the linear interpolation factor
return location for the
interpolated rectangle
Computes the intersection of the two given rectangles.
![](rectangle-intersection.png)
The intersection in the image above is the blue outline.
If the two rectangles do not intersect, @res will contain
a degenerate rectangle with origin in (0, 0) and a size of 0.
`true` if the two rectangles intersect
a #graphene_rect_t
a #graphene_rect_t
return location for
a #graphene_rect_t
Normalizes the passed rectangle.
This function ensures that the size of the rectangle is made of
positive values, and that the origin is the top-left corner of
the rectangle.
the normalized rectangle
a #graphene_rect_t
Normalizes the passed rectangle.
This function ensures that the size of the rectangle is made of
positive values, and that the origin is in the top-left corner
of the rectangle.
a #graphene_rect_t
the return location for the
normalized rectangle
Offsets the origin by @d_x and @d_y.
The size of the rectangle is unchanged.
the offset rectangle
a #graphene_rect_t
the horizontal offset
the vertical offset
Offsets the origin of the given rectangle by @d_x and @d_y.
The size of the rectangle is left unchanged.
a #graphene_rect_t
the horizontal offset
the vertical offset
return location for the offset
rectangle
Rounds the origin and size of the given rectangle to
their nearest integer values; the rounding is guaranteed
to be large enough to have an area bigger or equal to the
original rectangle, but might not fully contain its extents.
Use graphene_rect_round_extents() in case you need to round
to a rectangle that covers fully the original one.
This function is the equivalent of calling `floor` on
the coordinates of the origin, and `ceil` on the size.
Use graphene_rect_round_extents() instead
a #graphene_rect_t
return location for the
rounded rectangle
Rounds the origin of the given rectangle to its nearest
integer value and and recompute the size so that the
rectangle is large enough to contain all the conrners
of the original rectangle.
This function is the equivalent of calling `floor` on
the coordinates of the origin, and recomputing the size
calling `ceil` on the bottom-right coordinates.
If you want to be sure that the rounded rectangle
completely covers the area that was covered by the
original rectangle — i.e. you want to cover the area
including all its corners — this function will make sure
that the size is recomputed taking into account the ceiling
of the coordinates of the bottom-right corner.
If the difference between the original coordinates and the
coordinates of the rounded rectangle is greater than the
difference between the original size and and the rounded
size, then the move of the origin would not be compensated
by a move in the anti-origin, leaving the corners of the
original rectangle outside the rounded one.
a #graphene_rect_t
return location for the
rectangle with rounded extents
Rounds the origin and the size of the given rectangle to
their nearest integer values; the rounding is guaranteed
to be large enough to contain the original rectangle.
Use graphene_rect_round() instead
the pixel-aligned rectangle.
a #graphene_rect_t
Scales the size and origin of a rectangle horizontaly by @s_h,
and vertically by @s_v. The result @res is normalized.
a #graphene_rect_t
horizontal scale factor
vertical scale factor
return location for the
scaled rectangle
Computes the union of the two given rectangles.
![](rectangle-union.png)
The union in the image above is the blue outline.
a #graphene_rect_t
a #graphene_rect_t
return location for a #graphene_rect_t
Allocates a new #graphene_rect_t.
The contents of the returned rectangle are undefined.
the newly allocated rectangle
Returns a degenerate rectangle with origin fixed at (0, 0) and
a size of 0, 0.
a fixed rectangle
Initializes a #graphene_size_t with the given sizes when
declaring it, e.g.:
|[<!-- language="C" -->
graphene_size_t size = GRAPHENE_SIZE_INIT (100.f, 100.f);
]|
the width
the height
A size.
the width
the height
Allocates a new #graphene_size_t.
The contents of the returned value are undefined.
the newly allocated #graphene_size_t
Checks whether the two give #graphene_size_t are equal.
`true` if the sizes are equal
a #graphene_size_t
a #graphene_size_t
Frees the resources allocated by graphene_size_alloc().
a #graphene_size_t
Initializes a #graphene_size_t using the given @width and @height.
the initialized #graphene_size_t
a #graphene_size_t
the width
the height
Initializes a #graphene_size_t using the width and height of
the given @src.
the initialized #graphene_size_t
a #graphene_size_t
a #graphene_size_t
Linearly interpolates the two given #graphene_size_t using the given
interpolation @factor.
a #graphene_size_t
a #graphene_size_t
the linear interpolation factor
return location for the interpolated size
Scales the components of a #graphene_size_t using the given @factor.
a #graphene_size_t
the scaling factor
return location for the scaled size
A constant pointer to a zero #graphene_size_t, useful for
equality checks and interpolations.
a constant size
A sphere, represented by its center and radius.
Allocates a new #graphene_sphere_t.
The contents of the newly allocated structure are undefined.
the newly allocated #graphene_sphere_t. Use
graphene_sphere_free() to free the resources allocated by this function
Checks whether the given @point is contained in the volume
of a #graphene_sphere_t.
`true` if the sphere contains the point
a #graphene_sphere_t
a #graphene_point3d_t
Computes the distance of the given @point from the surface of
a #graphene_sphere_t.
the distance of the point
a #graphene_sphere_t
a #graphene_point3d_t
Checks whether two #graphene_sphere_t are equal.
`true` if the spheres are equal
a #graphene_sphere_t
a #graphene_sphere_t
Frees the resources allocated by graphene_sphere_alloc().
a #graphene_sphere_t
Computes the bounding box capable of containing the
given #graphene_sphere_t.
a #graphene_sphere_t
return location for the bounding box
Retrieves the coordinates of the center of a #graphene_sphere_t.
a #graphene_sphere_t
return location for the coordinates of
the center
Retrieves the radius of a #graphene_sphere_t.
a #graphene_sphere_t
Initializes the given #graphene_sphere_t with the given @center and @radius.
the initialized #graphene_sphere_t
the #graphene_sphere_t to initialize
the coordinates of the center of the sphere, or %NULL
for a center in (0, 0, 0)
the radius of the sphere
Initializes the given #graphene_sphere_t using the given array
of 3D coordinates so that the sphere includes them.
The center of the sphere can either be specified, or will be center
of the 3D volume that encompasses all @points.
the initialized #graphene_sphere_t
the #graphene_sphere_t to initialize
the number of #graphene_point3d_t in the @points array
an array of #graphene_point3d_t
the center of the sphere
Initializes the given #graphene_sphere_t using the given array
of 3D coordinates so that the sphere includes them.
The center of the sphere can either be specified, or will be center
of the 3D volume that encompasses all @vectors.
the initialized #graphene_sphere_t
the #graphene_sphere_t to initialize
the number of #graphene_vec3_t in the @vectors array
an array of #graphene_vec3_t
the center of the sphere
Checks whether the sphere has a zero radius.
`true` if the sphere is empty
a #graphene_sphere_t
Translates the center of the given #graphene_sphere_t using the @point
coordinates as the delta of the translation.
a #graphene_sphere_t
the coordinates of the translation
return location for the translated sphere
A triangle.
Allocates a new #graphene_triangle_t.
The contents of the returned structure are undefined.
the newly allocated #graphene_triangle_t
structure. Use graphene_triangle_free() to free the resources
allocated by this function
Checks whether the given triangle @t contains the point @p.
`true` if the point is inside the triangle
a #graphene_triangle_t
a #graphene_point3d_t
Checks whether the two given #graphene_triangle_t are equal.
`true` if the triangles are equal
a #graphene_triangle_t
a #graphene_triangle_t
Frees the resources allocated by graphene_triangle_alloc().
a #graphene_triangle_t
Computes the area of the given #graphene_triangle_t.
the area of the triangle
a #graphene_triangle_t
Computes the [barycentric coordinates](http://en.wikipedia.org/wiki/Barycentric_coordinate_system)
of the given point @p.
The point @p must lie on the same plane as the triangle @t; if the
point is not coplanar, the result of this function is undefined.
If we place the origin in the coordinates of the triangle's A point,
the barycentric coordinates are `u`, which is on the AC vector; and `v`
which is on the AB vector:
![](triangle-barycentric.png)
The returned #graphene_vec2_t contains the following values, in order:
- `res.x = u`
- `res.y = v`
`true` if the barycentric coordinates are valid
a #graphene_triangle_t
a #graphene_point3d_t
return location for the vector
with the barycentric coordinates
Computes the bounding box of the given #graphene_triangle_t.
a #graphene_triangle_t
return location for the box
Computes the coordinates of the midpoint of the given #graphene_triangle_t.
The midpoint G is the [centroid](https://en.wikipedia.org/wiki/Centroid#Triangle_centroid)
of the triangle, i.e. the intersection of its medians.
a #graphene_triangle_t
return location for the coordinates of
the midpoint
Computes the normal vector of the given #graphene_triangle_t.
a #graphene_triangle_t
return location for the normal vector
Computes the plane based on the vertices of the given #graphene_triangle_t.
a #graphene_triangle_t
return location for the plane
Retrieves the three vertices of the given #graphene_triangle_t and returns
their coordinates as #graphene_point3d_t.
a #graphene_triangle_t
return location for the coordinates
of the first vertex
return location for the coordinates
of the second vertex
return location for the coordinates
of the third vertex
Computes the UV coordinates of the given point @p.
The point @p must lie on the same plane as the triangle @t; if the point
is not coplanar, the result of this function is undefined. If @p is %NULL,
the point will be set in (0, 0, 0).
The UV coordinates will be placed in the @res vector:
- `res.x = u`
- `res.y = v`
See also: graphene_triangle_get_barycoords()
`true` if the coordinates are valid
a #graphene_triangle_t
a #graphene_point3d_t
the UV coordinates of the first point
the UV coordinates of the second point
the UV coordinates of the third point
a vector containing the UV coordinates
of the given point @p
Retrieves the three vertices of the given #graphene_triangle_t.
a #graphene_triangle_t
return location for the first vertex
return location for the second vertex
return location for the third vertex
Initializes a #graphene_triangle_t using the three given arrays
of floating point values, each representing the coordinates of
a point in 3D space.
the initialized #graphene_triangle_t
the #graphene_triangle_t to initialize
an array of 3 floating point values
an array of 3 floating point values
an array of 3 floating point values
Initializes a #graphene_triangle_t using the three given 3D points.
the initialized #graphene_triangle_t
the #graphene_triangle_t to initialize
a #graphene_point3d_t
a #graphene_point3d_t
a #graphene_point3d_t
Initializes a #graphene_triangle_t using the three given vectors.
the initialized #graphene_triangle_t
the #graphene_triangle_t to initialize
a #graphene_vec3_t
a #graphene_vec3_t
a #graphene_vec3_t
Evaluates to the number of components of a #graphene_vec2_t.
This symbol is useful when declaring a C array of floating
point values to be used with graphene_vec2_init_from_float() and
graphene_vec2_to_float(), e.g.
|[
float v[GRAPHENE_VEC2_LEN];
// vec is defined elsewhere
graphene_vec2_to_float (&vec, v);
for (int i = 0; i < GRAPHENE_VEC2_LEN; i++)
fprintf (stdout, "component %d: %g\n", i, v[i]);
]|
Evaluates to the number of components of a #graphene_vec3_t.
This symbol is useful when declaring a C array of floating
point values to be used with graphene_vec3_init_from_float() and
graphene_vec3_to_float(), e.g.
|[
float v[GRAPHENE_VEC3_LEN];
// vec is defined elsewhere
graphene_vec3_to_float (&vec, v);
for (int i = 0; i < GRAPHENE_VEC2_LEN; i++)
fprintf (stdout, "component %d: %g\n", i, v[i]);
]|
Evaluates to the number of components of a #graphene_vec4_t.
This symbol is useful when declaring a C array of floating
point values to be used with graphene_vec4_init_from_float() and
graphene_vec4_to_float(), e.g.
|[
float v[GRAPHENE_VEC4_LEN];
// vec is defined elsewhere
graphene_vec4_to_float (&vec, v);
for (int i = 0; i < GRAPHENE_VEC4_LEN; i++)
fprintf (stdout, "component %d: %g\n", i, v[i]);
]|
A structure capable of holding a vector with two dimensions, x and y.
The contents of the #graphene_vec2_t structure are private and should
never be accessed directly.
Allocates a new #graphene_vec2_t structure.
The contents of the returned structure are undefined.
Use graphene_vec2_init() to initialize the vector.
the newly allocated #graphene_vec2_t
structure. Use graphene_vec2_free() to free the resources allocated
by this function.
Adds each component of the two passed vectors and places
each result into the components of @res.
a #graphene_vec2_t
a #graphene_vec2_t
return location for the result
Divides each component of the first operand @a by the corresponding
component of the second operand @b, and places the results into the
vector @res.
a #graphene_vec2_t
a #graphene_vec2_t
return location for the result
Computes the dot product of the two given vectors.
the dot product of the vectors
a #graphene_vec2_t
a #graphene_vec2_t
Checks whether the two given #graphene_vec2_t are equal.
`true` if the two vectors are equal, and false otherwise
a #graphene_vec2_t
a #graphene_vec2_t
Frees the resources allocated by @v
a #graphene_vec2_t
Retrieves the X component of the #graphene_vec2_t.
the value of the X component
a #graphene_vec2_t
Retrieves the Y component of the #graphene_vec2_t.
the value of the Y component
a #graphene_vec2_t
Initializes a #graphene_vec2_t using the given values.
This function can be called multiple times.
the initialized vector
a #graphene_vec2_t
the X field of the vector
the Y field of the vector
Initializes @v with the contents of the given array.
the initialized vector
a #graphene_vec2_t
an array of floating point values
with at least two elements
Copies the contents of @src into @v.
the initialized vector
a #graphene_vec2_t
a #graphene_vec2_t
Linearly interpolates @v1 and @v2 using the given @factor.
a #graphene_vec2_t
a #graphene_vec2_t
the interpolation factor
the interpolated vector
Computes the length of the given vector.
the length of the vector
a #graphene_vec2_t
Compares the two given vectors and places the maximum
values of each component into @res.
a #graphene_vec2_t
a #graphene_vec2_t
the resulting vector
Compares the two given vectors and places the minimum
values of each component into @res.
a #graphene_vec2_t
a #graphene_vec2_t
the resulting vector
Multiplies each component of the two passed vectors and places
each result into the components of @res.
a #graphene_vec2_t
a #graphene_vec2_t
return location for the result
Compares the two given #graphene_vec2_t vectors and checks
whether their values are within the given @epsilon.
`true` if the two vectors are near each other
a #graphene_vec2_t
a #graphene_vec2_t
the threshold between the two vectors
Negates the given #graphene_vec2_t.
a #graphene_vec2_t
return location for the result vector
Computes the normalized vector for the given vector @v.
a #graphene_vec2_t
return location for the
normalized vector
Multiplies all components of the given vector with the given scalar @factor.
a #graphene_vec2_t
the scalar factor
return location for the result vector
Subtracts from each component of the first operand @a the
corresponding component of the second operand @b and places
each result into the components of @res.
a #graphene_vec2_t
a #graphene_vec2_t
return location for the result
Stores the components of @v into an array.
a #graphene_vec2_t
return location
for an array of floating point values with at least 2 elements
Retrieves a constant vector with (1, 1) components.
the one vector
Retrieves a constant vector with (1, 0) components.
the X axis vector
Retrieves a constant vector with (0, 1) components.
the Y axis vector
Retrieves a constant vector with (0, 0) components.
the zero vector
A structure capable of holding a vector with three dimensions: x, y, and z.
The contents of the #graphene_vec3_t structure are private and should
never be accessed directly.
Allocates a new #graphene_vec3_t structure.
The contents of the returned structure are undefined.
Use graphene_vec3_init() to initialize the vector.
the newly allocated #graphene_vec3_t
structure. Use graphene_vec3_free() to free the resources allocated
by this function.
Adds each component of the two given vectors.
a #graphene_vec3_t
a #graphene_vec3_t
return location for the resulting vector
Computes the cross product of the two given vectors.
a #graphene_vec3_t
a #graphene_vec3_t
return location for the resulting vector
Divides each component of the first operand @a by the corresponding
component of the second operand @b, and places the results into the
vector @res.
a #graphene_vec3_t
a #graphene_vec3_t
return location for the resulting vector
Computes the dot product of the two given vectors.
the value of the dot product
a #graphene_vec3_t
a #graphene_vec3_t
Checks whether the two given #graphene_vec3_t are equal.
`true` if the two vectors are equal, and false otherwise
a #graphene_vec3_t
a #graphene_vec3_t
Frees the resources allocated by @v
a #graphene_vec3_t
Retrieves the first component of the given vector @v.
the value of the first component of the vector
a #graphene_vec3_t
Creates a #graphene_vec2_t that contains the first and second
components of the given #graphene_vec3_t.
a #graphene_vec3_t
return location for a #graphene_vec2_t
Creates a #graphene_vec3_t that contains the first two components of
the given #graphene_vec3_t, and the third component set to 0.
a #graphene_vec3_t
return location for a #graphene_vec3_t
Converts a #graphene_vec3_t in a #graphene_vec4_t using 0.0
as the value for the fourth component of the resulting vector.
a #graphene_vec3_t
return location for the vector
Converts a #graphene_vec3_t in a #graphene_vec4_t using 1.0
as the value for the fourth component of the resulting vector.
a #graphene_vec3_t
return location for the vector
Converts a #graphene_vec3_t in a #graphene_vec4_t using @w as
the value of the fourth component of the resulting vector.
a #graphene_vec3_t
the value of the W component
return location for the vector
Retrieves the second component of the given vector @v.
the value of the second component of the vector
a #graphene_vec3_t
Retrieves the third component of the given vector @v.
the value of the third component of the vector
a #graphene_vec3_t
Initializes a #graphene_vec3_t using the given values.
This function can be called multiple times.
a pointer to the initialized
vector
a #graphene_vec3_t
the X field of the vector
the Y field of the vector
the Z field of the vector
Initializes a #graphene_vec3_t with the values from an array.
the initialized vector
a #graphene_vec3_t
an array of 3 floating point values
Initializes a #graphene_vec3_t with the values of another
#graphene_vec3_t.
the initialized vector
a #graphene_vec3_t
a #graphene_vec3_t
Linearly interpolates @v1 and @v2 using the given @factor.
a #graphene_vec3_t
a #graphene_vec3_t
the interpolation factor
the interpolated vector
Retrieves the length of the given vector @v.
the value of the length of the vector
a #graphene_vec3_t
Compares each component of the two given vectors and creates a
vector that contains the maximum values.
a #graphene_vec3_t
a #graphene_vec3_t
return location for the result vector
Compares each component of the two given vectors and creates a
vector that contains the minimum values.
a #graphene_vec3_t
a #graphene_vec3_t
return location for the result vector
Multiplies each component of the two given vectors.
a #graphene_vec3_t
a #graphene_vec3_t
return location for the resulting vector
Compares the two given #graphene_vec3_t vectors and checks
whether their values are within the given @epsilon.
`true` if the two vectors are near each other
a #graphene_vec3_t
a #graphene_vec3_t
the threshold between the two vectors
Negates the given #graphene_vec3_t.
a #graphene_vec3_t
return location for the result vector
Normalizes the given #graphene_vec3_t.
a #graphene_vec3_t
return location for the normalized vector
Multiplies all components of the given vector with the given scalar @factor.
a #graphene_vec3_t
the scalar factor
return location for the result vector
Subtracts from each component of the first operand @a the
corresponding component of the second operand @b and places
each result into the components of @res.
a #graphene_vec3_t
a #graphene_vec3_t
return location for the resulting vector
Copies the components of a #graphene_vec3_t into the given array.
a #graphene_vec3_t
return location for
an array of floating point values
Provides a constant pointer to a vector with three components,
all sets to 1.
a constant vector
Provides a constant pointer to a vector with three components
with values set to (1, 0, 0).
a constant vector
Provides a constant pointer to a vector with three components
with values set to (0, 1, 0).
a constant vector
Provides a constant pointer to a vector with three components
with values set to (0, 0, 1).
a constant vector
Provides a constant pointer to a vector with three components,
all sets to 0.
a constant vector
A structure capable of holding a vector with four dimensions: x, y, z, and w.
The contents of the #graphene_vec4_t structure are private and should
never be accessed directly.
Allocates a new #graphene_vec4_t structure.
The contents of the returned structure are undefined.
Use graphene_vec4_init() to initialize the vector.
the newly allocated #graphene_vec4_t
structure. Use graphene_vec4_free() to free the resources allocated
by this function.
Adds each component of the two given vectors.
a #graphene_vec4_t
a #graphene_vec4_t
return location for the resulting vector
Divides each component of the first operand @a by the corresponding
component of the second operand @b, and places the results into the
vector @res.
a #graphene_vec4_t
a #graphene_vec4_t
return location for the resulting vector
Computes the dot product of the two given vectors.
the value of the dot product
a #graphene_vec4_t
a #graphene_vec4_t
Checks whether the two given #graphene_vec4_t are equal.
`true` if the two vectors are equal, and false otherwise
a #graphene_vec4_t
a #graphene_vec4_t
Frees the resources allocated by @v
a #graphene_vec4_t
Retrieves the value of the fourth component of the given #graphene_vec4_t.
the value of the fourth component
a #graphene_vec4_t
Retrieves the value of the first component of the given #graphene_vec4_t.
the value of the first component
a #graphene_vec4_t
Creates a #graphene_vec2_t that contains the first two components
of the given #graphene_vec4_t.
a #graphene_vec4_t
return location for a #graphene_vec2_t
Creates a #graphene_vec3_t that contains the first three components
of the given #graphene_vec4_t.
a #graphene_vec4_t
return location for a graphene_vec3_t
Retrieves the value of the second component of the given #graphene_vec4_t.
the value of the second component
a #graphene_vec4_t
Retrieves the value of the third component of the given #graphene_vec4_t.
the value of the third component
a #graphene_vec4_t
Initializes a #graphene_vec4_t using the given values.
This function can be called multiple times.
a pointer to the initialized
vector
a #graphene_vec4_t
the X field of the vector
the Y field of the vector
the Z field of the vector
the W field of the vector
Initializes a #graphene_vec4_t with the values inside the given array.
the initialized vector
a #graphene_vec4_t
an array of four floating point values
Initializes a #graphene_vec4_t using the components of a
#graphene_vec2_t and the values of @z and @w.
the initialized vector
a #graphene_vec4_t
a #graphene_vec2_t
the value for the third component of @v
the value for the fourth component of @v
Initializes a #graphene_vec4_t using the components of a
#graphene_vec3_t and the value of @w.
the initialized vector
a #graphene_vec4_t
a #graphene_vec3_t
the value for the fourth component of @v
Initializes a #graphene_vec4_t using the components of
another #graphene_vec4_t.
the initialized vector
a #graphene_vec4_t
a #graphene_vec4_t
Linearly interpolates @v1 and @v2 using the given @factor.
a #graphene_vec4_t
a #graphene_vec4_t
the interpolation factor
the interpolated vector
Computes the length of the given #graphene_vec4_t.
the length of the vector
a #graphene_vec4_t
Compares each component of the two given vectors and creates a
vector that contains the maximum values.
a #graphene_vec4_t
a #graphene_vec4_t
return location for the result vector
Compares each component of the two given vectors and creates a
vector that contains the minimum values.
a #graphene_vec4_t
a #graphene_vec4_t
return location for the result vector
Multiplies each component of the two given vectors.
a #graphene_vec4_t
a #graphene_vec4_t
return location for the resulting vector
Compares the two given #graphene_vec4_t vectors and checks
whether their values are within the given @epsilon.
`true` if the two vectors are near each other
a #graphene_vec4_t
a #graphene_vec4_t
the threshold between the two vectors
Negates the given #graphene_vec4_t.
a #graphene_vec4_t
return location for the result vector
Normalizes the given #graphene_vec4_t.
a #graphene_vec4_t
return location for the normalized
vector
Multiplies all components of the given vector with the given scalar @factor.
a #graphene_vec4_t
the scalar factor
return location for the result vector
Subtracts from each component of the first operand @a the
corresponding component of the second operand @b and places
each result into the components of @res.
a #graphene_vec4_t
a #graphene_vec4_t
return location for the resulting vector
Stores the components of the given #graphene_vec4_t into an array
of floating point values.
a #graphene_vec4_t
return location for
an array of floating point values
Retrieves a pointer to a #graphene_vec4_t with all its
components set to 1.
a constant vector
Retrieves a pointer to a #graphene_vec4_t with its
components set to (0, 0, 0, 1).
a constant vector
Retrieves a pointer to a #graphene_vec4_t with its
components set to (1, 0, 0, 0).
a constant vector
Retrieves a pointer to a #graphene_vec4_t with its
components set to (0, 1, 0, 0).
a constant vector
Retrieves a pointer to a #graphene_vec4_t with its
components set to (0, 0, 1, 0).
a constant vector
Retrieves a pointer to a #graphene_vec4_t with all its
components set to 0.
a constant vector
A degenerate #graphene_box_t that can only be expanded.
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A degenerate #graphene_box_t that cannot be expanded.
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A #graphene_box_t with the minimum vertex set at (-1, -1, -1) and the
maximum vertex set at (0, 0, 0).
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A #graphene_box_t with the minimum vertex set at (0, 0, 0) and the
maximum vertex set at (1, 1, 1).
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A #graphene_box_t with the minimum vertex set at (-1, -1, -1) and the
maximum vertex set at (1, 1, 1).
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
A #graphene_box_t with both the minimum and maximum vertices set at (0, 0, 0).
The returned value is owned by Graphene and should not be modified or freed.
a #graphene_box_t
#graphene_box_t provides a representation of an axis aligned minimum
bounding box using the coordinates of its minimum and maximum vertices.
The #graphene_euler_t structure defines a rotation along three axes using
three angles. It also optionally can describe the order of the rotations.
[Euler's rotation theorem](https://en.wikipedia.org/wiki/Euler%27s_rotation_theorem)
states that, in three-dimensional space, any displacement of a rigid body
such that a point on the rigid body remains fixed, is equivalent to a single
rotation about some axis that runs through the fixed point. The angles on
each axis can be placed in a vector of three components—α, β, and γ—called
the *Euler angle vector*. Each rotation described by these components results
in a rotation matrix:
|[
rot(α) = A
rot(β) = B
rot(γ) = G
]|
The resulting rotation matrix expressed by the Euler angle vector is
given by the product of each rotation matrix:
|[
G × B × A = R
]|
In order to specify the meaning of an Euler angle vector, we need to
assign each axis of rotation to the corresponding α, β, and γ components,
for instance X, Y, and Z.
Additionally, we need to specify whether the rotations move the axes
as they are applied, also known as intrinsic, or relative rotations;
or if the axes stay fixed and the vectors move within the axis frame,
also known as extrinsic, or static rotations. For instance, a static
rotation alongside the ZYX axes will be interpreted as relative to
extrinsic coordinate axes, and be performed, in order, about the Z,
Y, and finally X axis. A relative rotation alongside the ZXZ axes will
be interpreted as relative to intrinsic coordinate axes, and be
performed, in order, about the Z axis, about the rotated X axis, and
finally about the rotated Z axis.
Finally, we need to define the direction of the rotation, or the handedness
of the coordinate system. In the case of Graphene, the direction is given
by the right-hand rule, which means all rotations are counterclockwise.
Rotations described Euler angles are typically immediately understandable,
compared to rotations expressed using quaternions, but they are susceptible
of ["Gimbal lock"](http://en.wikipedia.org/wiki/Gimbal_lock) — the loss of
one degree of freedom caused by two axis on the same plane. You typically
should use #graphene_euler_t to expose rotation angles in your API, or to
store them, but use #graphene_quaternion_t to apply rotations to modelview
matrices, or interpolate between initial and final rotation transformations.
For more information, see:
- http://en.wikipedia.org/wiki/Rotation_matrix
- http://en.wikipedia.org/wiki/Euler_angles
- http://mathworld.wolfram.com/EulerAngles.html
- "Representing Attitude with Euler Angles and Quaternions: A
Reference" by James Diebel, 2006
- "Graphics Gems IV", edited by Paul Heckbert, Academic Press, 1994.
See also: #graphene_quaternion_t.
A #graphene_frustum_t represents a volume of space delimited by planes. It
is usually employed to represent the field of view of a camera, and can be
used to determine whether an object falls within that view, to efficiently
remove invisible objects from the render process.
Graphene optionally provides information for using its own types with
GObject properties and signals.
## Using Graphene with GObject
In order to discover at compile time if Graphene exposes type information
for the GType type system, you need to check if the `graphene-gobject-1.0`
pkg-config file exists.
If you're using Meson to build your project, you can use a typical
`dependency()` object, for instance:
|[<!-- language="plain" -->
graphene_dep = dependency('graphene-gobject-1.0')
]|
If you're using Autotools to build your project, you can use the
`PKG_CHECK_EXISTS` m4 macro, for instance:
|[<!-- language="plain" -->
PKG_CHECK_EXISTS([graphene-gobject-1.0],
[action-if-found],
[action-if-not-found]
]|
All the types provided by Graphene are boxed types, which means you
will have to use the #GBoxed API when dealing with #GValue, #GParamSpec,
and signal marshallers. For instance, to install a property in a #GObject
class that uses #graphene_rect_t, you can use:
|[<!-- language="C" -->
g_object_class_install_property (object_class, PROP_BOUNDS,
g_param_spec_boxed ("bounds", "Bounds", "Bounds of an object",
GRAPHENE_TYPE_RECT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
]|
You'll then need to use g_value_set_boxed() and g_value_get_boxed()
in order to access the #graphene_rect_t pointer from the #GValue data
structure.
Whereas for creating a new signal that has a #graphene_point_t parameter
you can use:
|[<!-- language="C" -->
signals[HIT_TEST] =
g_signal_new ("hit-test",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled, NULL,
marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
GRAPHENE_TYPE_POINT);
]|
## Using Graphene via GObject introspection
When using Graphene with another language than C, the GObject Introspection
bindings change the type names to the CamelCase version of the C name, minus
the `_t` suffix; for instance:
* #graphene_point_t becomes `GraphenePoint`
* #graphene_point3d_t becomes `GraphenePoint3D`
* #graphene_rect_t becomes `GrapheneRect`
* #graphene_matrix_t becomes `GrapheneMatrix`
There is no direct access for the low level #graphene_simd4f_t and
#graphene_simd4x4f_t SIMD types.
#graphene_matrix_t is a type that provides a 4x4 square matrix, useful for
representing 3D transformations.
The matrix is treated as row-major, i.e. it has four vectors (x, y, z, and
w) representing rows, and elements of each vector are a column:
|[<!-- language="plain" -->
⎡ m.x ⎤ ⎛ x.x x.y x.z x.w ⎞
⎜ m.y ⎟ -\ ⎜ y.x y.y y.z y.w ⎟
⎜ m.z ⎟ -/ ⎜ z.x z.y z.z z.w ⎟
⎣ m.w ⎦ ⎝ w.x w.y w.z w.w ⎠
]|
It is possible to easily convert a #graphene_matrix_t to and from an array
of floating point values that can be used with other libraries.
The contents of a #graphene_matrix_t are private, and direct access is not
possible. You can modify and read the contents of a #graphene_matrix_t
only through the provided API.
# Conventions # {#conventions}
Graphene uses left-multiplication for all its operations on vectors and
matrices; in other words, given a matrix `A` and a vector `b`, the result
of a multiplication is going to be:
|[
res = b × A
]|
Multiplying two matrices, on the other hand, will use right-multiplication;
given two matrices `A` and `B`, the result of the multiplication is going
to be
|[
res = A × B
]|
as the implementation will multiply each row vector of matrix `A` with the
matrix `B` to obtain the new row vectors of the result matrix:
|[
res = ⎡ A.x × B ⎤
⎜ A.y × B ⎟
⎜ A.z × B ⎟
⎣ A.w × B ⎦
]|
For more information, see the documentation for #graphene_simd4x4f_t,
especially the following functions:
- graphene_simd4x4f_vec4_mul()
- graphene_simd4x4f_vec3_mul()
- graphene_simd4x4f_point3_mul()
- graphene_simd4x4f_matrix_mul()
#graphene_plane_t is a structure representing a plane that extends
infinitely in 3D space, described using the [Hessian normal
form](http://mathworld.wolfram.com/HessianNormalForm.html)
of a unit length normal vector pointing towards the origin, and a
constant distance from the origin along the normal vector.
#graphene_point_t is a data structure capable of describing a point with
two coordinates:
* @graphene_point_t.x
* @graphene_point_t.y
#graphene_point3d_t is a data structure capable of describing a point with
three coordinates:
* @graphene_point3d_t.x
* @graphene_point3d_t.y
* @graphene_point3d_t.z
A #graphene_quad_t represents a coplanar, four vertex quadrilateral shape.
Quaternions are a mathematical entity that can be used to represent
rotation transformations in 3D space; unlike the usual Euler representation
with roll, pitch, and yaw, quaternions do not suffer from the so-called
["Gimbal Lock"](http://en.wikipedia.org/wiki/Gimbal_lock) problem.
See also: #graphene_euler_t
#graphene_ray_t is a structure representing a ray emitted by an origin,
identified by a point in 3D space, in a given direction, identified
by a vector with 3 components.
A common use of #graphene_ray_t is ray-casting to find which objects in
a 3D scene are under the coordinates of the pointer.
#graphene_rect_t is a type representing a rectangle through an origin
#graphene_point_t point and a #graphene_size_t size.
![](rectangle.png)
Operations on a #graphene_rect_t will normalize the rectangle, to
ensure that the origin is always the top-left corner of the rectangle
and that the size is always positive.
#graphene_size_t represents a size composed of a @graphene_size_t.width
by a @graphene_size_t.height.
#graphene_sphere_t provides a representation of a sphere using its center
and radius.
#graphene_triangle_t represents a triangle in 3D space.
Graphene has three vector types, distinguished by their length:
1. #graphene_vec2_t, which holds 2 components x and y
2. #graphene_vec3_t, which holds 3 components x, y, and z
3. #graphene_vec4_t, which holds 4 components x, y, z, and w
Each vector type should be treated as an opaque data type.
Retrieves a constant point with all three coordinates set to 0.
a zero point
Returns a point fixed at (0, 0).
a fixed point
Allocates a new #graphene_rect_t.
The contents of the returned rectangle are undefined.
the newly allocated rectangle
Returns a degenerate rectangle with origin fixed at (0, 0) and
a size of 0, 0.
a fixed rectangle
A constant pointer to a zero #graphene_size_t, useful for
equality checks and interpolations.
a constant size
Retrieves a constant vector with (1, 1) components.
the one vector
Retrieves a constant vector with (1, 0) components.
the X axis vector
Retrieves a constant vector with (0, 1) components.
the Y axis vector
Retrieves a constant vector with (0, 0) components.
the zero vector
Provides a constant pointer to a vector with three components,
all sets to 1.
a constant vector
Provides a constant pointer to a vector with three components
with values set to (1, 0, 0).
a constant vector
Provides a constant pointer to a vector with three components
with values set to (0, 1, 0).
a constant vector
Provides a constant pointer to a vector with three components
with values set to (0, 0, 1).
a constant vector
Provides a constant pointer to a vector with three components,
all sets to 0.
a constant vector
Retrieves a pointer to a #graphene_vec4_t with all its
components set to 1.
a constant vector
Retrieves a pointer to a #graphene_vec4_t with its
components set to (0, 0, 0, 1).
a constant vector
Retrieves a pointer to a #graphene_vec4_t with its
components set to (1, 0, 0, 0).
a constant vector
Retrieves a pointer to a #graphene_vec4_t with its
components set to (0, 1, 0, 0).
a constant vector
Retrieves a pointer to a #graphene_vec4_t with its
components set to (0, 0, 1, 0).
a constant vector
Retrieves a pointer to a #graphene_vec4_t with all its
components set to 0.
a constant vector