BoundingBox Struct
Namespace: Stride.Core.MathematicsAssembly: Stride.Core.Mathematics.dll
Represents an axis-aligned bounding box in three dimensional space.
[DataContract]
public struct BoundingBox : IEquatable<BoundingBox>, IFormattable, IIntersectableWithRay, IIntersectableWithPlane
| Name | Description | |
|---|---|---|
| Constructors | ||
| BoundingBox(Vector3, Vector3) | Initializes a new instance of the BoundingBox struct. |
|
| Fields | ||
| Empty | A BoundingBox which represents an empty space. |
|
| Maximum | The maximum point of the box. |
|
| Minimum | The minimum point of the box. |
|
| Properties | ||
| Center | Gets the center of this bouding box. |
|
| Extent | Gets the extent of this bouding box. |
|
| Methods | ||
| Contains(ref BoundingBox) | Determines whether the current objects contains a BoundingBox. |
|
| Contains(ref BoundingSphere) | Determines whether the current objects contains a BoundingSphere. |
|
| Contains(ref Vector3) | Determines whether the current objects contains a point. |
|
| Equals(BoundingBox) | Determines whether the specified Vector4 is equal to this instance. |
|
| Equals(Object) | Determines whether the specified System.Object is equal to this instance. |
|
| FromPoints(Vector3[]) | Constructs a BoundingBox that fully contains the given points. |
|
| FromPoints(Vector3[], out BoundingBox) | Constructs a BoundingBox that fully contains the given points. |
|
| FromSphere(BoundingSphere) | Constructs a BoundingBox from a given sphere. |
|
| FromSphere(ref BoundingSphere, out BoundingBox) | Constructs a BoundingBox from a given sphere. |
|
| GetCorners() | Retrieves the eight corners of the bounding box. |
|
| GetHashCode() | Returns a hash code for this instance. |
|
| Intersects(ref BoundingBox) | Determines if there is an intersection between the current object and a BoundingBox. |
|
| Intersects(ref BoundingSphere) | Determines if there is an intersection between the current object and a BoundingSphere. |
|
| Intersects(ref Plane) | Determines if there is an intersection between the current object and a Plane. |
|
| Intersects(ref Ray) | Determines if there is an intersection between the current object and a Ray. |
|
| Intersects(ref Ray, out Vector3) | Determines if there is an intersection between the current object and a Ray. |
|
| Intersects(ref Ray, out Single) | Determines if there is an intersection between the current object and a Ray. |
|
| Merge(BoundingBox, BoundingBox) | Constructs a BoundingBox that is as large as the total combined area of the two specified boxes. |
|
| Merge(ref BoundingBox, ref BoundingBox, out BoundingBox) | Constructs a BoundingBox that is as large as the total combined area of the two specified boxes. |
|
| Merge(ref BoundingBox, ref Vector3, out BoundingBox) | Constructs a BoundingBox that is as large enough to contains the bounding box and the given point. |
|
| ToString() | Returns a System.String that represents this instance. |
|
| ToString(IFormatProvider) | Returns a System.String that represents this instance. |
|
| ToString(String) | Returns a System.String that represents this instance. |
|
| ToString(String, IFormatProvider) | Returns a System.String that represents this instance. |
|
| Transform(ref BoundingBox, ref Matrix, out BoundingBox) | Transform a bounding box. |
|
| Operators | ||
| Equality(BoundingBox, BoundingBox) | Tests for equality between two objects. |
|
| Inequality(BoundingBox, BoundingBox) | Tests for inequality between two objects. |
|
Constructors
BoundingBox(Vector3, Vector3)
Initializes a new instance of the BoundingBox struct.
public BoundingBox(Vector3 minimum, Vector3 maximum)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | minimum | The minimum vertex of the bounding box. |
| Vector3 | maximum | The maximum vertex of the bounding box. |
Fields
Empty
A BoundingBox which represents an empty space.
public static readonly BoundingBox Empty
Field Value
| Type | Description |
|---|---|
| BoundingBox |
Maximum
The maximum point of the box.
public Vector3 Maximum
Field Value
| Type | Description |
|---|---|
| Vector3 |
Minimum
The minimum point of the box.
public Vector3 Minimum
Field Value
| Type | Description |
|---|---|
| Vector3 |
Properties
Center
Gets the center of this bouding box.
public readonly Vector3 Center { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
Extent
Gets the extent of this bouding box.
public readonly Vector3 Extent { get; }
Property Value
| Type | Description |
|---|---|
| Vector3 |
Methods
Contains(ref BoundingBox)
Determines whether the current objects contains a BoundingBox.
public ContainmentType Contains(ref BoundingBox box)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | box | The box to test. |
Returns
| Type | Description |
|---|---|
| ContainmentType | The type of containment the two objects have. |
Contains(ref BoundingSphere)
Determines whether the current objects contains a BoundingSphere.
public ContainmentType Contains(ref BoundingSphere sphere)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingSphere | sphere | The sphere to test. |
Returns
| Type | Description |
|---|---|
| ContainmentType | The type of containment the two objects have. |
Contains(ref Vector3)
Determines whether the current objects contains a point.
public ContainmentType Contains(ref Vector3 point)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | point | The point to test. |
Returns
| Type | Description |
|---|---|
| ContainmentType | The type of containment the two objects have. |
Equals(BoundingBox)
Determines whether the specified Vector4 is equal to this instance.
public bool Equals(BoundingBox value)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | value | The Vector4 to compare with this instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
public override bool Equals(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The System.Object to compare with this instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Overrides
FromPoints(Vector3[])
Constructs a BoundingBox that fully contains the given points.
public static BoundingBox FromPoints(Vector3[] points)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3[] | points | The points that will be contained by the box. |
Returns
| Type | Description |
|---|---|
| BoundingBox | The newly constructed bounding box. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
FromPoints(Vector3[], out BoundingBox)
Constructs a BoundingBox that fully contains the given points.
public static void FromPoints(Vector3[] points, out BoundingBox result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3[] | points | The points that will be contained by the box. |
| BoundingBox | result | When the method completes, contains the newly constructed bounding box. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when |
FromSphere(BoundingSphere)
Constructs a BoundingBox from a given sphere.
public static BoundingBox FromSphere(BoundingSphere sphere)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingSphere | sphere | The sphere that will designate the extents of the box. |
Returns
| Type | Description |
|---|---|
| BoundingBox | The newly constructed bounding box. |
FromSphere(ref BoundingSphere, out BoundingBox)
Constructs a BoundingBox from a given sphere.
public static void FromSphere(ref BoundingSphere sphere, out BoundingBox result)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingSphere | sphere | The sphere that will designate the extents of the box. |
| BoundingBox | result | When the method completes, contains the newly constructed bounding box. |
GetCorners()
Retrieves the eight corners of the bounding box.
public Vector3[] GetCorners()
Returns
| Type | Description |
|---|---|
| Vector3[] | An array of points representing the eight corners of the bounding box. |
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
Intersects(ref BoundingBox)
Determines if there is an intersection between the current object and a BoundingBox.
public bool Intersects(ref BoundingBox box)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | box | The box to test. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the two objects intersected. |
Intersects(ref BoundingSphere)
Determines if there is an intersection between the current object and a BoundingSphere.
public bool Intersects(ref BoundingSphere sphere)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingSphere | sphere | The sphere to test. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the two objects intersected. |
Intersects(ref Plane)
Determines if there is an intersection between the current object and a Plane.
public PlaneIntersectionType Intersects(ref Plane plane)
Parameters
| Type | Name | Description |
|---|---|---|
| Plane | plane | The plane to test. |
Returns
| Type | Description |
|---|---|
| PlaneIntersectionType | Whether the two objects intersected. |
Intersects(ref Ray)
Determines if there is an intersection between the current object and a Ray.
public bool Intersects(ref Ray ray)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray to test. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the two objects intersected. |
Intersects(ref Ray, out Vector3)
Determines if there is an intersection between the current object and a Ray.
public bool Intersects(ref Ray ray, out Vector3 point)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray to test. |
| Vector3 | point | When the method completes, contains the point of intersection, or Zero if there was no intersection. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the two objects intersected. |
Intersects(ref Ray, out Single)
Determines if there is an intersection between the current object and a Ray.
public bool Intersects(ref Ray ray, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray to test. |
| System.Single | distance | When the method completes, contains the distance of the intersection, or 0 if there was no intersection. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the two objects intersected. |
Merge(BoundingBox, BoundingBox)
Constructs a BoundingBox that is as large as the total combined area of the two specified boxes.
public static BoundingBox Merge(BoundingBox value1, BoundingBox value2)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | value1 | The first box to merge. |
| BoundingBox | value2 | The second box to merge. |
Returns
| Type | Description |
|---|---|
| BoundingBox | The newly constructed bounding box. |
Merge(ref BoundingBox, ref BoundingBox, out BoundingBox)
Constructs a BoundingBox that is as large as the total combined area of the two specified boxes.
public static void Merge(ref BoundingBox value1, ref BoundingBox value2, out BoundingBox result)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | value1 | The first box to merge. |
| BoundingBox | value2 | The second box to merge. |
| BoundingBox | result | When the method completes, contains the newly constructed bounding box. |
Merge(ref BoundingBox, ref Vector3, out BoundingBox)
Constructs a BoundingBox that is as large enough to contains the bounding box and the given point.
public static void Merge(ref BoundingBox value1, ref Vector3 value2, out BoundingBox result)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | value1 | The box to merge. |
| Vector3 | value2 | The point to merge. |
| BoundingBox | result | When the method completes, contains the newly constructed bounding box. |
ToString()
Returns a System.String that represents this instance.
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
Overrides
ToString(IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(IFormatProvider formatProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IFormatProvider | formatProvider | The format provider. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
ToString(String)
Returns a System.String that represents this instance.
public string ToString(string format)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | format | The format. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
ToString(String, IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | format | The format. |
| System.IFormatProvider | formatProvider | The format provider. |
Returns
| Type | Description |
|---|---|
| System.String | A System.String that represents this instance. |
Transform(ref BoundingBox, ref Matrix, out BoundingBox)
Transform a bounding box.
public static void Transform(ref BoundingBox value, ref Matrix transform, out BoundingBox result)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | value | The original bounding box. |
| Matrix | transform | The transform to apply to the bounding box. |
| BoundingBox | result | The transformed bounding box. |
Operators
Equality(BoundingBox, BoundingBox)
Tests for equality between two objects.
public static bool operator ==(BoundingBox left, BoundingBox right)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | left | The first value to compare. |
| BoundingBox | right | The second value to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Inequality(BoundingBox, BoundingBox)
Tests for inequality between two objects.
public static bool operator !=(BoundingBox left, BoundingBox right)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | left | The first value to compare. |
| BoundingBox | right | The second value to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|