Bounds and Extents
This module provides the following bound and extent classes:
- Bounds2d: An array of 4 two-dimensional points defining the corners of a parallelogram bounding an area.
- Bounds3d: An array of 8 three-dimensional points defining the corners of a rhombus bounding a volume.
- Extents2d: A pair of two-dimensional points defining a rectangle with axis-aligned sides.
- Extents3d: A pair of three-dimensional points defining a box with axis-aligned sides.
Single precision variants are also available. Simply prefix these class names with "Float" to use them.
The Bounds2d Class
Objects of this class represent two-dimensional bounding volumes whose sides may have an arbitrary orientation.
This class has the following constant data members:
Bounds2d.kPointClass -> The class of the points in this object, in this case Point2d.
This class has the following construction methods:
Bounds2d ()
Constructs a new bounds object with uninitialized values.
Returns the new object.
Bounds2d (bounds)
bounds -> Bounds2d
Constructs a new bounds object by copying the given bounds object.
Returns the new object.
Bounds2d (p1, p2, p3, p4)
p1 -> Point2d
p2 -> Point2d
p3 -> Point2d
p4 -> Point2d
Constructs a new bounds object with the corner points.
Returns the new object.
Every instance of this class has the following member values, accessible both by numeric indices and the following keys:
1 | "pt1" -> the first corner value
2 | "pt2" -> the second corner value
3 | "pt3" -> the third corner value
4 | "pt4" -> the fourth corner value
Every instance of this class has the following member methods:
Bounds2d:Clone ()
Returns a newly allocated copy of this object.
Bounds2d:GetCenter ()
Returns the center point of the bounds.
Bounds2d:IndexedPoint (index)
index -> integer (from 1 to 4)
Returns the indexed point.
This seems a bit redundant now that I think of it, but it's potentially faster than the normal numerical Lua index operation.
Bounds2d:IsEmpty ()
Returns true if the bounds describe an empty area.
Bounds2d:IsFinite ()
Returns true if the bounds describe a finite area. (non-empty, non-infinite)
Bounds2d:IsInfinite ()
Returns true if the bounds describe an infinite area.
Bounds2d:SetByExtents (extents)
extents -> Extents2d
Set these bounds to match the given extents.
The original object is modified in place.
Returns the newly set bounds.
Bounds2d:SetByPoints (pt1, pt2)
pt1 -> Points2d
pt2 -> Points2d
Set these bounds to exactly encompass the two given points.
The original object is modified in place.
Returns the newly set bounds.
Bounds2d:SetEmpty ()
Set these bounds to be empty, containing no area.
The original object is modified in place.
Returns the newly emptied bounds.
Bounds2d:SetInfinite ()
Set these bounds to be infinite, containing all possible areas.
The original object is modified in place.
Returns the newly infinite bounds.
The Bounds3d Class
Objects of this class represent three-dimensional bounding volumes whose sides may have an arbitrary orientation.
This class has the following constant data members:
Bounds3d.kPointClass -> The class of the points in this object, in this case Point3d.
This class has the following construction methods:
Bounds3d ()
Constructs a new bounds object with uninitialized values.
Returns the new object.
Bounds3d (bounds)
bounds -> Bounds3d
Constructs a new bounds object by copying the given bounds object.
Returns the new object.
Bounds3d (p1, p2, p3, p4, p5, p6, p7, p8)
p1 -> Point3d
p2 -> Point3d
p3 -> Point3d
p4 -> Point3d
p5 -> Point3d
p6 -> Point3d
p7 -> Point3d
p8 -> Point3d
Constructs a new bounds object with the corner points.
Returns the new object.
Every instance of this class has the following member values, accessible both by numeric indices and the following keys:
1 | "pt1" -> the first corner value
2 | "pt2" -> the second corner value
3 | "pt3" -> the third corner value
4 | "pt4" -> the fourth corner value
5 | "pt5" -> the fifth corner value
6 | "pt6" -> the sixth corner value
7 | "pt7" -> the seventh corner value
8 | "pt8" -> the eighth corner value
Every instance of this class has the following member methods:
Bounds3d:Clone ()
Returns a newly allocated copy of this object.
Bounds3d:GetCenter ()
Returns the center point of the bounds.
Bounds3d:IndexedPoint (index)
index -> integer (from 1 to 8)
Returns the indexed point.
This seems a bit redundant now that I think of it, but it's potentially faster than the normal numerical Lua index operation.
Bounds3d:IsEmpty ()
Returns true if the bounds describe an empty area.
Bounds3d:IsFinite ()
Returns true if the bounds describe a finite area. (non-empty, non-infinite)
Bounds3d:IsInfinite ()
Returns true if the bounds describe an infinite area.
Bounds3d:SetByExtents (extents)
extents -> Extents3d
Set these bounds to match the given extents.
The original object is modified in place.
Returns the newly set bounds.
Bounds3d:SetByPoints (pt1, pt2)
pt1 -> Points3d
pt2 -> Points3d
Set these bounds to exactly encompass the two given points.
The original object is modified in place.
Returns the newly set bounds.
Bounds3d:SetEmpty ()
Set these bounds to be empty, containing no area.
The original object is modified in place.
Returns the newly emptied bounds.
Bounds3d:SetInfinite () Set these bounds to be infinite, containing all possible areas.
The original object is modified in place.
Returns the newly infinite bounds.
Bounds3d:Transform (matrix)
Transforms the bounds by the supplied matrix.
The original object is modified in place.
Returns the newly transformed bounds.
matrix -> FloatMatrix3x3 | FloatMatrix4x3 | FloatMatrix4x4 | Matrix3x3 | Matrix4x3 | Matrix4x4
The Extents2d Class
Objects of this class represent two-dimensional bounding volumes whose sides are axis aligned.
This class has the following constant data members:
Extents2d.kPointClass -> The class of the points in this object, in this case Point2d.
This class has the following construction methods:
Extents2d ()
Constructs a new extents object with uninitialized values.
Returns the new object.
Extents2d (extents)
extents -> Extents2d
Constructs a new extents object by copying the given extents object.
Returns the new object.
Extents2d (low, high)
low -> Point2d
high -> Point2d
Constructs a new extents object with the low and high corner points.
Returns the new object.
Every instance of this class has the following member values, accessible both by numeric indices and the following keys:
1 | "low" -> the low corner value
2 | "high" -> the high corner value
Every instance of this class has the following member methods:
Extents2d:Clone ()
Returns a newly allocated copy of this object.
Extents2d:ContainsExtents (extents)
extents -> Extents2d
Returns true if the given extents are entirely contained by these extents.
Extents2d:ContainsPoint (point)
point -> Point2d
Returns true if the given point is contained by these extents.
Extents2d:GetCenter ()
Returns the center point of the extents.
Extents2d:IncludePoint (point)
point -> Point2d
Expands these extents to include the given point if necessary.
The original object is modified in place.
Returns the newly expanded extents.
Extents2d:IndexedPoint (index)
index -> integer (from 1 to 4)
Returns the indexed point.
This seems a bit redundant now that I think of it, but it's potentially faster than the normal numerical Lua index operation.
Extents2d:Intersects (extents)
extents -> Extents2d
Returns true if the intersection of these extents with the given extents is non-empty.
Extents2d:IsEmpty ()
Returns true if the extents describe an empty area.
Extents2d:IsFinite ()
Returns true if the extents describe a finite area. (non-empty, non-infinite)
Extents2d:IsInfinite ()
Returns true if the extents describe an infinite area.
Extents2d:SetByBounds (bounds)
bounds -> Bounds2d
Set these extents to contain the given bounds.
The original object is modified in place.
Returns the newly set extents.
Extents2d:SetByPoints (pt1, pt2)
Set these extents to exactly encompass the two given points.
The original object is modified in place.
Returns the newly set extents.
pt1 -> Points2d
pt2 -> Points2d
Extents2d:SetEmpty ()
Set these extents to be empty, containing no area.
The original object is modified in place.
Returns the newly emptied extents.
Extents2d:SetInfinite ()
Set these extents to be infinite, containing all possible areas.
The original object is modified in place.
Returns the newly infinite extents.
The Extents3d Class
Objects of this class represent three-dimensional bounding volumes whose sides are axis aligned.
This class has the following constant data members:
Extents3d.kPointClass -> The class of the points in this object, in this case Point3d.
This class has the following construction methods:
Extents3d ()
Constructs a new extents object with uninitialized values.
Returns the new object.
Extents3d (extents)
extents -> Extents3d
Constructs a new extents object by copying the given extents object.
Returns the new object.
Extents3d (low, high)
Constructs a new extents object with the low and high corner points.
Returns the new object.
low -> Point3d
high -> Point3d
Every instance of this class has the following member values, accessible both by numeric indices and the following keys:
1 | "low" -> the low corner value
2 | "high" -> the high corner value
Every instance of this class has the following member methods:
Extents3d:Clone ()
Returns a newly allocated copy of this object.
Extents3d:ContainsExtents (extents)
extents -> Extents3d
Returns true if the given extents are entirely contained by these extents.
Extents3d:ContainsPoint (point)
point -> Point3d
Returns true if the given point is contained by these extents.
Extents3d:GetCenter ()
Returns the center point of the extents.
Extents3d:IncludePoint (point)
point -> Point3d
Expands these extents to include the given point if necessary.
The original object is modified in place.
Returns the newly expanded extents.
Extents3d:IndexedPoint (index)
index -> integer (from 1 to 8)
Returns the indexed point. This seems a bit redundant now that I think of it, but it's potentially faster than the normal numerical Lua index operation.
Extents3d:Intersects (extents)
extents -> Extents3d
Returns true if the intersection of these extents with the given extents is non-empty.
Extents3d:IsEmpty ()
Returns true if the extents describe an empty area.
Extents3d:IsFinite ()
Returns true if the extents describe a finite area. (non-empty, non-infinite)
Extents3d:IsInfinite ()
Returns true if the extents describe an infinite area.
Extents3d:SetByBounds (bounds)
bounds -> Bounds3d
Set these extents to contain the given bounds.
The original object is modified in place.
Returns the newly set extents.
Extents3d:SetByPoints (pt1, pt2)
pt1 -> Points3d
pt2 -> Points3d
Set these extents to exactly encompass the two given points.
The original object is modified in place.
Returns the newly set extents.
Extents3d:SetEmpty ()
Set these extents to be empty, containing no area.
The original object is modified in place.
Returns the newly emptied extents.
Extents3d:SetInfinite ()
Set these extents to be infinite, containing all possible areas.
The original object is modified in place.
Returns the newly infinite extents.
Extents3d:Transform (matrix)
Transforms the extents by the supplied matrix.
The original object is modified in place.
Returns the newly transformed extents.
matrix -> FloatMatrix3x3 | FloatMatrix4x3 | FloatMatrix4x4 | Matrix3x3 | Matrix4x3 | Matrix4x4