Struct BoundingBox
A bounding axis-aligned object.
Implements
Inherited Members
Namespace: JeremyAnsel.DirectX.DXMath.Collision
Assembly: JeremyAnsel.DirectX.DXMath.dll
Syntax
public struct BoundingBox : IEquatable<BoundingBox>
Constructors
| Edit this page View SourceBoundingBox(XMFloat3, XMFloat3)
Initializes a new instance of the BoundingBox struct.
Declaration
public BoundingBox(XMFloat3 center, XMFloat3 extents)
Parameters
| Type | Name | Description |
|---|---|---|
| XMFloat3 | center | The coordinate of the center of the box. |
| XMFloat3 | extents | The extents of the box. |
Fields
| Edit this page View SourceCornerCount
The number of points defining the BoundingBox.
Declaration
public const int CornerCount = 8
Field Value
| Type | Description |
|---|---|
| int |
Properties
| Edit this page View SourceCenter
Gets or sets the center of the BoundingBox.
Declaration
public XMFloat3 Center { get; set; }
Property Value
| Type | Description |
|---|---|
| XMFloat3 |
Extents
Gets or sets the extents of the BoundingBox.
Declaration
public XMFloat3 Extents { get; set; }
Property Value
| Type | Description |
|---|---|
| XMFloat3 |
Methods
| Edit this page View SourceContainedBy(XMVector, XMVector, XMVector, XMVector, XMVector, XMVector)
Tests whether the BoundingBox is contained by the specified frustum.
Declaration
public ContainmentType ContainedBy(XMVector plane0, XMVector plane1, XMVector plane2, XMVector plane3, XMVector plane4, XMVector plane5)
Parameters
| Type | Name | Description |
|---|---|---|
| XMVector | plane0 | The first plane describing the frustum. |
| XMVector | plane1 | The second plane describing the frustum. |
| XMVector | plane2 | The third plane describing the frustum. |
| XMVector | plane3 | The fourth plane describing the frustum. |
| XMVector | plane4 | The fifth plane describing the frustum. |
| XMVector | plane5 | The sixth plane describing the frustum. |
Returns
| Type | Description |
|---|---|
| ContainmentType | A ContainmentType value indicating whether the frustum contains the BoundingBox. |
ContainedBy(XMVector[]?)
Tests whether the BoundingBox is contained by the specified frustum.
Declaration
public ContainmentType ContainedBy(XMVector[]? planes)
Parameters
| Type | Name | Description |
|---|---|---|
| XMVector[] | planes | The planes describing the frustum. |
Returns
| Type | Description |
|---|---|
| ContainmentType | A ContainmentType value indicating whether the frustum contains the BoundingBox. |
Contains(BoundingBox)
Tests whether the BoundingBox contains another BoundingBox.
Declaration
public ContainmentType Contains(BoundingBox box)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | box | The BoundingBox to test against. |
Returns
| Type | Description |
|---|---|
| ContainmentType | A ContainmentType value indicating whether the BoundingBox contains the specified BoundingBox. |
Contains(BoundingFrustum)
Tests whether the BoundingBox contains the specified BoundingFrustum.
Declaration
public ContainmentType Contains(BoundingFrustum fr)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingFrustum | fr | The BoundingFrustum to test against. |
Returns
| Type | Description |
|---|---|
| ContainmentType | A ContainmentType value indicating whether the BoundingFrustum is contained in the BoundingBox. |
Contains(BoundingOrientedBox)
Tests whether the BoundingBox contains the specified BoundingOrientedBox.
Declaration
public ContainmentType Contains(BoundingOrientedBox box)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingOrientedBox | box | The BoundingOrientedBox to test against. |
Returns
| Type | Description |
|---|---|
| ContainmentType | A ContainmentType value indicating whether the BoundingOrientedBox is contained in the BoundingBox. |
Contains(BoundingSphere)
Tests whether the BoundingBox contains a specified BoundingSphere.
Declaration
public ContainmentType Contains(BoundingSphere sh)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingSphere | sh | The BoundingSphere to test against. |
Returns
| Type | Description |
|---|---|
| ContainmentType | A ContainmentType value indicating whether the BoundingBox contains the BoundingSphere. |
Contains(XMVector)
Tests the whether the BoundingBox contains a specified point.
Declaration
public ContainmentType Contains(XMVector point)
Parameters
| Type | Name | Description |
|---|---|---|
| XMVector | point | The point to test against. |
Returns
| Type | Description |
|---|---|
| ContainmentType | A ContainmentType value indicating whether the point is contained in the BoundingBox. |
Contains(XMVector, XMVector, XMVector)
Test whether the BoundingBox contains a specified triangle.
Declaration
public ContainmentType Contains(XMVector v0, XMVector v1, XMVector v2)
Parameters
| Type | Name | Description |
|---|---|---|
| XMVector | v0 | The first corner of the triangle. |
| XMVector | v1 | The second corner of the triangle. |
| XMVector | v2 | The third corner of the triangle. |
Returns
| Type | Description |
|---|---|
| ContainmentType | A ContainmentType value indicating whether the BoundingBox contains the specified triangle. |
CreateFromPoints(XMFloat3[]?)
Creates a BoundingBox from a list of points.
Declaration
public static BoundingBox CreateFromPoints(XMFloat3[]? points)
Parameters
| Type | Name | Description |
|---|---|---|
| XMFloat3[] | points | The points to create the BoundingBox from. |
Returns
| Type | Description |
|---|---|
| BoundingBox | The new BoundingBox containing the specified points. |
CreateFromPoints(XMVector, XMVector)
Creates a BoundingBox from two points.
Declaration
public static BoundingBox CreateFromPoints(XMVector pt1, XMVector pt2)
Parameters
| Type | Name | Description |
|---|---|---|
| XMVector | pt1 | The first point the new BoundingBox should contain. |
| XMVector | pt2 | The second point the new BoundingBox should contain. |
Returns
| Type | Description |
|---|---|
| BoundingBox | The new BoundingBox containing the two specified points. |
CreateFromSphere(BoundingSphere)
Creates a BoundingBox large enough to contain the a specified BoundingSphere.
Declaration
public static BoundingBox CreateFromSphere(BoundingSphere sh)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingSphere | sh | The BoundingSphere the new BoundingBox should contain. |
Returns
| Type | Description |
|---|---|
| BoundingBox | The new BoundingBox. |
CreateMerged(BoundingBox, BoundingBox)
Creates a BoundingBox large enough to contains two specified BoundingBox instances.
Declaration
public static BoundingBox CreateMerged(BoundingBox b1, BoundingBox b2)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | b1 | The first BoundingBox that should be contained in the new BoundingBox. |
| BoundingBox | b2 | The second BoundingBox that should be contained in the new BoundingBox. |
Returns
| Type | Description |
|---|---|
| BoundingBox | The merged BoundingBox. |
Equals(BoundingBox)
Determines whether the specified object is equal to the current object.
Declaration
public bool Equals(BoundingBox other)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | other | The object to compare with the current object. |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object?)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current object. |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceGetCorners()
Retrieves the corners of the BoundingBox.
Declaration
public XMFloat3[] GetCorners()
Returns
| Type | Description |
|---|---|
| XMFloat3[] | The corners of the BoundingBox. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
| Edit this page View SourceIntersects(BoundingBox)
Tests the BoundingBox for intersection with another BoundingBox.
Declaration
public bool Intersects(BoundingBox box)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | box | The BoundingBox to test for intersection. |
Returns
| Type | Description |
|---|---|
| bool | A boolean value indicating whether the BoundingBox intersects the specified BoundingBox. |
Intersects(BoundingFrustum)
Test the BoundingBox for intersection with a BoundingFrustum.
Declaration
public bool Intersects(BoundingFrustum fr)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingFrustum | fr | The BoundingFrustum to test for intersection. |
Returns
| Type | Description |
|---|---|
| bool | A boolean value indicating whether the BoundingBox intersects the specified BoundingFrustum. |
Intersects(BoundingOrientedBox)
Test the BoundingBox for intersection with a BoundingOrientedBox.
Declaration
public bool Intersects(BoundingOrientedBox box)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingOrientedBox | box | The BoundingOrientedBox to test for intersection. |
Returns
| Type | Description |
|---|---|
| bool | A boolean value indicating whether the BoundingBox intersects the specified BoundingOrientedBox. |
Intersects(BoundingSphere)
Tests the BoundingBox for intersection with a BoundingSphere.
Declaration
public bool Intersects(BoundingSphere sh)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingSphere | sh | The BoundingSphere to test for intersection. |
Returns
| Type | Description |
|---|---|
| bool | A boolean value indicating whether the BoundingBox intersects the specified BoundingSphere. |
Intersects(XMVector)
Test the BoundingBox for intersection with a plane.
Declaration
public PlaneIntersectionType Intersects(XMVector plane)
Parameters
| Type | Name | Description |
|---|---|---|
| XMVector | plane | A vector describing the plane. |
Returns
| Type | Description |
|---|---|
| PlaneIntersectionType | A PlaneIntersectionType value indicating the intersection status. |
Intersects(XMVector, XMVector)
Test the BoundingBox for intersection with a ray.
Declaration
public bool Intersects(XMVector origin, XMVector direction)
Parameters
| Type | Name | Description |
|---|---|---|
| XMVector | origin | The origin of the ray. |
| XMVector | direction | The direction of the ray. |
Returns
| Type | Description |
|---|---|
| bool | A boolean value indicating whether the BoundingBox intersects the ray. |
Intersects(XMVector, XMVector, XMVector)
Test the BoundingBox for intersection with a triangle.
Declaration
public bool Intersects(XMVector v0, XMVector v1, XMVector v2)
Parameters
| Type | Name | Description |
|---|---|---|
| XMVector | v0 | The first vector describing the triangle. |
| XMVector | v1 | The second vector describing the triangle. |
| XMVector | v2 | The third vector describing the triangle. |
Returns
| Type | Description |
|---|---|
| bool | A boolean value indicating whether the BoundingBox intersects the triangle. |
Intersects(XMVector, XMVector, out float)
Test the BoundingBox for intersection with a ray.
Declaration
public bool Intersects(XMVector origin, XMVector direction, out float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| XMVector | origin | The origin of the ray. |
| XMVector | direction | The direction of the ray. |
| float | distance | The length of the ray. |
Returns
| Type | Description |
|---|---|
| bool | A boolean value indicating whether the BoundingBox intersects the ray. |
Transform(XMMatrix)
Transforms the BoundingBox.
Declaration
public BoundingBox Transform(XMMatrix m)
Parameters
| Type | Name | Description |
|---|---|---|
| XMMatrix | m | The matrix to transform the BoundingBox by. |
Returns
| Type | Description |
|---|---|
| BoundingBox | The transformed BoundingBox. |
Transform(float, XMVector, XMVector)
Transforms the BoundingBox.
Declaration
public BoundingBox Transform(float scale, XMVector rotation, XMVector translation)
Parameters
| Type | Name | Description |
|---|---|---|
| float | scale | The value to scale the BoundingBox by. |
| XMVector | rotation | The value to rotate the BoundingBox by. |
| XMVector | translation | The value to translate the BoundingBox by. |
Returns
| Type | Description |
|---|---|
| BoundingBox | The transformed BoundingBox. |
Operators
| Edit this page View Sourceoperator ==(BoundingBox, BoundingBox)
Compares two BoundingBox objects. The result specifies whether the values of the two objects are equal.
Declaration
public static bool operator ==(BoundingBox left, BoundingBox right)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | left | The left BoundingBox to compare. |
| BoundingBox | right | The right BoundingBox to compare. |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(BoundingBox, BoundingBox)
Compares two BoundingBox objects. The result specifies whether the values of the two objects are unequal.
Declaration
public static bool operator !=(BoundingBox left, BoundingBox right)
Parameters
| Type | Name | Description |
|---|---|---|
| BoundingBox | left | The left BoundingBox to compare. |
| BoundingBox | right | The right BoundingBox to compare. |
Returns
| Type | Description |
|---|---|
| bool |