module Vector:sig..end
Vector contains the Vector.t type and functions for
creating and manipulating vectors.
typet =float * float
val to_string : t -> stringto_string vec is the string representation of vec.
val (~<) : t -> float~< (x, y) is x.
val (~>) : t -> float~> (x, y) is y.
val create : float -> float -> tcreate x y is (x, y).
val of_tuple : float * float -> tof_tuple (x, y) is (x, y).
val of_angle : float -> tof_angle theta is the unit vector (cos theta, sin theta).
val mag : t -> floatmag vec is the magnitude of vec, i.e. sqrt (x**2. +. y**2.)
val mag_sq : t -> floatmag_sq vec is the squared magnitude of vec, i.e. x**2. +. y**2..
This computation is faster than mag.
val add : t -> t -> tadd v1 v2 is the sum of v1 and v2.
val sub : t -> t -> tsub v1 v2 is the difference between v1 and v2, which is
equivalent to add v1 (mult v2 (-1.)).
val mult : t -> float -> tmult vec f is the scalar multiplication of vec by f.
val div : t -> float -> tdiv vec f is mult vec (1. /. f).
val dist : t -> t -> floatdist v1 v2 is the distance between v1 and v2, which is equivalent
to mag (sub v1 v2).
val dot : t -> t -> floatdot v1 v2 is the dot product of v1 and v2, i.e.
(x1 *. x2) +. (y1 *. y2), where v1 = (x1, y1) and v2 = (x2, y2).
val norm : t -> tnorm vec is vec with a magnitude of 1., which is equivalent to
div vec (mag vec).
val with_mag : t -> float -> twith_mag vec f is vec with a magnitude of f, which is equivalent
to mult (norm vec) f.
val limit : t -> float -> tlimit vec f is vec with a maximum magnitude of f, which is
equivalent to with_mag vec (min (mag vec) f).
val heading : t -> floatheading vec is the heading of vec, i.e. atan2 y x where
vec = (x, y).
val rotate : t -> float -> trotate vec theta is vec rotated by angle theta.
val lerp : t -> t -> float -> tlerp v1 v2 t is the linear interpolation from v1 to v2 by t,
where t is in [0, 1].
val angle_between : t -> t -> floatangle_between v1 v2 is the smallest angle between v1 and v2.
val project : t -> t -> tproject v1 v2 is the projection of v1 on to v2.
val (++) : t -> t -> tv1 ++ v2 is add v1 v2.
val (--) : t -> t -> tv1 -- v2 is sub v1 v2.
val ( *** ) : t -> float -> tvec *** f is mult vec f.
val (//) : t -> float -> tvec // f is div vec f.
val ( **. ) : t -> t -> floatv1 **. v2 is dot v1 v2.
val (~||) : t -> float~|| vec is mag vec.