(** An immutable 2D vector class. @author Victor Nicollet *) (** A vector as a pair of coordinates. *) type vector = { x : float; y : float } (** The horizontal 'right' vector *) val right : vector (** The vertical 'up' vector *) val up : vector (** The zero vector *) val zero : vector (** Are two vectors equal? *) val equal : vector -> vector -> bool (** Add two vectors together *) val ( ++ ) : vector -> vector -> vector (** Substract a vector from another *) val ( -- ) : vector -> vector -> vector (** Scale a vector *) val ( *+ ) : float -> vector -> vector (** The squared length of a vector *) val sqlen : vector -> float (** The length of a vector *) val len : vector -> float (** Exception thrown when expecting a non-null vector *) exception ZeroVector (** The unit vector corresponding to a vector. @raise ZeroVector if the vector is zero. *) val normalize : vector -> vector (** Dot product *) val dot : vector -> vector -> float