# Module Gg.V4

`module V4: `sig` .. `end``

`type t = `Gg.v4` `
The type for 4D vectors.
`val dim : `int``
`dim` is the dimension of vectors of type `Gg.v4`.
`type m = `Gg.m4` `
The type for matrices representing linear transformations of 4D space.

# Constructors, accessors and constants

`val v : `float -> float -> float -> float -> Gg.v4``
`v x y z w` is the vector `(x y z w)`.
`val comp : `int -> Gg.v4 -> float``
`comp i v` is `v``i`, the `i`th component of `v`.
Raises `Invalid_argument` if `i` is not in [`0;``Gg.V4.dim`[.
`val x : `Gg.v4 -> float``
`x v` is the x component of `v`.
`val y : `Gg.v4 -> float``
`y v` is the y component of `v`.
`val z : `Gg.v4 -> float``
`z v` is the z component of `v`.
`val w : `Gg.v4 -> float``
`z v` is the z component of `v`.
`val ox : `Gg.v4``
`ox` is the unit vector `(1. 0. 0. 0.)`.
`val oy : `Gg.v4``
`oy` is the unit vector `(0. 1. 0. 0.)`.
`val oz : `Gg.v4``
`oz` is the unit vector `(0. 0. 1. 0.)`.
`val ow : `Gg.v4``
`ow` is the unit vector `(0. 0. 0. 1.)`.
`val zero : `Gg.v4``
`zero` is the neutral element for `Gg.V4.add`.
`val infinity : `Gg.v4``
`infinity` is the vector whose components are `infinity`.
`val neg_infinity : `Gg.v4``
`neg_infinity` is the vector whose components are `neg_infinity`.
`val basis : `int -> Gg.v4``
`basis i` is the `i`th vector of an orthonormal basis of the vector space `Gg.V4.t` with inner product `Gg.V4.dot`.
Raises `Invalid_argument` if `i` is not in [`0;``Gg.V4.dim`[.
`val of_tuple : `float * float * float * float -> Gg.v4``
`of_tuple (x, y, z, w)` is `v x y z w`.
`val to_tuple : `Gg.v4 -> float * float * float * float``
`to_tuple v` is `(x v, y v, z v, w v)`.
`val of_v2 : `Gg.v2 -> z:float -> w:float -> Gg.v4``
`of_v2 u z w` is `v (V2.x u) (V2.y u) z w`.
`val of_v3 : `Gg.v3 -> w:float -> Gg.v4``
`of_v3 u w` is `v (V3.x u) (V3.y u) (V3.z u) w`.

# Functions

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

# Overridden `Pervasives` operators

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

# Traversal

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

# Predicates and comparisons

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

# Printers

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