Module Gg.M3
type t
= m3
The type for 3D square matrices.
type v
= v3
The type for rows and columns as vectors.
Constructors, accessors and constants
val v : float -> float -> float -> float -> float -> float -> float -> float -> float -> m3
v e00 e01 e02 e10 e11 e12 e20 e21 e22
is a matrix whose components are specified in row-major order
val el : int -> int -> m3 -> float
el i j a
is the elementa
ij
. See also the direct element accessors.- raises Invalid_argument
if
i
orj
is not in [0;
dim
[.
val col : int -> m3 -> v3
col j a
is thej
th column ofa
.- raises Invalid_argument
if
j
is not in [0;
dim
[.
Functions
val mul : m3 -> m3 -> m3
mul a b
is the matrix multiplicationa * b
.
val trace : m3 -> float
trace a
is the matrix tracetrace(a)
.
val det : m3 -> float
det a
is the determinant|a|
.
val inv : m3 -> m3
inv a
is the inverse matrixa
-1.
2D space transformations
val rot2 : ?pt:p2 -> float -> m3
rot2 pt theta
rotates 2D space around the pointpt
bytheta
radians.pt
defaults toP2.o
.
3D space transformations
val rot3_map : v3 -> v3 -> m3
rot3_map u v
rotates 3D space to map the unit vectoru
on the unit vectorv
.
val rot3_axis : v3 -> float -> m3
rot_axis v theta
rotates 3D space bytheta
radians around the unit vectorv
.
Traversal
val mapi : (int -> int -> float -> float) -> m3 -> m3
mapi f a
is likemap
but the element indices are also given.
val fold : ('a -> float -> 'a) -> 'a -> m3 -> 'a
fold f acc a
isf (
...(f (f acc a
00) a
10)
...)
.
val foldi : ('a -> int -> int -> float -> 'a) -> 'a -> m3 -> 'a
foldi f acc a
isf (
...(f (f acc 0 0 a
00) 1 0 a
10)
...)
.
val iter : (float -> unit) -> m3 -> unit
iter f a
isf a
00; f a
10;
...
val iteri : (int -> int -> float -> unit) -> m3 -> unit
iteri f a
isf 0 0 a
00; f 1 0 a
10;
...
Predicates and comparisons
val for_all : (float -> bool) -> m3 -> bool
for_all p a
isp a
00&& p a
10&&
...
val exists : (float -> bool) -> m3 -> bool
exists p a
isp a
00|| p a
10||
...
val equal_f : (float -> float -> bool) -> m3 -> m3 -> bool
equal_f eq a b
testsa
andb
likeequal
but useseq
to test floating point values.
Printers
val pp : Stdlib.Format.formatter -> m3 -> unit
pp ppf a
prints a textual representation ofa
onppf
.
val pp_f : (Stdlib.Format.formatter -> float -> unit) -> Stdlib.Format.formatter -> m3 -> unit
pp_f pp_e ppf a
printsa
likepp
but usespp_e
to print floating point values.