A structure capable of holding a 4x4 matrix.
The contents of the <GrapheneMatrix> structure are
private and should never be accessed directly.
Allocates a new <GrapheneMatrix>.
Returned: a <GrapheneMatrix>.
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; specifically, the decomposition code is based on the equivalent code published in "Graphics Gems II", edited by Jim Arvo, and available online.
Passed: a <GrapheneMatrix>.
Passed, filled in, and returned: a <GrapheneVec3>.
the translation vector
Passed, filled in, and returned: a <GrapheneVec3>.
the scale vector
Passed, filled in, and returned: a
<GrapheneQuaternion>.
the rotation quaternion
Passed, filled in, and returned: a <GrapheneVec3>.
the shear vector
Passed, filled in, and returned: a <GrapheneVec4>.
the perspective vector
Returned: a boolean.
true if the matrix could be decomposed
Computes the determinant of the given matrix.
Passed: a <GrapheneMatrix>.
Returned: a real number.
the value of the determinant
Checks whether the two given <GrapheneMatrix>
matrices are byte-by-byte equal.
While this function is faster than matrix:equal?, it can also return false negatives, so it should
be used in conjuction with either matrix:equal? or 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
}
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneMatrix>.
Returned: a boolean.
true if the matrices are equal. and false otherwise
Checks whether the two given <GrapheneMatrix>
matrices are equal.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneMatrix>.
Returned: a boolean.
true if the two matrices are equal, and false otherwise
Frees the resources allocated by matrix:alloc.
Passed: a <GrapheneMatrix>.
Retrieves the given row vector at index- inside a matrix.
Passed: a <GrapheneMatrix>.
Passed: an unsigned 32-bit integer.
the index of the row vector, between 0 and 3
Passed, filled in, and returned: a <GrapheneVec4>.
return location for the <GrapheneVec4> that is used
to store the row vector
Retrieves the value at the given row and col index.
Passed: a <GrapheneMatrix>.
Passed: an unsigned 32-bit integer.
the row index
Passed: an unsigned 32-bit integer.
the column index
Returned: a real number.
the value at the given indices
Retrieves the scaling factor on the X axis in self.
Passed: a <GrapheneMatrix>.
Returned: a real number.
the value of the scaling factor
Retrieves the translation component on the X axis from self.
Passed: a <GrapheneMatrix>.
Returned: a real number.
the translation component
Retrieves the scaling factor on the Y axis in self.
Passed: a <GrapheneMatrix>.
Returned: a real number.
the value of the scaling factor
Retrieves the translation component on the Y axis from self.
Passed: a <GrapheneMatrix>.
Returned: a real number.
the translation component
Retrieves the scaling factor on the Z axis in self.
Passed: a <GrapheneMatrix>.
Returned: a real number.
the value of the scaling factor
Retrieves the translation component on the Z axis from self.
Passed: a <GrapheneMatrix>.
Returned: a real number.
the translation component
Initializes a <GrapheneMatrix> 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 <GrapheneMatrix>.
Passed: a <GrapheneMatrix>.
Passed: a real number.
the xx member
Passed: a real number.
the yx member
Passed: a real number.
the xy member
Passed: a real number.
the yy member
Passed: a real number.
the x0 member
Passed: a real number.
the y0 member
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> with the given array
of floating point values.
Passed: a <GrapheneMatrix>.
Passed: a f32vector, or a list or vector, each a real number.
an array of at least 16 floating point values
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> using the values of
the given matrix.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneMatrix>.
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> with the given four
row vectors.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneVec4>.
the first row vector
Passed: a <GrapheneVec4>.
the second row vector
Passed: a <GrapheneVec4>.
the third row vector
Passed: a <GrapheneVec4>.
the fourth row vector
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> compatible with
<GrapheneFrustum>.
See also: frustum:init-from-matrix
Passed: a <GrapheneMatrix>.
Passed: a real number.
distance of the left clipping plane
Passed: a real number.
distance of the right clipping plane
Passed: a real number.
distance of the bottom clipping plane
Passed: a real number.
distance of the top clipping plane
Passed: a real number.
distance of the near clipping plane
Passed: a real number.
distance of the far clipping plane
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> with the identity
matrix.
Passed: a <GrapheneMatrix>.
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> 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 self to transform a model of such a camera into world-space. However, it is more common to use the inverse of self 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.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneVec3>.
the vector describing the position to look from
Passed: a <GrapheneVec3>.
the vector describing the position to look at
Passed: a <GrapheneVec3>.
the vector describing the world’s upward direction; usually, this is the
vec3-y-axis vector
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> with an orthographic
projection.
Passed: a <GrapheneMatrix>.
Passed: a real number.
the left edge of the clipping plane
Passed: a real number.
the right edge of the clipping plane
Passed: a real number.
the top edge of the clipping plane
Passed: a real number.
the bottom edge of the clipping plane
Passed: a real number.
the distance of the near clipping plane
Passed: a real number.
the distance of the far clipping plane
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> with a perspective
projection.
Passed: a <GrapheneMatrix>.
Passed: a real number.
the field of view angle, in degrees
Passed: a real number.
the aspect value
Passed: a real number.
the near Z plane
Passed: a real number.
the far Z plane
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes self to represent a rotation of angle degrees on the axis represented by the axis vector.
Passed: a <GrapheneMatrix>.
Passed: a real number.
the rotation angle, in degrees
Passed: a <GrapheneVec3>.
the axis vector as a <GrapheneVec3>
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> with the given
scaling factors.
Passed: a <GrapheneMatrix>.
Passed: a real number.
the scale factor on the X axis
Passed: a real number.
the scale factor on the Y axis
Passed: a real number.
the scale factor on the Z axis
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> with a skew
transformation with the given factors.
Passed: a <GrapheneMatrix>.
Passed: a real number.
skew factor, in radians, on the X axis
Passed: a real number.
skew factor, in radians, on the Y axis
Returned: a <GrapheneMatrix>.
the initialized matrix
Initializes a <GrapheneMatrix> with a translation
to the given coordinates.
Passed: a <GrapheneMatrix>.
Passed: a <GraphenePoint3D>.
the translation coordinates
Returned: a <GrapheneMatrix>.
the initialized matrix
Linearly interpolates the two given
<GrapheneMatrix> 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.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneMatrix>.
Passed: a real number.
the linear interpolation factor
Passed, filled in, and returned: a
<GrapheneMatrix>.
return location for the interpolated matrix
Inverts the given matrix.
Passed: a <GrapheneMatrix>.
Passed, filled in, and returned: a
<GrapheneMatrix>.
return location for the inverse matrix
Returned: a boolean.
true if the matrix is invertible
Checks whether the given <GrapheneMatrix> is
compatible with an a 2D affine transformation matrix.
Passed: a <GrapheneMatrix>.
Returned: a boolean.
true if the matrix is compatible with an affine transformation
matrix
Checks whether a <GrapheneMatrix> has a visible
back face.
Passed: a <GrapheneMatrix>.
Returned: a boolean.
true if the back face of the matrix is visible
Checks whether the given <GrapheneMatrix> is the
identity matrix.
Passed: a <GrapheneMatrix>.
Returned: a boolean.
true if the matrix is the identity matrix
Checks whether a matrix is singular.
Passed: a <GrapheneMatrix>.
Returned: a boolean.
true if the matrix is singular
Multiplies two <GrapheneMatrix>.
Matrix multiplication is not commutative in general; the order of the factors matters. The product of this multiplication is (self × b)
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneMatrix>.
Passed, filled in, and returned: a
<GrapheneMatrix>.
return location for the matrix result
Compares the two given <GrapheneMatrix> matrices
and checks whether their values are within the given epsilon of
each other.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneMatrix>.
Passed: a real number.
the threshold between the two matrices
Returned: a boolean.
true if the two matrices are near each other, and false
otherwise
Normalizes the given <GrapheneMatrix>.
Passed: a <GrapheneMatrix>.
Passed, filled in, and returned: a
<GrapheneMatrix>.
return location for the normalized matrix
Applies a perspective of depth to the matrix.
Passed: a <GrapheneMatrix>.
Passed: a real number.
the depth of the perspective
Passed, filled in, and returned: a
<GrapheneMatrix>.
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.
Passed: a <GrapheneMatrix>.
The matrix to print
Projects a <GraphenePoint> using the matrix
self.
Passed: a <GrapheneMatrix>.
Passed: a <GraphenePoint>.
Passed, filled in, and returned: a <GraphenePoint>.
return location for the projected point
Projects all corners of a <GrapheneRect> using the
given matrix.
See also: matrix:project-point!
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GrapheneQuad>.
return location for the projected rectangle
Projects a <GrapheneRect> using the given matrix.
The resulting rectangle is the axis aligned bounding rectangle capable of fully containing the projected rectangle.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GrapheneRect>.
return location for the projected rectangle
Adds a rotation transformation to self, using the given angle and axis vector.
This is the equivalent of calling matrix:init-rotate and then multiplying the matrix
self with the rotation matrix.
Passed: a <GrapheneMatrix>.
Passed: a real number.
the rotation angle, in degrees
Passed: a <GrapheneVec3>.
the rotation axis, as a <GrapheneVec3>
Adds a rotation transformation to self, using the given
<GrapheneEuler>.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneEuler>.
a rotation described by a <GrapheneEuler>
Adds a rotation transformation to self, using the given
<GrapheneQuaternion>.
This is the equivalent of calling quaternion:to-matrix! and then multiplying self with
the rotation matrix.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneQuaternion>.
a rotation described by a <GrapheneQuaternion>
Adds a rotation transformation around the X axis to self, using the given angle.
See also: matrix:rotate
Passed: a <GrapheneMatrix>.
Passed: a real number.
the rotation angle, in degrees
Adds a rotation transformation around the Y axis to self, using the given angle.
See also: matrix:rotate
Passed: a <GrapheneMatrix>.
Passed: a real number.
the rotation angle, in degrees
Adds a rotation transformation around the Z axis to self, using the given angle.
See also: matrix:rotate
Passed: a <GrapheneMatrix>.
Passed: a real number.
the rotation angle, in degrees
Adds a scaling transformation to self, using the three given factors.
This is the equivalent of calling matrix:init-scale and then multiplying the matrix
self with the scale matrix.
Passed: a <GrapheneMatrix>.
Passed: a real number.
scaling factor on the X axis
Passed: a real number.
scaling factor on the Y axis
Passed: a real number.
scaling factor on the Z axis
Adds a skew of factor on the X and Y axis to the given matrix.
Passed: a <GrapheneMatrix>.
Passed: a real number.
skew factor
Adds a skew of factor on the X and Z axis to the given matrix.
Passed: a <GrapheneMatrix>.
Passed: a real number.
skew factor
Adds a skew of factor on the Y and Z axis to the given matrix.
Passed: a <GrapheneMatrix>.
Passed: a real number.
skew factor
Converts a <GrapheneMatrix> 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
<GrapheneMatrix> and an affine matrix type from
other libraries.
Passed: a <GrapheneMatrix>.
Returned: a boolean.
true if the matrix is compatible with an affine transformation
matrix
Returned: a real number.
return location for the xx member
Returned: a real number.
return location for the yx member
Returned: a real number.
return location for the xy member
Returned: a real number.
return location for the yy member
Returned: a real number.
return location for the x0 member
Returned: a real number.
return location for the y0 member
Converts a <GrapheneMatrix> to an array of floating
point values.
Passed: a <GrapheneMatrix>.
Passed: a f32vector, or a list or vector, each a real number. It is filled in, and returned: a f32vector.
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 <GrapheneRect> using the
given matrix self.
The result is the axis aligned bounding rectangle containing the coplanar quadrilateral.
See also: matrix:transform-point!
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GrapheneRect>.
return location for the bounds of the transformed rectangle
Transforms the vertices of a <GrapheneBox> using the
given matrix self.
The result is the axis aligned bounding box containing the transformed vertices.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneBox>.
Passed, filled in, and returned: a <GrapheneBox>.
return location for the bounds of the transformed box
Transforms the given <GraphenePoint> using the
matrix self.
Unlike matrix:transform-vec3!, this
function will take into account the fourth row vector of the
<GrapheneMatrix> when computing the dot product of
each row vector of the matrix.
See also: graphene_simd4x4f_point3_mul()
Passed: a <GrapheneMatrix>.
Passed: a <GraphenePoint>.
Passed, filled in, and returned: a <GraphenePoint>.
return location for the transformed <GraphenePoint>
Transforms the given <GraphenePoint3D> using the
matrix self.
Unlike matrix:transform-vec3!, this
function will take into account the fourth row vector of the
<GrapheneMatrix> when computing the dot product of
each row vector of the matrix.
See also: graphene_simd4x4f_point3_mul()
Passed: a <GrapheneMatrix>.
Passed: a <GraphenePoint3D>.
Passed, filled in, and returned: a
<GraphenePoint3D>.
return location for the result
Transform a <GrapheneRay> using the given matrix
self.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneRay>.
Passed, filled in, and returned: a <GrapheneRay>.
return location for the transformed ray
Transforms each corner of a <GrapheneRect> using the
given matrix self.
The result is a coplanar quadrilateral.
See also: matrix:transform-point!
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneRect>.
Passed, filled in, and returned: a <GrapheneQuad>.
return location for the transformed quad
Transforms a <GrapheneSphere> using the given
matrix self. The result is the bounding sphere containing the
transformed sphere.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneSphere>.
Passed, filled in, and returned: a
<GrapheneSphere>.
return location for the bounds of the transformed sphere
Transforms the given <GrapheneVec3> using the matrix
self.
This function will multiply the X, Y, and Z row vectors of the matrix self with the corresponding components of the vector v. The W row vector will be ignored.
See also: graphene_simd4x4f_vec3_mul()
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneVec3>.
Passed, filled in, and returned: a <GrapheneVec3>.
return location for a <GrapheneVec3>
Transforms the given <GrapheneVec4> using the matrix
self.
See also: graphene_simd4x4f_vec4_mul()
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneVec4>.
Passed, filled in, and returned: a <GrapheneVec4>.
return location for a <GrapheneVec4>
Adds a translation transformation to self using the coordinates of
the given <GraphenePoint3D>.
This is the equivalent of calling matrix:init-translate and then multiplying self
with the translation matrix.
Passed: a <GrapheneMatrix>.
Passed: a <GraphenePoint3D>.
Transposes the given matrix.
Passed: a <GrapheneMatrix>.
Passed, filled in, and returned: a
<GrapheneMatrix>.
return location for the transposed matrix
Unprojects the given point using the self matrix and a modelview matrix.
Passed: a <GrapheneMatrix>.
a <GrapheneMatrix> for the projection matrix
Passed: a <GrapheneMatrix>.
a <GrapheneMatrix> for the modelview matrix; this
is the inverse of the modelview used when projecting the point
Passed: a <GraphenePoint3D>.
a <GraphenePoint3D> with the coordinates of the
point
Passed, filled in, and returned: a
<GraphenePoint3D>.
return location for the unprojected point
Undoes the transformation on the corners of a
<GrapheneRect> using the given matrix, within the
given axis aligned rectangular bounds.
Passed: a <GrapheneMatrix>.
Passed: a <GrapheneRect>.
Passed: a <GrapheneRect>.
the bounds of the transformation
Passed, filled in, and returned: a <GrapheneRect>.
return location for the untransformed rectangle
Undoes the transformation of a <GraphenePoint> using
the given matrix, within the given axis aligned rectangular
bounds.
Passed: a <GrapheneMatrix>.
Passed: a <GraphenePoint>.
Passed: a <GrapheneRect>.
the bounds of the transformation
Passed, filled in, and returned: a <GraphenePoint>.
return location for the untransformed point
Returned: a boolean.
true if the point was successfully untransformed