Module type Gg.V

module type V = sig .. end
Implemented by all vector types.

type t 
The type for vectors.
val dim : int
dim is the dimension of vectors of type Gg.V.t.
type m 
The type for matrices representing linear transformations of Gg.V.dim space.

Constructors, accessors and constants


val comp : int -> t -> float
comp i v is vi, the ith component of v.
Raises Invalid_argument if i is not in [0;Gg.V.dim[.
val zero : t
zero is the neutral element for Gg.V.add.
val infinity : t
infinity is the vector whose components are infinity.
val neg_infinity : t
neg_infinity is the vector whose components are neg_infinity.
val basis : int -> t
basis i is the ith vector of an orthonormal basis of the vector space Gg.V.t with inner product Gg.V.dot.
Raises Invalid_argument if i is not in [0;Gg.V.dim[.

Functions


val neg : t -> t
neg v is the inverse vector -v.
val add : t -> t -> t
add u v is the vector addition u + v.
val sub : t -> t -> t
sub u v is the vector subtraction u - v.
val mul : t -> t -> t
mul u v is the component wise multiplication u * v.
val div : t -> t -> t
div u v is the component wise division u / v.
val smul : float -> t -> t
smul s v is the scalar multiplication sv.
val half : t -> t
half v is the half vector smul 0.5 v.
val dot : t -> t -> float
dot u v is the dot product u.v.
val norm : t -> float
norm v is the norm |v| = sqrt v.v.
val norm2 : t -> float
norm2 v is the squared norm |v|2 .
val unit : t -> t
unit v is the unit vector v/|v|.
val homogene : t -> t
homogene v is the vector v/(comp (dim - 1) v) if comp (dim - 1) v <> 0 and v otherwise.
val mix : t -> t -> float -> t
mix u v t is the linear interpolation u + t(v - u).
val ltr : m -> t -> t
ltr m v is the linear transform mv.

Overridden Pervasives operators


val (+) : t -> t -> t
u + v is add u v.
val (-) : t -> t -> t
u - v is sub u v.
val ( * ) : float -> t -> t
t * v is smul t v.
val (/) : t -> float -> t
v / t is smul (1. /. t) v.

Traversal


val map : (float -> float) -> t -> t
map f v is the component wise application of f to v.
val mapi : (int -> float -> float) -> t -> t
mapi f v is like Gg.V.map but the component index is also given.
val fold : ('a -> float -> 'a) -> 'a -> t -> 'a
fold f acc v is f (...(f (f acc v0) v1)...).
val foldi : ('a -> int -> float -> 'a) -> 'a -> t -> 'a
foldi f acc v is f (...(f (f acc 0 v0) 1 v1)...).
val iter : (float -> unit) -> t -> unit
iter f v is f v0; f v1; ...
val iteri : (int -> float -> unit) -> t -> unit
iteri f v is f 0 v0; f 1 v1; ...

Predicates and comparisons


val for_all : (float -> bool) -> t -> bool
for_all p v is p v0 && p v1 && ...
val exists : (float -> bool) -> t -> bool
exists p v is p v0 || p v1 || ...
val equal : t -> t -> bool
equal u v is u = v.
val equal_f : (float -> float -> bool) -> t -> t -> bool
equal_f eq u v tests u and v like Gg.V.equal but uses eq to test floating point values.
val compare : t -> t -> int
compare u v is Pervasives.compare u v.
val compare_f : (float -> float -> int) -> t -> t -> int
compare_f cmp u v compares u and v like Gg.V.compare but uses cmp to compare floating point values.

Printers


val pp : Format.formatter -> t -> unit
pp ppf v prints a textual representation of v on ppf.
val pp_f : (Format.formatter -> float -> unit) -> Format.formatter -> t -> unit
pp_f pp_comp ppf v prints v like Gg.V.pp but uses pp_comp to print floating point values.