Library
Module
Module type
Parameter
Class
Class type
A 2d affine transformation matrix.
val id : t
The identity matrix.
val trace : t -> float
trace t
Sum the elements on the main diagonal (upper left to lower right) of t
.
val get : t -> int -> int -> float
get t r c
Get the element at r
ow and c
olumn of t
. Equivalent to t.(r).(c)
. Raises Invalid_argument
if access is out of bounds.
compose a b
Compose the affine transformations a
and b
. Equivalent to mul b a
, which when applied, will perform the transformation a
, then the transformation b
.
a % b
Mathematical composition of affine transformations a
and b
, equivalent to mul a b
.
of_rows rows
Create an 2d affine transformation matrix from two rows. The last row is set to 0., 0., 1.
.
val of_row_matrix_exn : float array array -> t
of_row_matrix_exn m
Convert the float matrix m
into a t
if it is the correct shape (3 x 3), otherwise raise Invalid_argument
.
of_row_matrix m
Convert the float matrix m
into a t
if it is the correct shape (3 x 3).
translation v
Create a 2d affine transformation matrix from the xy translation vector v
.
val xtrans : float -> t
xtrans x
Create a 2d affine transformation matrix that applies a translation of x
distance along the x-axis.
val ytrans : float -> t
ytrans y
Create a 2d affine transformation matrix that applies a translation of y
distance along the y-axis.
rotate ?about r
Create an affine transformation matrix that applies a rotation of r
radians around the origin (or the point about
if provided).
zrot ?about r
Create an affine transformation matrix that applies a rotation of r
radians around the origin (or the point about
if provided). Alias of rotate
.
align a b
Compute an affine transformation matrix that would bring the vector a
into alignment with b
.
val xscale : float -> t
xscale x
Create a 2d affine transformation matrix that applies x-axis scaling.
val yscale : float -> t
yscale y
Create a 2d affine transformation matrix that applies y-axis scaling.
mirror ax
Create an affine transformation matrix that applies a reflection across the axis ax
.
val skew : float -> float -> t
skew xa ya
Create an affine transformation matrix that applies a skew transformation along the xy plane.
xa
: skew angle (in radians) in the direction of the x-axisya
: skew angle (in radians) in the direction of the y-axistransform t v
Apply the 2d affine transformation matrix t
to the vector v
.
val to_string : t -> string