Box2D
This object represents a 2d bounding box for an object or group of objects.
Constructor
Box2D()
This construct an uninitialized box with invalid values which can be tested for using the .IsInvalid property.
Box2D (Point2D p1, Point2D p2)
Create a box which bounds the 2 passed in points P1 (Point2D) first point within the box P1 (Point2D) second point within the box
Box2D(Box2D box)
A new Box2D with the same values as the passed box (Box2D) Note: an existing box to copy values from
Properties
.BLC
Interaction: Read Only
Returns: (Point2D) a point representing the bottom left corner of the bounding box
.BRC
Interaction: Read Only
Returns: (Point2D) a point representing the bottom right corner of the bounding box
.Centre
Interaction: Read Only
Returns: (Point2D) a point representing the centre of the bounding box (British spelling)
.Center
Interaction: Read Only
Returns: (Point2D) a point representing the center of the bounding box (U.S spelling)
.IsInvalid
Interaction: Read Only
Returns: (bool) true if the box is in an invalid state Note: not initialised or SetInvalid called
.MinX
Interaction: Read Only
Returns: (double) the minimum X value for the bounding box
.MinY
Interaction: Read Only
Returns: (double) the minimum Y value for the bounding box
.MaxX
Interaction: Read Only
Returns: (double) the maximum X value for the bounding box
.MaxY
Interaction: Read Only
Returns: (double) the maximum Y value for the bounding box
.XLength
Interaction: Read Only
Returns: (double) the length in X for the bounding box
.YLength
Interaction: Read Only
Returns: (double) the length in Y for the bounding box
.MaxLength
Interaction: Read Only
Returns: (double) the length of the longest side for the bounding box
.MinLength
Interaction: Read Only
Returns: (double) the length of the shortest side for the bounding box
.TRC
Interaction: Read Only
Returns: (Point2D) a point representing the top right corner of the bounding box
.TLC
Interaction: Read Only
Returns: (Point2D) a point representing the top left corner of the bounding box
Methods
:Expand( double offset_dist)
Expand this box on all sides by passed amount
- offset_dist(double) distance to offset box by
:IsInside( Point2D point, double tol)
Returns: (bool) true if passed point is inside this box within passed tolerance (which may be 0.0).
- point (Point2D) point to test to see if inside box
- tol(double) tolerance value to use when checking if inside box
:IsInsideOrOn( Point2D point, double tol)
Returns: (bool) true if passed point is inside or on the edge of this box within passed tolerance (which may be 0.0).
- point (Point2D) point to test to see if inside or on box
- tol (double) tolerance value to use when checking if inside box
:IsInside( Box2D box, bool on_counts_as_int, double tol)
Returns: (bool) true if passed box intersects this box within passed tolerance (which may be 0.0).
- box (Box2D) box to test to see if intersects this box
- on_counts_as_int(bool) if true boxes with shared edges count as intersections
- tol(double) tolerance value to use when checking if inside box
:Intersects( Box2D box, double tol)
Returns: (bool) true if passed box is inside this box within passed tolerance (which may be 0.0).
- box (Box2D) box to test to see if inside this box
- tol(double) tolerance value to use when checking if inside box
:Merge( double x, double y)
Merge a point with the passed x and y values into the box updating limits
- x(double) x value for point being merged
- y(double) y value for point being merged
:Merge( Point2D point)
Merge a point into the box updating limits point (Point2D) point being merged
:Merge( Box2D box)
Merge another box into this box, updating the limits box (Box2D) box being merged
:SetInvalid()
Set the box to invalid state
References
Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information