1.4 <GrapheneMatrix>

Structure: <GrapheneMatrix>

A structure capable of holding a 4x4 matrix.

The contents of the <GrapheneMatrix> structure are private and should never be accessed directly.

Procedures

Procedure: matrix:alloc ⇒ %return

Allocates a new <GrapheneMatrix>.

%return

Returned: a <GrapheneMatrix>.

the newly allocated matrix

Method: matrix:decompose! self translate scale rotate shear perspective ⇒ %return translate scale rotate shear perspective
Method: decompose! self translate scale rotate shear perspective ⇒ %return translate scale rotate shear perspective

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.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

translate

Passed, filled in, and returned: a <GrapheneVec3>.

the translation vector

scale

Passed, filled in, and returned: a <GrapheneVec3>.

the scale vector

rotate

Passed, filled in, and returned: a <GrapheneQuaternion>.

the rotation quaternion

shear

Passed, filled in, and returned: a <GrapheneVec3>.

the shear vector

perspective

Passed, filled in, and returned: a <GrapheneVec4>.

the perspective vector

%return

Returned: a boolean.

true if the matrix could be decomposed

Method: matrix:determinant self ⇒ %return
Method: determinant self ⇒ %return

Computes the determinant of the given matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a real number.

the value of the determinant

Method: matrix:equal-fast? self b ⇒ %return
Method: equal-fast? self b ⇒ %return

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
    }
self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

b

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a boolean.

true if the matrices are equal. and false otherwise

Method: matrix:equal? self b ⇒ %return
Method: equal? self b ⇒ %return

Checks whether the two given <GrapheneMatrix> matrices are equal.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

b

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a boolean.

true if the two matrices are equal, and false otherwise

Method: matrix:free self
Method: free self

Frees the resources allocated by matrix:alloc.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

Method: matrix:get-row! self index- res ⇒ res
Method: get-row! self index- res ⇒ res

Retrieves the given row vector at index- inside a matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

index-

Passed: an unsigned 32-bit integer.

the index of the row vector, between 0 and 3

res

Passed, filled in, and returned: a <GrapheneVec4>.

return location for the <GrapheneVec4> that is used to store the row vector

Method: matrix:get-value self row col ⇒ %return
Method: get-value self row col ⇒ %return

Retrieves the value at the given row and col index.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

row

Passed: an unsigned 32-bit integer.

the row index

col

Passed: an unsigned 32-bit integer.

the column index

%return

Returned: a real number.

the value at the given indices

Method: matrix:get-x-scale self ⇒ %return
Method: get-x-scale self ⇒ %return

Retrieves the scaling factor on the X axis in self.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a real number.

the value of the scaling factor

Method: matrix:get-x-translation self ⇒ %return
Method: get-x-translation self ⇒ %return

Retrieves the translation component on the X axis from self.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a real number.

the translation component

Method: matrix:get-y-scale self ⇒ %return
Method: get-y-scale self ⇒ %return

Retrieves the scaling factor on the Y axis in self.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a real number.

the value of the scaling factor

Method: matrix:get-y-translation self ⇒ %return
Method: get-y-translation self ⇒ %return

Retrieves the translation component on the Y axis from self.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a real number.

the translation component

Method: matrix:get-z-scale self ⇒ %return
Method: get-z-scale self ⇒ %return

Retrieves the scaling factor on the Z axis in self.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a real number.

the value of the scaling factor

Method: matrix:get-z-translation self ⇒ %return
Method: get-z-translation self ⇒ %return

Retrieves the translation component on the Z axis from self.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a real number.

the translation component

Method: matrix:init-from-2d self xx yx xy yy x-0 y-0 ⇒ %return
Method: init-from-2d self xx yx xy yy x-0 y-0 ⇒ %return

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>.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

xx

Passed: a real number.

the xx member

yx

Passed: a real number.

the yx member

xy

Passed: a real number.

the xy member

yy

Passed: a real number.

the yy member

x-0

Passed: a real number.

the x0 member

y-0

Passed: a real number.

the y0 member

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-from-float self v ⇒ %return
Method: init-from-float self v ⇒ %return

Initializes a <GrapheneMatrix> with the given array of floating point values.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

v

Passed: a f32vector, or a list or vector, each a real number.

an array of at least 16 floating point values

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-from-matrix self src ⇒ %return
Method: init-from-matrix self src ⇒ %return

Initializes a <GrapheneMatrix> using the values of the given matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

src

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-from-vec4 self v0 v1 v2 v3 ⇒ %return
Method: init-from-vec4 self v0 v1 v2 v3 ⇒ %return

Initializes a <GrapheneMatrix> with the given four row vectors.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

v0

Passed: a <GrapheneVec4>.

the first row vector

v1

Passed: a <GrapheneVec4>.

the second row vector

v2

Passed: a <GrapheneVec4>.

the third row vector

v3

Passed: a <GrapheneVec4>.

the fourth row vector

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-frustum self left right bottom top z-near z-far ⇒ %return
Method: init-frustum self left right bottom top z-near z-far ⇒ %return

Initializes a <GrapheneMatrix> compatible with <GrapheneFrustum>.

See also: frustum:init-from-matrix

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

left

Passed: a real number.

distance of the left clipping plane

right

Passed: a real number.

distance of the right clipping plane

bottom

Passed: a real number.

distance of the bottom clipping plane

top

Passed: a real number.

distance of the top clipping plane

z-near

Passed: a real number.

distance of the near clipping plane

z-far

Passed: a real number.

distance of the far clipping plane

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-identity self ⇒ %return
Method: init-identity self ⇒ %return

Initializes a <GrapheneMatrix> with the identity matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-look-at self eye center up ⇒ %return
Method: init-look-at self eye center up ⇒ %return

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.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

eye

Passed: a <GrapheneVec3>.

the vector describing the position to look from

center

Passed: a <GrapheneVec3>.

the vector describing the position to look at

up

Passed: a <GrapheneVec3>.

the vector describing the world’s upward direction; usually, this is the vec3-y-axis vector

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-ortho self left right top bottom z-near z-far ⇒ %return
Method: init-ortho self left right top bottom z-near z-far ⇒ %return

Initializes a <GrapheneMatrix> with an orthographic projection.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

left

Passed: a real number.

the left edge of the clipping plane

right

Passed: a real number.

the right edge of the clipping plane

top

Passed: a real number.

the top edge of the clipping plane

bottom

Passed: a real number.

the bottom edge of the clipping plane

z-near

Passed: a real number.

the distance of the near clipping plane

z-far

Passed: a real number.

the distance of the far clipping plane

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-perspective self fovy aspect z-near z-far ⇒ %return
Method: init-perspective self fovy aspect z-near z-far ⇒ %return

Initializes a <GrapheneMatrix> with a perspective projection.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

fovy

Passed: a real number.

the field of view angle, in degrees

aspect

Passed: a real number.

the aspect value

z-near

Passed: a real number.

the near Z plane

z-far

Passed: a real number.

the far Z plane

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-rotate self angle axis ⇒ %return
Method: init-rotate self angle axis ⇒ %return

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

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

angle

Passed: a real number.

the rotation angle, in degrees

axis

Passed: a <GrapheneVec3>.

the axis vector as a <GrapheneVec3>

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-scale self x y z ⇒ %return
Method: init-scale self x y z ⇒ %return

Initializes a <GrapheneMatrix> with the given scaling factors.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

x

Passed: a real number.

the scale factor on the X axis

y

Passed: a real number.

the scale factor on the Y axis

z

Passed: a real number.

the scale factor on the Z axis

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-skew self x-skew y-skew ⇒ %return
Method: init-skew self x-skew y-skew ⇒ %return

Initializes a <GrapheneMatrix> with a skew transformation with the given factors.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

x-skew

Passed: a real number.

skew factor, in radians, on the X axis

y-skew

Passed: a real number.

skew factor, in radians, on the Y axis

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:init-translate self p ⇒ %return
Method: init-translate self p ⇒ %return

Initializes a <GrapheneMatrix> with a translation to the given coordinates.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

p

Passed: a <GraphenePoint3D>.

the translation coordinates

%return

Returned: a <GrapheneMatrix>.

the initialized matrix

Method: matrix:interpolate! self b factor res ⇒ res
Method: interpolate! self b factor res ⇒ res

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.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

b

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

factor

Passed: a real number.

the linear interpolation factor

res

Passed, filled in, and returned: a <GrapheneMatrix>.

return location for the interpolated matrix

Method: matrix:inverse! self res ⇒ %return res
Method: inverse! self res ⇒ %return res

Inverts the given matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

res

Passed, filled in, and returned: a <GrapheneMatrix>.

return location for the inverse matrix

%return

Returned: a boolean.

true if the matrix is invertible

Method: matrix:is-2d? self ⇒ %return
Method: is-2d? self ⇒ %return

Checks whether the given <GrapheneMatrix> is compatible with an a 2D affine transformation matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a boolean.

true if the matrix is compatible with an affine transformation matrix

Method: matrix:is-backface-visible? self ⇒ %return
Method: is-backface-visible? self ⇒ %return

Checks whether a <GrapheneMatrix> has a visible back face.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a boolean.

true if the back face of the matrix is visible

Method: matrix:is-identity? self ⇒ %return
Method: is-identity? self ⇒ %return

Checks whether the given <GrapheneMatrix> is the identity matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a boolean.

true if the matrix is the identity matrix

Method: matrix:is-singular? self ⇒ %return
Method: is-singular? self ⇒ %return

Checks whether a matrix is singular.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a boolean.

true if the matrix is singular

Method: matrix:multiply! self b res ⇒ res
Method: multiply! self b res ⇒ res

Multiplies two <GrapheneMatrix>.

Matrix multiplication is not commutative in general; the order of the factors matters. The product of this multiplication is (self × b)

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

b

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

res

Passed, filled in, and returned: a <GrapheneMatrix>.

return location for the matrix result

Method: matrix:near? self b epsilon ⇒ %return
Method: near? self b epsilon ⇒ %return

Compares the two given <GrapheneMatrix> matrices and checks whether their values are within the given epsilon of each other.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

b

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

epsilon

Passed: a real number.

the threshold between the two matrices

%return

Returned: a boolean.

true if the two matrices are near each other, and false otherwise

Method: matrix:normalize! self res ⇒ res
Method: normalize! self res ⇒ res

Normalizes the given <GrapheneMatrix>.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

res

Passed, filled in, and returned: a <GrapheneMatrix>.

return location for the normalized matrix

Method: matrix:perspective! self depth res ⇒ res
Method: perspective! self depth res ⇒ res

Applies a perspective of depth to the matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

depth

Passed: a real number.

the depth of the perspective

res

Passed, filled in, and returned: a <GrapheneMatrix>.

return location for the perspective matrix

Method: matrix:print self
Method: print self

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.

self

Passed: a <GrapheneMatrix>.

The matrix to print

Method: matrix:project-point! self p res ⇒ res
Method: project-point! self p res ⇒ res

Projects a <GraphenePoint> using the matrix self.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

p

Passed: a <GraphenePoint>.

a <GraphenePoint>

res

Passed, filled in, and returned: a <GraphenePoint>.

return location for the projected point

Method: matrix:project-rect! self r res ⇒ res
Method: project-rect! self r res ⇒ res

Projects all corners of a <GrapheneRect> using the given matrix.

See also: matrix:project-point!

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

r

Passed: a <GrapheneRect>.

a <GrapheneRect>

res

Passed, filled in, and returned: a <GrapheneQuad>.

return location for the projected rectangle

Method: matrix:project-rect-bounds! self r res ⇒ res
Method: project-rect-bounds! self r res ⇒ res

Projects a <GrapheneRect> using the given matrix.

The resulting rectangle is the axis aligned bounding rectangle capable of fully containing the projected rectangle.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

r

Passed: a <GrapheneRect>.

a <GrapheneRect>

res

Passed, filled in, and returned: a <GrapheneRect>.

return location for the projected rectangle

Method: matrix:rotate self angle axis
Method: rotate self angle axis

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.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

angle

Passed: a real number.

the rotation angle, in degrees

axis

Passed: a <GrapheneVec3>.

the rotation axis, as a <GrapheneVec3>

Method: matrix:rotate-euler self e
Method: rotate-euler self e

Adds a rotation transformation to self, using the given <GrapheneEuler>.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

e

Passed: a <GrapheneEuler>.

a rotation described by a <GrapheneEuler>

Method: matrix:rotate-quaternion self q
Method: rotate-quaternion self q

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.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

q

Passed: a <GrapheneQuaternion>.

a rotation described by a <GrapheneQuaternion>

Method: matrix:rotate-x self angle
Method: rotate-x self angle

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

See also: matrix:rotate

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

angle

Passed: a real number.

the rotation angle, in degrees

Method: matrix:rotate-y self angle
Method: rotate-y self angle

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

See also: matrix:rotate

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

angle

Passed: a real number.

the rotation angle, in degrees

Method: matrix:rotate-z self angle
Method: rotate-z self angle

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

See also: matrix:rotate

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

angle

Passed: a real number.

the rotation angle, in degrees

Method: matrix:scale self factor-x factor-y factor-z
Method: scale self factor-x factor-y factor-z

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.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

factor-x

Passed: a real number.

scaling factor on the X axis

factor-y

Passed: a real number.

scaling factor on the Y axis

factor-z

Passed: a real number.

scaling factor on the Z axis

Method: matrix:skew-xy self factor
Method: skew-xy self factor

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

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

factor

Passed: a real number.

skew factor

Method: matrix:skew-xz self factor
Method: skew-xz self factor

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

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

factor

Passed: a real number.

skew factor

Method: matrix:skew-yz self factor
Method: skew-yz self factor

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

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

factor

Passed: a real number.

skew factor

Method: matrix:to-2d self ⇒ %return xx yx xy yy x-0 y-0
Method: to-2d self ⇒ %return xx yx xy yy x-0 y-0

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.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

%return

Returned: a boolean.

true if the matrix is compatible with an affine transformation matrix

xx

Returned: a real number.

return location for the xx member

yx

Returned: a real number.

return location for the yx member

xy

Returned: a real number.

return location for the xy member

yy

Returned: a real number.

return location for the yy member

x-0

Returned: a real number.

return location for the x0 member

y-0

Returned: a real number.

return location for the y0 member

Method: matrix:to-float! self v ⇒ v
Method: to-float! self v ⇒ v

Converts a <GrapheneMatrix> to an array of floating point values.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

v

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.

Method: matrix:transform-bounds! self r res ⇒ res
Method: transform-bounds! self r res ⇒ res

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!

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

r

Passed: a <GrapheneRect>.

a <GrapheneRect>

res

Passed, filled in, and returned: a <GrapheneRect>.

return location for the bounds of the transformed rectangle

Method: matrix:transform-box! self b res ⇒ res
Method: transform-box! self b res ⇒ res

Transforms the vertices of a <GrapheneBox> using the given matrix self.

The result is the axis aligned bounding box containing the transformed vertices.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

b

Passed: a <GrapheneBox>.

a <GrapheneBox>

res

Passed, filled in, and returned: a <GrapheneBox>.

return location for the bounds of the transformed box

Method: matrix:transform-point! self p res ⇒ res
Method: transform-point! self p res ⇒ res

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

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

p

Passed: a <GraphenePoint>.

a <GraphenePoint>

res

Passed, filled in, and returned: a <GraphenePoint>.

return location for the transformed <GraphenePoint>

Method: matrix:transform-point3d! self p res ⇒ res
Method: transform-point3d! self p res ⇒ res

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

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

p

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

res

Passed, filled in, and returned: a <GraphenePoint3D>.

return location for the result

Method: matrix:transform-ray! self r res ⇒ res
Method: transform-ray! self r res ⇒ res

Transform a <GrapheneRay> using the given matrix self.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

r

Passed: a <GrapheneRay>.

a <GrapheneRay>

res

Passed, filled in, and returned: a <GrapheneRay>.

return location for the transformed ray

Method: matrix:transform-rect! self r res ⇒ res
Method: transform-rect! self r res ⇒ res

Transforms each corner of a <GrapheneRect> using the given matrix self.

The result is a coplanar quadrilateral.

See also: matrix:transform-point!

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

r

Passed: a <GrapheneRect>.

a <GrapheneRect>

res

Passed, filled in, and returned: a <GrapheneQuad>.

return location for the transformed quad

Method: matrix:transform-sphere! self s res ⇒ res
Method: transform-sphere! self s res ⇒ res

Transforms a <GrapheneSphere> using the given matrix self. The result is the bounding sphere containing the transformed sphere.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

s

Passed: a <GrapheneSphere>.

a <GrapheneSphere>

res

Passed, filled in, and returned: a <GrapheneSphere>.

return location for the bounds of the transformed sphere

Method: matrix:transform-vec3! self v res ⇒ res
Method: transform-vec3! self v res ⇒ res

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

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

v

Passed: a <GrapheneVec3>.

a <GrapheneVec3>

res

Passed, filled in, and returned: a <GrapheneVec3>.

return location for a <GrapheneVec3>

Method: matrix:transform-vec4! self v res ⇒ res
Method: transform-vec4! self v res ⇒ res

Transforms the given <GrapheneVec4> using the matrix self.

See also: graphene_simd4x4f_vec4_mul()

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

v

Passed: a <GrapheneVec4>.

a <GrapheneVec4>

res

Passed, filled in, and returned: a <GrapheneVec4>.

return location for a <GrapheneVec4>

Method: matrix:translate self pos
Method: translate self pos

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.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

pos

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D>

Method: matrix:transpose! self res ⇒ res
Method: transpose! self res ⇒ res

Transposes the given matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

res

Passed, filled in, and returned: a <GrapheneMatrix>.

return location for the transposed matrix

Method: matrix:unproject-point3d! self modelview point res ⇒ res
Method: unproject-point3d! self modelview point res ⇒ res

Unprojects the given point using the self matrix and a modelview matrix.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix> for the projection matrix

modelview

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix> for the modelview matrix; this is the inverse of the modelview used when projecting the point

point

Passed: a <GraphenePoint3D>.

a <GraphenePoint3D> with the coordinates of the point

res

Passed, filled in, and returned: a <GraphenePoint3D>.

return location for the unprojected point

Method: matrix:untransform-bounds! self r bounds res ⇒ res
Method: untransform-bounds! self r bounds res ⇒ res

Undoes the transformation on the corners of a <GrapheneRect> using the given matrix, within the given axis aligned rectangular bounds.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

r

Passed: a <GrapheneRect>.

a <GrapheneRect>

bounds

Passed: a <GrapheneRect>.

the bounds of the transformation

res

Passed, filled in, and returned: a <GrapheneRect>.

return location for the untransformed rectangle

Method: matrix:untransform-point! self p bounds res ⇒ %return res
Method: untransform-point! self p bounds res ⇒ %return res

Undoes the transformation of a <GraphenePoint> using the given matrix, within the given axis aligned rectangular bounds.

self

Passed: a <GrapheneMatrix>.

a <GrapheneMatrix>

p

Passed: a <GraphenePoint>.

a <GraphenePoint>

bounds

Passed: a <GrapheneRect>.

the bounds of the transformation

res

Passed, filled in, and returned: a <GraphenePoint>.

return location for the untransformed point

%return

Returned: a boolean.

true if the point was successfully untransformed