package gg

  1. Overview
  2. Docs

Module type Gg.BoxSource

Implemented by all axis-aligned box types.

Sourcetype t

The type for boxes.

Sourceval dim : int

dim is the dimension of the boxes of type t.

Sourcetype v

The type for dim vectors.

Sourcetype p

The type for dim points.

Sourcetype size

The type for dim sizes.

Sourcetype m

The type for matrices representing linear transformations of dim space.

Constructors, accessors and constants

Sourceval v : p -> size -> t

v o size is a box whose origin is o and size is size.

Sourceval v_mid : p -> size -> t

v_mid mid size is a box whose mid point is mid and size is size.

Sourceval empty : t

empty is the empty box.

Sourceval o : t -> p

o b is the origin of b.

Raises Invalid_argument on empty

Sourceval size : t -> size

size b is the size of b.

Raises Invalid_argument on empty

Sourceval zero : t

zero is a box whose origin and size is zero.

Sourceval unit : t

unit is the unit box which extends from zero to one in all dimensions.

Sourceval of_pts : p -> p -> t

of_pts p p' is the smallest box whose space contains p and p'.

Sourceval add_pt : t -> p -> t

add_pt b p is the smallest box whose space contains b and p.

Functions

Sourceval min : t -> p

min b is the smallest point of b (its origin).

Raises Invalid_argument on empty

Sourceval max : t -> p

max b is the greatest point of b (its size added to the origin).

Raises Invalid_argument on empty

Sourceval mid : t -> p

mid b is the mid point between min and max.

Raises Invalid_argument on empty

Sourceval area : t -> float

area b is the surface area of b.

Sourceval inter : t -> t -> t

inter b b' is a box whose space is the intersection of S(b) and S(b').

Sourceval union : t -> t -> t

union b b' is the smallest box whose space contains S(b) and S(b').

Sourceval inset : v -> t -> t

inset d b is b whose edges are inset in each dimension according to amounts in d. Negative values in d outset. If the size in dimension i becomes negative it is clamped to 0 and the ith coordinate of the mid point of b is used for the ith coordinate of the resulting box's origin. Returns empty on empty.

Sourceval round : t -> t

round b is the smallest box containing b with integer valued corners. Returns empty on empty.

Sourceval move : v -> t -> t

move d b is b translated by d. Returns empty on empty.

Sourceval ltr : m -> t -> t

ltr m b is the smallest box containing the corners of b transformed by m. Returns empty on empty.

Sourceval map_f : (float -> float) -> t -> t

map_f f b is the box whose origin and size are those of b with their components mapped by f. Returns empty on empty.

Predicates and comparisons

Sourceval is_empty : t -> bool

is_empty b is true iff b is empty.

Sourceval is_pt : t -> bool

is_pt b is true iff b is not empty and its size is equal to 0 in every dimension.

Sourceval isects : t -> t -> bool

isects b b' is not (is_empty (inter b b')).

Sourceval subset : t -> t -> bool

subset b b' is true iff S(b) is included in S(b').

Sourceval mem : p -> t -> bool

mem p b is true iff p is in S(b).

Sourceval equal : t -> t -> bool

equal b b' is b = b'.

Sourceval equal_f : (float -> float -> bool) -> t -> t -> bool

equal_f eq b b' tests b and b' like equal but uses eq to test floating point values.

Sourceval compare : t -> t -> int

compare u v is Stdlib.compare u v.

Sourceval compare_f : (float -> float -> int) -> t -> t -> int

compare_f cmp b b' compares b and b' like compare but uses cmp to compare floating point values.

Formatters

Sourceval pp : Format.formatter -> t -> unit

pp ppf b prints a textual representation of b on ppf.

Sourceval pp_f : (Format.formatter -> float -> unit) -> Format.formatter -> t -> unit

pp_f pp_fl ppf b prints b like pp but uses pp_fl to print floating point values.