Module OgamlMath.FloatBox

Operations on float boxes

This module defines the FloatBox type and various operations on it.

type t = {x : float; y : float; z : float; width : float; height : float; depth : float}
Type of immutable boxes of floats

Record fields

x : float
y : float
z : float
width : float
height : float
depth : float
val create : Vector3f.t -> Vector3f.t -> t
create position size creates a box at position position and of size size
val create_from_points : Vector3f.t -> Vector3f.t -> t
create_from_points p1 p2 creates a box going from p1 to p2
val zero : t
Zero box
val one : t
Unit box
val position : t -> Vector3f.t
Returns the position of a box
val abs_position : t -> Vector3f.t
Returns the absolute position of a box, that is the point of minimal coordinates
val corner : t -> Vector3f.t
Returns the top corner (aka position + size) of a box
val abs_corner : t -> Vector3f.t
Returns the absolute corner of a box, that is the point of maximal coordinates
val size : t -> Vector3f.t
Returns the size of a box
val abs_size : t -> Vector3f.t
Returnrs the absolute size of a box
val center : t -> Vector3f.t
Returns the center of a box
val normalize : t -> t
normalize box returns a box equivalent to box but with positive size
val extend : t -> Vector3f.t -> t
Adds a vector to the dimensions of a box. Be careful since if the box is not normalized, adding a positive vector may reduce the effective size of the box.
val volume : t -> float
Returns the volume of a box
val scale : t -> Vector3f.t -> t
Scales a box
val translate : t -> Vector3f.t -> t
Translates a box
val from_int : IntBox.t -> t
Converts an integer box to a float box
val to_int : t -> IntBox.t
Truncates the floating-point coordinates of a box
See : OgamlMath.IntBox
val intersects : t -> t -> bool
intersects t1 t2 returns true iff the boxes t1 and t2 overlap
val includes : t -> t -> bool
includes t b returns true iff the box b is included in the box t
val contains : t -> Vector3f.t -> bool
contains t p returns true iff the box t contains p
val print : t -> string
Returns a pretty-printed string (not for serialization)