`Gg.V4`

4D vectors.

`type t = v4`

The type for 4D vectors.

`dim`

is the dimension of vectors of type `v4`

.

`type m = m4`

The type for matrices representing linear transformations of 4D space.

`val v : float -> float -> float -> float -> v4`

`v x y z w`

is the vector `(x y z w)`

.

`val comp : int -> v4 -> float`

`comp i v`

is `v`

_{i}, the `i`

th component of `v`

.

Raises `Invalid_argument`

if `i`

is not in [`0;`

`dim`

[.

`val x : v4 -> float`

`x v`

is the x component of `v`

.

`val y : v4 -> float`

`y v`

is the y component of `v`

.

`val z : v4 -> float`

`z v`

is the z component of `v`

.

`val w : v4 -> float`

`z v`

is the z component of `v`

.

`val ox : v4`

`ox`

is the unit vector `(1. 0. 0. 0.)`

.

`val oy : v4`

`oy`

is the unit vector `(0. 1. 0. 0.)`

.

`val oz : v4`

`oz`

is the unit vector `(0. 0. 1. 0.)`

.

`val ow : v4`

`ow`

is the unit vector `(0. 0. 0. 1.)`

.

`val infinity : v4`

`infinity`

is the vector whose components are `infinity`

.

`val neg_infinity : v4`

`neg_infinity`

is the vector whose components are `neg_infinity`

.

`val basis : int -> v4`

`basis i`

is the `i`

th vector of an orthonormal basis of the vector space `t`

with inner product `dot`

.

Raises `Invalid_argument`

if `i`

is not in [`0;`

`dim`

[.

`val of_tuple : (float * float * float * float) -> v4`

`of_tuple (x, y, z, w)`

is `v x y z w`

.

`val to_tuple : v4 -> float * float * float * float`

`to_tuple v`

is `(x v, y v, z v, w v)`

.

`dot u v`

is the dot product `u.v`

.

`val norm : v4 -> float`

`norm v`

is the norm `|v| = sqrt v.v`

.

`val norm2 : v4 -> float`

`norm2 v`

is the squared norm `|v|`

^{2} .

`ltr m v`

is the linear transform `mv`

.

`Stdlib`

operators`mapi f v`

is like `map`

but the component index is also given.

`val fold : ('a -> float -> 'a) -> 'a -> v4 -> 'a`

`fold f acc v`

is `f (`

...`(f (f acc v`

_{0}`) v`

_{1}`)`

...`)`

.

`val foldi : ('a -> int -> float -> 'a) -> 'a -> v4 -> 'a`

`foldi f acc v`

is `f (`

...`(f (f acc 0 v`

_{0}`) 1 v`

_{1}`)`

...`)`

.

`val iter : (float -> unit) -> v4 -> unit`

`iter f v`

is `f v`

_{0}`; f v`

_{1}`;`

...

`val iteri : (int -> float -> unit) -> v4 -> unit`

`iteri f v`

is `f 0 v`

_{0}`; f 1 v`

_{1}`;`

...

`val for_all : (float -> bool) -> v4 -> bool`

`for_all p v`

is `p v`

_{0}` && p v`

_{1}` &&`

...

`val exists : (float -> bool) -> v4 -> bool`

`exists p v`

is `p v`

_{0}` || p v`

_{1}` ||`

...

`equal_f eq u v`

tests `u`

and `v`

like `equal`

but uses `eq`

to test floating point values.

`compare_f cmp u v`

compares `u`

and `v`

like `compare`

but uses `cmp`

to compare floating point values.

`val pp : Stdlib.Format.formatter -> v4 -> unit`

`pp ppf v`

prints a textual representation of `v`

on `ppf`

.