Decomposes a transformation matrix into its component transformations.
The algorithm for decomposing a matrix is taken from the CSS3 Transforms specification; specifically, the decomposition code is based on the equivalent code published in "Graphics Gems II", edited by Jim Arvo, and available online.
true if the matrix could be decomposed
Computes the determinant of the given matrix.
the value of the determinant
Checks whether the two given Graphene.Matrix matrices are equal.
true if the two matrices are equal, and false otherwise
Checks whether the two given Graphene.Matrix matrices are byte-by-byte equal.
While this function is faster than graphene_matrix_equal(), it
can also return false negatives, so it should be used in
conjuction with either graphene_matrix_equal() or
graphene_matrix_near(). For instance:
if (graphene_matrix_equal_fast (a, b))
{
// matrices are definitely the same
}
else
{
if (graphene_matrix_equal (a, b))
// matrices contain the same values within an epsilon of FLT_EPSILON
else if (graphene_matrix_near (a, b, 0.0001))
// matrices contain the same values within an epsilon of 0.0001
else
// matrices are not equal
}
true if the matrices are equal. and false otherwise
Frees the resources allocated by graphene_matrix_alloc().
Retrieves the given row vector at index_ inside a matrix.
the index of the row vector, between 0 and 3
Retrieves the value at the given row and col index.
the row index
the column index
the value at the given indices
Retrieves the scaling factor on the X axis in m.
the value of the scaling factor
Retrieves the translation component on the X axis from m.
the translation component
Retrieves the scaling factor on the Y axis in m.
the value of the scaling factor
Retrieves the translation component on the Y axis from m.
the translation component
Retrieves the scaling factor on the Z axis in m.
the value of the scaling factor
Retrieves the translation component on the Z axis from m.
the translation component
Initializes a Graphene.Matrix from the values of an affine transformation matrix.
The arguments map to the following matrix layout:
⎛ xx yx ⎞ ⎛ a b 0 ⎞
⎜ xy yy ⎟ = ⎜ c d 0 ⎟
⎝ x0 y0 ⎠ ⎝ tx ty 1 ⎠
This function can be used to convert between an affine matrix type from other libraries and a Graphene.Matrix.
the xx member
the yx member
the xy member
the yy member
the x0 member
the y0 member
the initialized matrix
Initializes a Graphene.Matrix with the given array of floating point values.
an array of at least 16 floating point values
the initialized matrix
Initializes a Graphene.Matrix using the values of the given matrix.
the initialized matrix
Initializes a Graphene.Matrix compatible with Graphene.Frustum.
See also: graphene_frustum_init_from_matrix()
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
the initialized matrix
Initializes a Graphene.Matrix with the identity matrix.
the initialized matrix
Initializes a Graphene.Matrix 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
Initializes a Graphene.Matrix with an orthographic projection.
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
the initialized matrix
Initializes a Graphene.Matrix with a perspective projection.
the field of view angle, in degrees
the aspect value
the near Z plane
the far Z plane
the initialized matrix
Initializes m to represent a rotation of angle degrees on
the axis represented by the axis vector.
the rotation angle, in degrees
the axis vector as a Graphene.Vec3
the initialized matrix
Initializes a Graphene.Matrix with the given scaling factors.
the scale factor on the X axis
the scale factor on the Y axis
the scale factor on the Z axis
the initialized matrix
Initializes a Graphene.Matrix with a skew transformation with the given factors.
skew factor, in radians, on the X axis
skew factor, in radians, on the Y axis
the initialized matrix
Initializes a Graphene.Matrix with a translation to the given coordinates.
the translation coordinates
the initialized matrix
Linearly interpolates the two given Graphene.Matrix 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.
Checks whether the given Graphene.Matrix is compatible with an a 2D affine transformation matrix.
true if the matrix is compatible with an affine transformation matrix
Checks whether a Graphene.Matrix has a visible back face.
true if the back face of the matrix is visible
Checks whether the given Graphene.Matrix is the identity matrix.
true if the matrix is the identity matrix
Checks whether a matrix is singular.
true if the matrix is singular
Multiplies two Graphene.Matrix.
Matrix multiplication is not commutative in general; the order of the factors matters.
The product of this multiplication is (a × b)
Compares the two given Graphene.Matrix 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
Normalizes the given Graphene.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.
Projects all corners of a Graphene.Rect using the given matrix.
See also: graphene_matrix_project_point()
Projects a Graphene.Rect using the given matrix.
The resulting rectangle is the axis aligned bounding rectangle capable of fully containing 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.
the rotation angle, in degrees
the rotation axis, as a Graphene.Vec3
Adds a rotation transformation to m, using the given
Graphene.Euler.
a rotation described by a Graphene.Euler
Adds a rotation transformation to m, using the given
Graphene.Quaternion.
This is the equivalent of calling graphene_quaternion_to_matrix() and
then multiplying m with the rotation matrix.
a rotation described by a Graphene.Quaternion
Adds a rotation transformation around the X axis to m, using
the given angle.
See also: graphene_matrix_rotate()
the rotation angle, in degrees
Adds a rotation transformation around the Y axis to m, using
the given angle.
See also: graphene_matrix_rotate()
the rotation angle, in degrees
Adds a rotation transformation around the Z axis to m, using
the given angle.
See also: graphene_matrix_rotate()
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.
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.
skew factor
Adds a skew of factor on the X and Z axis to the given matrix.
skew factor
Adds a skew of factor on the Y and Z axis to the given matrix.
skew factor
Converts a Graphene.Matrix to an affine transformation matrix, if the given matrix is compatible.
The returned values have the following layout:
⎛ xx yx ⎞ ⎛ a b 0 ⎞
⎜ xy yy ⎟ = ⎜ c d 0 ⎟
⎝ x0 y0 ⎠ ⎝ tx ty 1 ⎠
This function can be used to convert between a Graphene.Matrix and an affine matrix type from other libraries.
true if the matrix is compatible with an affine transformation matrix
Converts a Graphene.Matrix to an array of floating point values.
Transforms each corner of a Graphene.Rect using the given matrix m.
The result is the axis aligned bounding rectangle containing the coplanar quadrilateral.
See also: graphene_matrix_transform_point()
Transforms the vertices of a Graphene.Box using the given matrix m.
The result is the axis aligned bounding box containing the transformed vertices.
Transforms the given Graphene.Point using the matrix m.
Unlike graphene_matrix_transform_vec3(), this function will take into
account the fourth row vector of the Graphene.Matrix when computing
the dot product of each row vector of the matrix.
See also: graphene_simd4x4f_point3_mul()
Transforms the given Graphene.Point3D using the matrix m.
Unlike graphene_matrix_transform_vec3(), this function will take into
account the fourth row vector of the Graphene.Matrix when computing
the dot product of each row vector of the matrix.
See also: graphene_simd4x4f_point3_mul()
Transforms each corner of a Graphene.Rect using the given matrix m.
The result is a coplanar quadrilateral.
See also: graphene_matrix_transform_point()
Transforms a Graphene.Sphere using the given matrix m. The
result is the bounding sphere containing the transformed sphere.
Transforms the given Graphene.Vec3 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()
Transforms the given Graphene.Vec4 using the matrix m.
See also: graphene_simd4x4f_vec4_mul()
Adds a translation transformation to m using the coordinates
of the given Graphene.Point3D.
This is the equivalent of calling graphene_matrix_init_translate() and
then multiplying m with the translation matrix.
Unprojects the given point using the projection matrix and
a modelview matrix.
a Graphene.Matrix for the modelview matrix; this is the inverse of the modelview used when projecting the point
a Graphene.Point3D with the coordinates of the point
Staticalloc
A structure capable of holding a 4x4 matrix.
The contents of the Graphene.Matrix structure are private and should never be accessed directly.