Module Gg.V3
type t= v3The type for 3D vectors.
val dim : intdimis the dimension of vectors of typev3.
type m= m3The type for matrices representing linear transformations of 3D space.
Constructors, accessors and constants
val v : float -> float -> float -> v3v x y zis the vector(x y z).
val comp : int -> v3 -> floatcomp i visvi, theith component ofv.- raises Invalid_argument
if
iis not in [0;dim[.
val x : v3 -> floatx vis the x component ofv.
val y : v3 -> floaty vis the y component ofv.
val z : v3 -> floatz vis the z component ofv.
val ox : v3oxis the unit vector(1. 0. 0.).
val oy : v3oyis the unit vector(0. 1. 0.).
val oz : v3ozis the unit vector(0. 0. 1.).
val infinity : v3infinityis the vector whose components areinfinity.
val neg_infinity : v3neg_infinityis the vector whose components areneg_infinity.
val basis : int -> v3basis iis theith vector of an orthonormal basis of the vector spacetwith inner productdot.- raises Invalid_argument
if
iis not in [0;dim[.
val of_tuple : (float * float * float) -> v3of_tuple (x, y, z)isv x y z.
val to_tuple : v3 -> float * float * floatto_tuple vis(x v, y v, z v).
val of_spherical : v3 -> v3of_spherical svis 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 : v3 -> v3to_spherical vis the vector whose coordinate(r, theta, phi)are the radial, azimuth angle and zenith angle spherical coordinates ofv.thetais in [-pi;pi] andphiin [0;pi].
Functions
val cross : v3 -> v3 -> v3cross u vis the cross productu x v.
val dot : v3 -> v3 -> floatdot u vis the dot productu.v.
val norm : v3 -> floatnorm vis the norm|v| = sqrt v.v.
val norm2 : v3 -> floatnorm2 vis the squared norm|v|2 .
val spherical : float -> float -> float -> v3spherical r theta phiisof_spherical (V3.v r theta phi).
val azimuth : v3 -> floatazimuth vis the azimuth angle spherical coordinates ofv. The result is in [-pi;pi].
val zenith : v3 -> floatzenith vis the zenith angle spherical coordinates ofv. The result is in [0;pi].
val ltr : m3 -> v3 -> v3ltr m vis the linear transformmv.
val tr : m4 -> v3 -> v3tr m vis the affine transform in homogenous 3D space of the vectorvbym.Note. Since
mis supposed to be affine the function ignores the last row ofm.vis treated as a vector (infinite point, its last coordinate in homogenous space is 0) and is thus translationally invariant. UseP3.trto transform finite points.
Overridden Pervasives operators
Traversal
val mapi : (int -> float -> float) -> v3 -> v3mapi f vis likemapbut the component index is also given.
val fold : ('a -> float -> 'a) -> 'a -> v3 -> 'afold f acc visf (...(f (f acc v0) v1)...).
val foldi : ('a -> int -> float -> 'a) -> 'a -> v3 -> 'afoldi f acc visf (...(f (f acc 0 v0) 1 v1)...).
val iter : (float -> unit) -> v3 -> unititer f visf v0; f v1;...
val iteri : (int -> float -> unit) -> v3 -> unititeri f visf 0 v0; f 1 v1;...
Predicates and comparisons
val for_all : (float -> bool) -> v3 -> boolfor_all p visp v0&& p v1&&...
val exists : (float -> bool) -> v3 -> boolexists p visp v0|| p v1||...
Printers
val pp : Stdlib.Format.formatter -> v3 -> unitpp ppf vprints a textual representation ofvonppf.
val pp_f : (Stdlib.Format.formatter -> float -> unit) -> Stdlib.Format.formatter -> v3 -> unitpp_f pp_comp ppf vprintsvlikeppbut usespp_compto print floating point values.