Module Gg.Box2
type t
= box2
The type for 2D boxes (rectangles).
val dim : int
dim
is the dimension of the boxes of typebox2
.
type v
= v2
The type for 2D vectors.
type p
= p2
The type for 2D points.
type size
= size2
The type for 2D sizes.
type m
= m2
The type for matrices representing linear transformations of 2D space.
Constructors, accessors and constants
val empty : box2
empty
is the empty box.
val ox : box2 -> float
ox b
isV2.x (o b)
.
val oy : box2 -> float
oy b
isV2.y (o b)
.
val w : box2 -> float
w b
isSize2.w (size b)
.
val h : box2 -> float
h b
isSize2.h (size b)
.
val zero : box2
zero
is a box whose origin and size is zero.
val unit : box2
unit
is the unit box which extends from zero to one in all dimensions.
Functions
val minx : box2 -> float
minx b
isV2.x (min b)
.
val miny : box2 -> float
miny b
isV2.y (min b)
.
val max : box2 -> p2
max b
is the greatest point ofb
(its size added to the origin).- raises Invalid_argument
on
empty
val maxx : box2 -> float
maxx b
isV2.x (max b)
.
val maxy : box2 -> float
maxy b
isV2.y (max b)
.
val midx : box2 -> float
midx b
isV2.x (mid b)
.
val midy : box2 -> float
midy b
isV2.y (mid b)
.
val area : box2 -> float
area b
is the surface area ofb
.
val inter : box2 -> box2 -> box2
inter b b'
is a box whose space is the intersection of S(b
) and S(b'
).
val inset : v2 -> box2 -> box2
inset d b
isb
whose edges are inset in each dimension according to amounts ind
. Negative values ind
outset. If the resulting size is negative returnsempty
. Returnsempty
onempty
.
val round : box2 -> box2
round b
is the smallest box containingb
with integer valued corners. Returnsempty
onempty
.
val ltr : m2 -> box2 -> box2
ltr m b
is the smallest box containing the corners ofb
transformed bym
. Returnsempty
onempty
.
Predicates and comparisons
val is_pt : box2 -> bool
is_pt b
istrue
iffb
is notempty
and its size is equal to 0 in every dimension.
val is_seg : box2 -> bool
is_seg b
istrue
iffb
is notempty
and its size is equal to 0 in exactly one dimension.
Printers
val pp : Stdlib.Format.formatter -> box2 -> unit
pp ppf b
prints a textual representation ofb
onppf
.
val pp_f : (Stdlib.Format.formatter -> float -> unit) -> Stdlib.Format.formatter -> box2 -> unit
pp_f pp_fl ppf b
printsb
likepp
but usespp_fl
to print floating point values.