Class BBox
- Namespace
- SearchAThing.OpenGL.Core
- Assembly
- netcore-opengl-core.dll
Bounding box of a set of points.
It can be an oriented bounding box if created with custom coordinate system, WCS elsewhere is used as default.
public class BBox
- Inheritance
-
BBox
- Inherited Members
- Extension Methods
Remarks
If a custom CS is given at the constructor min and max point of the bbox evaluates extension increments from the cs point of view.
Constructors
BBox(BBox)
Create a copy of given bbox.
public BBox(BBox other)
Parameters
other
BBoxOther bbox to copy.
BBox(IEnumerable<BBox>)
Create a wcs bounding box adding given bboxes wcs extensions.
public BBox(IEnumerable<BBox> bboxes)
Parameters
bboxes
IEnumerable<BBox>
BBox(IEnumerable<Vector3>)
Create a wcs bounding box of given points
public BBox(IEnumerable<Vector3> pts)
Parameters
pts
IEnumerable<Vector3>
BBox(in Matrix4x4?)
Create bounding box object with optional coordinate system.
public BBox(in Matrix4x4? cs = null)
Parameters
BBox(in Matrix4x4?, params Vector3[])
Create a cs oriented bounding box of given set of points.
public BBox(in Matrix4x4? cs, params Vector3[] pts)
Parameters
BBox(in Matrix4x4, IEnumerable<BBox>)
Create a cs oriented bounding box adding given bboxes wcs extensions.
public BBox(in Matrix4x4 cs, IEnumerable<BBox> bboxes)
Parameters
cs
Matrix4x4bboxes
IEnumerable<BBox>
BBox(in Matrix4x4, IEnumerable<Vector3>)
Create a cs oriente bounding box of given set of points.
public BBox(in Matrix4x4 cs, IEnumerable<Vector3> pts)
Parameters
cs
Matrix4x4pts
IEnumerable<Vector3>
BBox(params Vector3[])
Create a wcs bounding box of given set of points.
public BBox(params Vector3[] pts)
Parameters
pts
Vector3[]
Properties
CS
Coordinate system related to the bounding box or null if WCS is considered.
public Matrix4x4? CS { get; }
Property Value
IsEmpty
States if bounding box is empty. This is the default state at construct time and mean no point added yet.
public bool IsEmpty { get; }
Property Value
Max
Maximum coordinate [wcs].
public Vector3 Max { get; }
Property Value
MaxCS
Maximum coordinate [cs].
public Vector3 MaxCS { get; }
Property Value
Middle
Bounding box middle coordinate [wcs].
public Vector3 Middle { get; }
Property Value
Min
Minimum coordinate [wcs].
public Vector3 Min { get; }
Property Value
MinCS
Minimum coordinate [cs].
public Vector3 MinCS { get; }
Property Value
Points
Enumerate bounding box eight points.
public IEnumerable<Vector3> Points { get; }
Property Value
Remarks
It doesn't check for duplicates.
Size
Bounding box size [wcs].
public Vector3 Size { get; }
Property Value
SizeCS
Bounding box size [cs].
public Vector3 SizeCS { get; }
Property Value
TolHint
Retrieve length comparision tolerance hint from bbox size.
If bbox empty a default tolerance DefaultTolerance will retrieved.
public float TolHint { get; }
Property Value
Methods
ApplyUnion(BBox)
(side effect) Modify current bounding box by adding given other bbox wcs extensions.
public bool ApplyUnion(BBox other)
Parameters
other
BBoxOther bbox to add.
Returns
- bool
True if bbox changed.
ApplyUnion(IEnumerable<Vector3>)
(side effect) Apply union of given wcs points. If bbox provided with custom CS then bbox aligned comparision will be done.
public bool ApplyUnion(IEnumerable<Vector3> pts)
Parameters
pts
IEnumerable<Vector3>Other points to add.
Returns
- bool
True if bbox changed.
ApplyUnion(params Vector3[])
(side effect) Modify current bounding box by adding given other set ot wcs points.
public bool ApplyUnion(params Vector3[] pts)
Parameters
pts
Vector3[]Other wcs points to add.
Returns
- bool
True if bbox changed.
Clear()
Reset bbox to empty state.
public void Clear()
Contains(float, BBox, bool, bool)
WCS tests if given other bounding box is contained (with tolerance) to this one.
public bool Contains(float tol, BBox other, bool strictly = false, bool testZ = true)
Parameters
tol
floatComparision tolerance.
other
BBoxOther bbox to test if contained into this one.
strictly
boolIf true, test will fails if one wcs ordinate of other bbox extensions equals to this one.
testZ
boolIf false tests acts only for x, y bounding box extension components (Default: true).
Returns
- bool
True if test succeeded.
EqualsTol(float, BBox)
States if this bbox equals (with tolerance) to another.
public bool EqualsTol(float tol, BBox other)
Parameters
Returns
- bool
True if two bbox are equals (with tolerance).
Intersects(BBox)
Test if this bbox and the other given intersects.
public bool Intersects(BBox other)
Parameters
other
BBoxOther bbox to test intersects with.
Returns
- bool
True if one of two box have at least one point inside the other.
Returns false if one of the given boxes is empty.
Intersects(float, BBox)
Test if this bbox and the other given intersects.
public bool Intersects(float tol, BBox other)
Parameters
Returns
- bool
True if one of two box have at least one point inside the other.
Returns false if one of the given boxes is empty.
Move(in Vector3)
Create a new bounding box with Min, Max moved by the given wcs delta.
public BBox Move(in Vector3 delta)
Parameters
delta
Vector3WCS delta to apply.
Returns
- BBox
Moved bounding box.
ToString()
public override string ToString()
Returns
Transform(Matrix4x4)
Create a new bbox that is the given one with extensions transformed by the given transform matrix.
public BBox Transform(Matrix4x4 m)
Parameters
m
Matrix4x4Transform matrix.
Returns
- BBox
Transformed bbox.
Union(BBox)
Create a new bounding box that is the result of the current with addition of the extensions of given other bbox.
public BBox Union(BBox other)
Parameters
other
BBoxOther bbox to add.
Returns
- BBox
Extended bbox.
Union(IEnumerable<Vector3>)
Create a new bounding box that is the result of the current with addition of given wcs point set.
public BBox Union(IEnumerable<Vector3> pts)
Parameters
pts
IEnumerable<Vector3>WCS point set to add.
Returns
- BBox
Extended bbox.
Union(in Vector3)
Create a new bounding box that is the result of the current with addition of given wcs point.
public BBox Union(in Vector3 p)
Parameters
p
Vector3WCS point to add.
Returns
- BBox
Extended bbox.