Gg.V22D vectors.
type t = v2The type for 2D vectors.
dim is the dimension of vectors of type v2.
type m = m2The type for matrices representing linear transformations of 2D space.
val v : float -> float -> v2v x y is the vector (x y).
val comp : int -> v2 -> floatcomp i v is vi, the ith component of v.
Raises Invalid_argument if i is not in [0;dim[.
val x : v2 -> floatx v is the x component of v.
val y : v2 -> floaty v is the y component of v.
val ox : v2ox is the unit vector (1. 0.).
val oy : v2oy is the unit vector (0. 1.).
val infinity : v2infinity is the vector whose components are infinity.
val neg_infinity : v2neg_infinity is the vector whose components are neg_infinity.
val basis : int -> v2basis i is the ith vector of an orthonormal basis of the vector space t with inner product dot.
Raises Invalid_argumentx if i is not in [0;dim[.
val of_tuple : (float * float) -> v2of_tuple (x, y) is V2.v x y.
val to_tuple : v2 -> float * floatof_tuple v is (V2.x v, V2.y v).
of_polar pv is a vector whose cartesian coordinates (x, y) correspond to the radial and angular polar coordinates (r, theta) given by (V2.x pv, V2.y pv).
to_polar v is a vector whose coordinates (r, theta) are the radial and angular polar coordinates of v. theta is in [-pi;pi].
dot u v is the dot product u.v.
val norm : v2 -> floatnorm v is the norm |v| = sqrt v.v.
val norm2 : v2 -> floatnorm2 v is the squared norm |v|2 .
val polar : float -> float -> v2polar r theta is V2.of_polar (V2.v r theta).
val angle : v2 -> floatangle v is the angular polar coordinates of v. The result is in [-pi;pi].
ltr m v is the linear transform mv.
tr m v is the affine transform in homogenous 2D 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 P2.tr to transform finite points.
Stdlib operatorsmapi f v is like map but the component index is also given.
val fold : ('a -> float -> 'a) -> 'a -> v2 -> 'afold f acc v is f (...(f (f acc v0) v1)...).
val foldi : ('a -> int -> float -> 'a) -> 'a -> v2 -> 'afoldi f acc v is f (...(f (f acc 0 v0) 1 v1)...).
val iter : (float -> unit) -> v2 -> unititer f v is f v0; f v1; ...
val iteri : (int -> float -> unit) -> v2 -> unititeri f v is f 0 v0; f 1 v1; ...
val for_all : (float -> bool) -> v2 -> boolfor_all p v is p v0 && p v1 && ...
val exists : (float -> bool) -> v2 -> boolexists p v is p v0 || p v1 || ...
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 -> v2 -> unitpp ppf v prints a textual representation of v on ppf.