Module bound3

A 3-component axis-aligned bounding box.

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, point) Extend bound to include point
extend_bound (a, bound) Extend bound to entirety of other bound
size (a) Get size of bounding box as a vector
with_size (a, new) 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, new) Move bounding box to new center
with_size_centered (a, new) Resize bounding box from center
check (a) Convert possibly-invalid bounding box to valid one
inset (a, a) Shrink bounding box with fixed margin
outset (a, a) Expand bounding box with fixed margin
offset (a, offset) Offset bounding box
contains (a, point) Test if point in bound
to_string (a) Return a formatted string.


Functions

new (min, max)
The public constructor.

Parameters:

  • min Can be of two types:
    vec3 min, minimum value for each component nil Create bound at single point 0,0,0
  • max vec3 , maximum value for each component

Returns:

    bound3 out
clone (a)
Clone a bound.

Parameters:

  • a bound3 bound to be cloned

Returns:

    bound3 out
at (a, b)
Construct a bound covering one or two points

Parameters:

  • a vec3 Any vector
  • b vec3 Any second vector (optional)

Returns:

    vec3 Minimum bound containing the given points
extend (a, point)
Extend bound to include point

Parameters:

  • a bound3 bound
  • point vec3 to include

Returns:

    bound3 Bound covering current min, current max and new point
extend_bound (a, bound)
Extend bound to entirety of other bound

Parameters:

  • a bound3 bound
  • bound bound3 to cover

Returns:

    bound3 Bound covering current min and max of each bound in the pair
size (a)
Get size of bounding box as a vector

Parameters:

  • a bound3 bound

Returns:

    vec3 Vector spanning min to max points
with_size (a, new)
Resize bounding box from minimum corner

Parameters:

  • a bound3 bound
  • new vec3 size

Returns:

    bound3 resized bound
radius (a)
Get half-size of bounding box as a vector. A more correct term for this is probably "apothem"

Parameters:

  • a bound3 bound

Returns:

    vec3 Vector spanning center to max point
center (a)
Get center of bounding box

Parameters:

  • a bound3 bound

Returns:

    bound3 Point in center of bound
with_center (a, new)
Move bounding box to new center

Parameters:

  • a bound3 bound
  • new vec3 center

Returns:

    bound3 Bound with same size as input but different center
with_size_centered (a, new)
Resize bounding box from center

Parameters:

  • a bound3 bound
  • new vec3 size

Returns:

    bound3 resized bound
check (a)
Convert possibly-invalid bounding box to valid one

Parameters:

  • a bound3 bound

Returns:

    bound3 bound with all components corrected for min-max property
inset (a, a)
Shrink bounding box with fixed margin

Parameters:

  • a vec3 margin
  • a vec3 margin

Returns:

    bound3 bound with margin subtracted from all edges. May not be valid, consider calling check()
outset (a, a)
Expand bounding box with fixed margin

Parameters:

  • a vec3 margin
  • a vec3 margin

Returns:

    bound3 bound with margin added to all edges. May not be valid, consider calling check()
offset (a, offset)
Offset bounding box

Parameters:

  • a bound3 bound
  • offset vec3

Returns:

    bound3 bound with same size, but position moved by offset
contains (a, point)
Test if point in bound

Parameters:

  • a bound3 bound
  • point vec3 to test

Returns:

    boolean true if point in bounding box
to_string (a)
Return a formatted string.

Parameters:

  • a bound3 bound to be turned into a string

Returns:

    string formatted
generated by LDoc 1.4.6 Last updated 2022-05-07 22:53:35