exception Vector3f_exception of string
Raised when an error occurs (usually a division by zero)
This module defines the vector3f type and various operations on it.
exception Vector3f_exception of string
type t = {x : float; y : float; z : float}
x : float
|
|
y : float
|
|
z : float
|
val make : float -> float -> float -> t
val zero : t
val unit_x : t
val unit_y : t
val unit_z : 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 -> Vector3i.t
val from_int : Vector3i.t -> t
val project : t -> Vector2f.t
val lift : Vector2f.t -> t
val dot : t -> t -> float
val cross : t -> t -> t
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 Vector3f_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 (cubes) 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 cube 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