Module OgamlMath.IntBox

Operations on integer boxes

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

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

Record fields

x : int
y : int
z : int
width : int
height : int
depth : int
val create : Vector3i.t -> Vector3i.t -> t
create position size creates a box at position position and of size size
val create_from_points : Vector3i.t -> Vector3i.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 -> Vector3i.t
Returns the position of a box
val abs_position : t -> Vector3i.t
Returns the absolute position of a box, that is the point of minimal coordinates
val corner : t -> Vector3i.t
Returns the top corner (aka position + size) of a box
val abs_corner : t -> Vector3i.t
Returns the absolute corner of a box, that is the point of maximal coordinates
val normalize : t -> t
normalize box returns a box equivalent to box but with positive size
val size : t -> Vector3i.t
Returns the size of a box
val abs_size : t -> Vector3i.t
Returns the absolute size of a box
val center : t -> Vector3f.t
Returns the center of a box
val volume : t -> int
Returns the volume of a box
val scale : t -> Vector3i.t -> t
Scales a box
val extend : t -> Vector3i.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 translate : t -> Vector3i.t -> t
Translates a box
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 : ?strict:bool -> t -> Vector3i.t -> bool
contains t p returns true iff the box t contains p
if strict is set to true then upper bounds are not included (false by default)
val iter : ?strict:bool -> t -> (Vector3i.t -> unit) -> unit
iter t f iterates through all points of the box t
if strict is set to false then upper bounds are included (true by default)
val fold : ?strict:bool -> t -> (Vector3i.t -> 'a -> 'a) -> 'a -> 'a
fold t f u folds through all points of the box t
if strict is set to false then upper bounds are included (true by default)
val print : t -> string
Returns a pretty-printed string (not for serialization)