exception Vector2f_exception of string
Raised when an error occurs (usually a division by zero)
This module defines the vector2f type and various operations on it.
exception Vector2f_exception of string
type t = {x : float; y : float}
x : float
|
|
y : float
|
val make : float -> float -> t
val zero : t
val unit_x : t
val unit_y : t
val add : t -> t -> t
val sub : t -> t -> t
sub u v computes the vector u - v
val prop : float -> t -> t
val div : float -> t -> t
val pointwise_product : t -> t -> t
val pointwise_div : t -> t -> t
val to_int : t -> Vector2i.t
val from_int : Vector2i.t -> t
val dot : t -> t -> float
val det : t -> t -> float
val angle : t -> t -> float
val squared_norm : t -> float
val norm : t -> float
val squared_dist : t -> t -> float
val dist : t -> t -> float
val normalize : t -> t
val clamp : t -> t -> t -> t
clamp v a b returns the vector whose coordinates are the coordinates of v clamped between the coordinates of a and b
val map : t -> (float -> float) -> t
val map2 : t -> t -> (float -> float -> float) -> t
val max : t -> float
val min : t -> float
val print : t -> string
val direction : t -> t -> t
direction u v returns the normalized direction vector from u to v . Raises Vector2f_exception if u = v .
val endpoint : t -> t -> float -> t
endpoint a v t returns the point a + tv
val raytrace_points : t -> t -> (float * t * t) list
raytrace_points p1 p2 returns the list of integer-valued points (squares) on the line from p1 to p2(t, p, f) such that :t is the time at the intersection between the line and the pointp stores the (integer) coordinates of the pointf is a unit vector indicating which face of the square has been intersected
val raytrace : t -> t -> float -> (float * t * t) list
raytrace p v t applies raytrace_points between the points p and p + tv . The intersection times are comprised between 0 and t