Module Gg.V4
type t
= v4
The type for 4D vectors.
val dim : int
dim
is the dimension of vectors of typev4
.
type m
= m4
The type for matrices representing linear transformations of 4D space.
Constructors, accessors and constants
val v : float -> float -> float -> float -> v4
v x y z w
is the vector(x y z w)
.
val comp : int -> v4 -> float
comp i v
isv
i
, thei
th component ofv
.- raises Invalid_argument
if
i
is not in [0;
dim
[.
val x : v4 -> float
x v
is the x component ofv
.
val y : v4 -> float
y v
is the y component ofv
.
val z : v4 -> float
z v
is the z component ofv
.
val w : v4 -> float
z v
is the z component ofv
.
val ox : v4
ox
is the unit vector(1. 0. 0. 0.)
.
val oy : v4
oy
is the unit vector(0. 1. 0. 0.)
.
val oz : v4
oz
is the unit vector(0. 0. 1. 0.)
.
val ow : v4
ow
is the unit vector(0. 0. 0. 1.)
.
val infinity : v4
infinity
is the vector whose components areinfinity
.
val neg_infinity : v4
neg_infinity
is the vector whose components areneg_infinity
.
val basis : int -> v4
basis i
is thei
th vector of an orthonormal basis of the vector spacet
with inner productdot
.- raises Invalid_argument
if
i
is not in [0;
dim
[.
val of_tuple : (float * float * float * float) -> v4
of_tuple (x, y, z, w)
isv x y z w
.
val to_tuple : v4 -> float * float * float * float
to_tuple v
is(x v, y v, z v, w v)
.
Functions
val dot : v4 -> v4 -> float
dot u v
is the dot productu.v
.
val norm : v4 -> float
norm v
is the norm|v| = sqrt v.v
.
val norm2 : v4 -> float
norm2 v
is the squared norm|v|
2 .
val ltr : m4 -> v4 -> v4
ltr m v
is the linear transformmv
.
Overridden Pervasives
operators
Traversal
val mapi : (int -> float -> float) -> v4 -> v4
mapi f v
is likemap
but the component index is also given.
val fold : ('a -> float -> 'a) -> 'a -> v4 -> 'a
fold f acc v
isf (
...(f (f acc v
0) v
1)
...)
.
val foldi : ('a -> int -> float -> 'a) -> 'a -> v4 -> 'a
foldi f acc v
isf (
...(f (f acc 0 v
0) 1 v
1)
...)
.
val iter : (float -> unit) -> v4 -> unit
iter f v
isf v
0; f v
1;
...
val iteri : (int -> float -> unit) -> v4 -> unit
iteri f v
isf 0 v
0; f 1 v
1;
...
Predicates and comparisons
val for_all : (float -> bool) -> v4 -> bool
for_all p v
isp v
0&& p v
1&&
...
val exists : (float -> bool) -> v4 -> bool
exists p v
isp v
0|| p v
1||
...
Printers
val pp : Stdlib.Format.formatter -> v4 -> unit
pp ppf v
prints a textual representation ofv
onppf
.
val pp_f : (Stdlib.Format.formatter -> float -> unit) -> Stdlib.Format.formatter -> v4 -> unit
pp_f pp_comp ppf v
printsv
likepp
but usespp_comp
to print floating point values.