Module Gg.V3

module V3: sig .. end

type t = Gg.v3 
The type for 3D vectors.
val dim : int
dim is the dimension of vectors of type Gg.v3.
type m = Gg.m3 
The type for matrices representing linear transformations of 3D space.

Constructors, accessors and constants


val v : float -> float -> float -> Gg.v3
v x y z is the vector (x y z).
val comp : int -> Gg.v3 -> float
comp i v is vi, the ith component of v.
Raises Invalid_argument if i is not in [0;Gg.V3.dim[.
val x : Gg.v3 -> float
x v is the x component of v.
val y : Gg.v3 -> float
y v is the y component of v.
val z : Gg.v3 -> float
z v is the z component of v.
val ox : Gg.v3
ox is the unit vector (1. 0. 0.).
val oy : Gg.v3
oy is the unit vector (0. 1. 0.).
val oz : Gg.v3
oz is the unit vector (0. 0. 1.).
val zero : Gg.v3
zero is the neutral element for Gg.V3.add.
val infinity : Gg.v3
infinity is the vector whose components are infinity.
val neg_infinity : Gg.v3
neg_infinity is the vector whose components are neg_infinity.
val basis : int -> Gg.v3
basis i is the ith vector of an orthonormal basis of the vector space Gg.V3.t with inner product Gg.V3.dot.
Raises Invalid_argument if i is not in [0;Gg.V3.dim[.
val of_tuple : float * float * float -> Gg.v3
of_tuple (x, y, z) is v x y z.
val to_tuple : Gg.v3 -> float * float * float
to_tuple v is (x v, y v, z v).
val of_spherical : Gg.v3 -> Gg.v3
of_spherical sv is the vector whose cartesian coordinates (x, y, z) correspond to the radial, azimuth angle and zenith angle spherical coordinates (r, theta, phi) given by (V3.x sv, V2.y sv, V3.z sv).
val to_spherical : Gg.v3 -> Gg.v3
to_spherical v is the vector whose coordinate (r, theta, phi) are the radial, azimuth angle and zenith angle spherical coordinates of v. theta is in [-pi;pi] and phi in [0;pi].
val of_v2 : Gg.v2 -> z:float -> Gg.v3
of_v2 u z is v (V2.x u) (V2.y u) z.
val of_v4 : Gg.v4 -> Gg.v3
of_v4 u z is v (V4.x u) (V4.y u) (V4.z u).

Functions


val neg : Gg.v3 -> Gg.v3
neg v is the inverse vector -v.
val add : Gg.v3 -> Gg.v3 -> Gg.v3
add u v is the vector addition u + v.
val sub : Gg.v3 -> Gg.v3 -> Gg.v3
sub u v is the vector subtraction u - v.
val mul : Gg.v3 -> Gg.v3 -> Gg.v3
mul u v is the component wise multiplication u * v.
val div : Gg.v3 -> Gg.v3 -> Gg.v3
div u v is the component wise division u / v.
val smul : float -> Gg.v3 -> Gg.v3
smul s v is the scalar multiplication sv.
val half : Gg.v3 -> Gg.v3
half v is the half vector smul 0.5 v.
val cross : Gg.v3 -> Gg.v3 -> Gg.v3
cross u v is the cross product u x v.
val dot : Gg.v3 -> Gg.v3 -> float
dot u v is the dot product u.v.
val norm : Gg.v3 -> float
norm v is the norm |v| = sqrt v.v.
val norm2 : Gg.v3 -> float
norm2 v is the squared norm |v|2 .
val unit : Gg.v3 -> Gg.v3
unit v is the unit vector v/|v|.
val spherical : float -> float -> float -> Gg.v3
spherical r theta phi is of_spherical (V3.v r theta phi).
val azimuth : Gg.v3 -> float
azimuth v is the azimuth angle spherical coordinates of v. The result is in [-pi;pi].
val zenith : Gg.v3 -> float
zenith v is the zenith angle spherical coordinates of v. The result is in [0;pi].
val homogene : Gg.v3 -> Gg.v3
homogene v is the vector v/vz if vz <> 0 and v otherwise.
val mix : Gg.v3 -> Gg.v3 -> float -> Gg.v3
mix u v t is the linear interpolation u + t(v - u).
val ltr : Gg.m3 -> Gg.v3 -> Gg.v3
ltr m v is the linear transform mv.
val tr : Gg.m4 -> Gg.v3 -> Gg.v3
tr m v is the affine transform in homogenous 3D space of the vector v by m.

Note. Since m is supposed to be affine the function ignores the last row of m. v is treated as a vector (infinite point, its last coordinate in homogenous space is 0) and is thus translationally invariant. Use Gg.P3.tr to transform finite points.


Overridden Pervasives operators


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

Traversal


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

Predicates and comparisons


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

Printers


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