Skip to content

Latest commit

 

History

History
222 lines (103 loc) · 6.13 KB

erstar_bound.md

File metadata and controls

222 lines (103 loc) · 6.13 KB

Module erstar_bound

Module provides means to deal with simple structures called bounds.

Description

Each such bound contain description of a two-dimensional bounding box.

Data Types

bound() = {number(), number(), number(), number()}

Function Index

area/1Computes area of a bound.
center/1Returns effective coordinates of the center of a bound.
dimensions/1Returns effective dimensions of a bound.
empty/0Creates an empty bound, with no position and dimensions.
intersect/2Returns new bound comprised of all common points of two specified bound.
lowerleft/1Returns coordinates of the lower left point of a bound.
margin/1Computes margin of a bound.
new/2Creates bound with position and no dimensions, effectively a point.
new/4Creates bound with well-defined position and dimensions.
overlap/2Computes area covered by the intersection of two specified bounds.
unify/2Returns new bound containing each one of specified bounds.
upperright/1Returns coordinates of the upper right point of a bound.
x1/1Returns lower coordinate of a bound on the X axis.
x2/1Returns upper coordinate of a bound on the X axis.
y1/1Returns lower coordinate of a bound on the Y axis.
y2/1Returns upper coordinate of a bound on the Y axis.

Function Details

area/1

area(X1::empty | bound()) -> number()



Computes area of a bound.

center/1

center(X1::bound()) -> {number(), number()}



Returns effective coordinates of the center of a bound.

dimensions/1

dimensions(X1::bound()) -> {number(), number()}



Returns effective dimensions of a bound.

empty/0

empty() -> empty



Creates an empty bound, with no position and dimensions.

intersect/2

intersect(X1::bound(), X2::bound()) -> empty | bound()



Returns new bound comprised of all common points of two specified bound. The resulting bound can be empty, in case there are no common points at all.

lowerleft/1

lowerleft(X1::bound()) -> {number(), number()}



Returns coordinates of the lower left point of a bound.

margin/1

margin(X1::empty | bound()) -> number()



Computes margin of a bound. Margin is equal to the half of perimeter.

new/2

new(X::number(), Y::number()) -> bound()



Creates bound with position and no dimensions, effectively a point.

new/4

new(X::number(), Y::number(), W::number(), H::number()) -> bound()



Creates bound with well-defined position and dimensions. Negative dimensions are not allowed.

overlap/2

overlap(X1::bound(), X2::bound()) -> number()



Computes area covered by the intersection of two specified bounds. If these bounds have no intersection, the result will be 0.

unify/2

unify(B0::empty | bound(), B1::empty | bound()) -> empty | bound()



Returns new bound containing each one of specified bounds. The resulting bound is optimal one in terms of area.

upperright/1

upperright(X1::bound()) -> {number(), number()}



Returns coordinates of the upper right point of a bound.

x1/1

x1(X1::bound()) -> number()



Returns lower coordinate of a bound on the X axis.

x2/1

x2(X1::bound()) -> number()



Returns upper coordinate of a bound on the X axis.

y1/1

y1(X1::bound()) -> number()



Returns lower coordinate of a bound on the Y axis.

y2/1

y2(X1::bound()) -> number()



Returns upper coordinate of a bound on the Y axis.