Module math.bound2
A 2 component bounding box.
this is apart of the LEEF-math module
Functions
new (min, max) | The public constructor. |
clone (a) | Clone a bound. |
at (a, b) | Construct a bound covering one or two points |
extend (a, center) | Extend bound to include point |
extend_bound (a, b) | Extend bound to entirety of other bound |
size (a) | Get size of bounding box as a vector |
with_size (a, size) | Resize bounding box from minimum corner |
radius (a) | Get half-size of bounding box as a vector. |
center (a) | Get center of bounding box |
with_center (a, center) | Move bounding box to new center |
with_size_centered (a, size) | Resize bounding box from center |
check (a) | Convert possibly-invalid bounding box to valid one |
inset (a, v) | Shrink bounding box with fixed margin |
outset (a, v) | Expand bounding box with fixed margin |
offset (a, v) | Offset bounding box |
contains (a, v) | Test if point in bound |
to_string (a) | Return a formatted string. |
Functions
- new (min, max)
-
The public constructor.
Parameters:
- min
(vec2 | nil) minimum value for each component.
nil
sets to zero. - max vec2 maximum value for each component
Returns:
-
bound2
out
- min
(vec2 | nil) minimum value for each component.
- clone (a)
-
Clone a bound.
Parameters:
- a bound2 bound to be cloned
Returns:
-
bound2
out
- at (a, b)
-
Construct a bound covering one or two points
Parameters:
- a vec2 Any vector
- b vec2 Any second vector (optional)
Returns:
-
vec2
Minimum bound containing the given points
- extend (a, center)
-
Extend bound to include point
Parameters:
- a bound2 a bound
- center vec2 point to include
Returns:
-
bound2
Bound covering current min, current max and new point
- extend_bound (a, b)
-
Extend bound to entirety of other bound
Parameters:
- a bound2 a bound
- b bound2 bound to cover
Returns:
-
bound2
Bound covering current min and max of each bound in the pair
- size (a)
-
Get size of bounding box as a vector
Parameters:
- a bound2 a bound
Returns:
-
vec2
Vector spanning min to max points
- with_size (a, size)
-
Resize bounding box from minimum corner
Parameters:
- a bound2 a bound
- size vec2 new size
Returns:
-
bound2
resized bound
- radius (a)
-
Get half-size of bounding box as a vector. A more correct term for this is probably "apothem"
Parameters:
- a bound2 a bound
Returns:
-
vec2
Vector spanning center to max point
- center (a)
-
Get center of bounding box
Parameters:
- a bound2 a bound
Returns:
-
bound2
Point in center of bound
- with_center (a, center)
-
Move bounding box to new center
Parameters:
- a bound2 a bound
- center vec2 new center
Returns:
-
bound2
Bound with same size as input but different center
- with_size_centered (a, size)
-
Resize bounding box from center
Parameters:
- a bound2 bound
- size vec2 new size
Returns:
-
bound2
resized bound
- check (a)
-
Convert possibly-invalid bounding box to valid one
Parameters:
- a bound2 bound
Returns:
-
bound2
bound with all components corrected for min-max property
- inset (a, v)
-
Shrink bounding box with fixed margin
Parameters:
- a bound2 bound
- v vec2 margin
Returns:
-
bound2
bound with margin subtracted from all edges. May not be valid, consider calling check()
- outset (a, v)
-
Expand bounding box with fixed margin
Parameters:
- a bound2 bound
- v vec2 margin
Returns:
-
bound2
bound with margin added to all edges. May not be valid, consider calling check()
- offset (a, v)
-
Offset bounding box
Parameters:
- a bound2 bound
- v vec2 offset
Returns:
-
bound2
bound with same size, but position moved by offset
- contains (a, v)
-
Test if point in bound
Parameters:
- a bound2 bound
- v vec2 point to test
Returns:
-
boolean
true if point in bounding box
- to_string (a)
-
Return a formatted string.
Parameters:
- a bound2 bound to be turned into a string
Returns:
-
string
formatted