Module Gg.V4
type t= v4The type for 4D vectors.
val dim : intdimis the dimension of vectors of typev4.
type m= m4The type for matrices representing linear transformations of 4D space.
Constructors, accessors and constants
val v : float -> float -> float -> float -> v4v x y z wis the vector(x y z w).
val comp : int -> v4 -> floatcomp i visvi, theith component ofv.- raises Invalid_argument
if
iis not in [0;dim[.
val x : v4 -> floatx vis the x component ofv.
val y : v4 -> floaty vis the y component ofv.
val z : v4 -> floatz vis the z component ofv.
val w : v4 -> floatz vis the z component ofv.
val ox : v4oxis the unit vector(1. 0. 0. 0.).
val oy : v4oyis the unit vector(0. 1. 0. 0.).
val oz : v4ozis the unit vector(0. 0. 1. 0.).
val ow : v4owis the unit vector(0. 0. 0. 1.).
val infinity : v4infinityis the vector whose components areinfinity.
val neg_infinity : v4neg_infinityis the vector whose components areneg_infinity.
val basis : int -> v4basis 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 * float) -> v4of_tuple (x, y, z, w)isv x y z w.
val to_tuple : v4 -> float * float * float * floatto_tuple vis(x v, y v, z v, w v).
Functions
val dot : v4 -> v4 -> floatdot u vis the dot productu.v.
val norm : v4 -> floatnorm vis the norm|v| = sqrt v.v.
val norm2 : v4 -> floatnorm2 vis the squared norm|v|2 .
val ltr : m4 -> v4 -> v4ltr m vis the linear transformmv.
Overridden Pervasives operators
Traversal
val mapi : (int -> float -> float) -> v4 -> v4mapi f vis likemapbut the component index is also given.
val fold : ('a -> float -> 'a) -> 'a -> v4 -> 'afold f acc visf (...(f (f acc v0) v1)...).
val foldi : ('a -> int -> float -> 'a) -> 'a -> v4 -> 'afoldi f acc visf (...(f (f acc 0 v0) 1 v1)...).
val iter : (float -> unit) -> v4 -> unititer f visf v0; f v1;...
val iteri : (int -> float -> unit) -> v4 -> unititeri f visf 0 v0; f 1 v1;...
Predicates and comparisons
val for_all : (float -> bool) -> v4 -> boolfor_all p visp v0&& p v1&&...
val exists : (float -> bool) -> v4 -> boolexists p visp v0|| p v1||...
Printers
val pp : Stdlib.Format.formatter -> v4 -> unitpp ppf vprints a textual representation ofvonppf.
val pp_f : (Stdlib.Format.formatter -> float -> unit) -> Stdlib.Format.formatter -> v4 -> unitpp_f pp_comp ppf vprintsvlikeppbut usespp_compto print floating point values.