Struct BoundingSphere
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
Represents a bounding sphere in three dimensional space.
[DataContract]
public struct BoundingSphere : IEquatable<BoundingSphere>, ISpanFormattable, IFormattable, IIntersectableWithRay, IIntersectableWithPlane- Implements
Constructors
BoundingSphere(Vector3, float)
Initializes a new instance of the BoundingSphere struct.
public BoundingSphere(Vector3 center, float radius)Parameters
- centerVector3
- The center of the sphere in three dimensional space. 
- radiusfloat
- The radius of the sphere. 
Fields
Center
The center of the sphere in three dimensional space.
public Vector3 CenterField Value
Empty
An empty bounding sphere (Center = 0 and Radius = 0).
public static readonly BoundingSphere EmptyField Value
Radius
The radius of the sphere.
public float RadiusField Value
Methods
Contains(ref readonly BoundingBox)
Determines whether the current objects contains a BoundingBox.
public ContainmentType Contains(ref readonly BoundingBox box)Parameters
- boxBoundingBox
- The box to test. 
Returns
- ContainmentType
- The type of containment the two objects have. 
Contains(ref readonly BoundingSphere)
Determines whether the current objects contains a BoundingSphere.
public ContainmentType Contains(ref readonly BoundingSphere sphere)Parameters
- sphereBoundingSphere
- The sphere to test. 
Returns
- ContainmentType
- The type of containment the two objects have. 
Contains(ref readonly Vector3)
Determines whether the current objects contains a point.
public ContainmentType Contains(ref readonly Vector3 point)Parameters
- pointVector3
- The point to test. 
Returns
- ContainmentType
- The type of containment the two objects have. 
Contains(ref readonly Vector3, ref readonly Vector3, ref readonly Vector3)
Determines whether the current objects contains a triangle.
public ContainmentType Contains(ref readonly Vector3 vertex1, ref readonly Vector3 vertex2, ref readonly Vector3 vertex3)Parameters
- vertex1Vector3
- The first vertex of the triangle to test. 
- vertex2Vector3
- The second vertex of the triagnle to test. 
- vertex3Vector3
- The third vertex of the triangle to test. 
Returns
- ContainmentType
- The type of containment the two objects have. 
Equals(BoundingSphere)
Determines whether the specified Vector4 is equal to this instance.
public readonly bool Equals(BoundingSphere value)Parameters
- valueBoundingSphere
- The Vector4 to compare with this instance. 
Returns
Equals(object?)
Determines whether the specified object is equal to this instance.
public override readonly bool Equals(object? value)Parameters
- valueobject
- The object to compare with this instance. 
Returns
- bool
- trueif the specified object is equal to this instance; otherwise,- false.
FromBox(BoundingBox)
Constructs a BoundingSphere from a given box.
public static BoundingSphere FromBox(BoundingBox box)Parameters
- boxBoundingBox
- The box that will designate the extents of the sphere. 
Returns
- BoundingSphere
- The newly constructed bounding sphere. 
FromBox(ref readonly BoundingBox, out BoundingSphere)
Constructs a BoundingSphere from a given box.
public static void FromBox(ref readonly BoundingBox box, out BoundingSphere result)Parameters
- boxBoundingBox
- The box that will designate the extents of the sphere. 
- resultBoundingSphere
- When the method completes, the newly constructed bounding sphere. 
FromPoints(Vector3[])
Constructs a BoundingSphere that fully contains the given points.
public static BoundingSphere FromPoints(Vector3[] points)Parameters
- pointsVector3[]
- The points that will be contained by the sphere. 
Returns
- BoundingSphere
- The newly constructed bounding sphere. 
FromPoints(Vector3[], out BoundingSphere)
Constructs a BoundingSphere that fully contains the given points.
public static void FromPoints(Vector3[] points, out BoundingSphere result)Parameters
- pointsVector3[]
- The points that will be contained by the sphere. 
- resultBoundingSphere
- When the method completes, contains the newly constructed bounding sphere. 
FromPoints(nint, int, int, int, out BoundingSphere)
Constructs a BoundingSphere that fully contains the given unmanaged points.
public static void FromPoints(nint vertexBufferPtr, int vertexPositionOffsetInBytes, int vertexCount, int vertexStride, out BoundingSphere result)Parameters
- vertexBufferPtrnint
- A pointer to of vertices containing points. 
- vertexPositionOffsetInBytesint
- The point offset in bytes starting from the vertex structure. 
- vertexCountint
- The verterx vertexCount. 
- vertexStrideint
- The vertex stride (size of vertex). 
- resultBoundingSphere
- When the method completes, contains the newly constructed bounding sphere. 
GetHashCode()
Returns a hash code for this instance.
public override readonly int GetHashCode()Returns
- int
- A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
Intersects(ref readonly BoundingBox)
Determines if there is an intersection between the current object and a BoundingBox.
public bool Intersects(ref readonly BoundingBox box)Parameters
- boxBoundingBox
- The box to test. 
Returns
- bool
- Whether the two objects intersected. 
Intersects(ref readonly BoundingSphere)
Determines if there is an intersection between the current object and a BoundingSphere.
public bool Intersects(ref readonly BoundingSphere sphere)Parameters
- sphereBoundingSphere
- The sphere to test. 
Returns
- bool
- Whether the two objects intersected. 
Intersects(ref readonly Plane)
Determines if there is an intersection between the current object and a Plane.
public PlaneIntersectionType Intersects(ref readonly Plane plane)Parameters
- planePlane
- The plane to test. 
Returns
- PlaneIntersectionType
- Whether the two objects intersected. 
Intersects(ref readonly Ray)
Determines if there is an intersection between the current object and a Ray.
public bool Intersects(ref readonly Ray ray)Parameters
- rayRay
- The ray to test. 
Returns
- bool
- Whether the two objects intersected. 
Intersects(ref readonly Ray, out Vector3)
Determines if there is an intersection between the current object and a Ray.
public bool Intersects(ref readonly Ray ray, out Vector3 point)Parameters
- rayRay
- The ray to test. 
- pointVector3
- When the method completes, contains the point of intersection, or Zero if there was no intersection. 
Returns
- bool
- Whether the two objects intersected. 
Intersects(ref readonly Ray, out float)
Determines if there is an intersection between the current object and a Ray.
public bool Intersects(ref readonly Ray ray, out float distance)Parameters
- rayRay
- The ray to test. 
- distancefloat
- When the method completes, contains the distance of the intersection, or 0 if there was no intersection. 
Returns
- bool
- Whether the two objects intersected. 
Intersects(ref readonly Vector3, ref readonly Vector3, ref readonly Vector3)
Determines if there is an intersection between the current object and a triangle.
public bool Intersects(ref readonly Vector3 vertex1, ref readonly Vector3 vertex2, ref readonly Vector3 vertex3)Parameters
- vertex1Vector3
- The first vertex of the triangle to test. 
- vertex2Vector3
- The second vertex of the triagnle to test. 
- vertex3Vector3
- The third vertex of the triangle to test. 
Returns
- bool
- Whether the two objects intersected. 
Merge(BoundingSphere, BoundingSphere)
Constructs a BoundingSphere that is the as large as the total combined area of the two specified spheres.
public static BoundingSphere Merge(BoundingSphere value1, BoundingSphere value2)Parameters
- value1BoundingSphere
- The first sphere to merge. 
- value2BoundingSphere
- The second sphere to merge. 
Returns
- BoundingSphere
- The newly constructed bounding sphere. 
Merge(ref readonly BoundingSphere, ref readonly BoundingSphere, out BoundingSphere)
Constructs a BoundingSphere that is the as large as the total combined area of the two specified spheres.
public static void Merge(ref readonly BoundingSphere value1, ref readonly BoundingSphere value2, out BoundingSphere result)Parameters
- value1BoundingSphere
- The first sphere to merge. 
- value2BoundingSphere
- The second sphere to merge. 
- resultBoundingSphere
- When the method completes, contains the newly constructed bounding sphere. 
ToString()
Returns a string that represents this instance.
public override readonly string ToString()Returns
ToString(string?, IFormatProvider?)
Returns a string that represents this instance.
public readonly string ToString(string? format, IFormatProvider? formatProvider)Parameters
- formatstring
- The format. 
- formatProviderIFormatProvider
- The format provider. 
Returns
Transform(ref readonly BoundingSphere, ref readonly Matrix, out BoundingSphere)
Transforms a bounding sphere, yielding the bounding sphere of all points contained by the original one, transformed by the specified transform.
public static void Transform(ref readonly BoundingSphere value, ref readonly Matrix transform, out BoundingSphere result)Parameters
- valueBoundingSphere
- The original bounding sphere. 
- transformMatrix
- The transform to apply to the bounding sphere. 
- resultBoundingSphere
- The transformed bounding sphere. 
Operators
operator ==(BoundingSphere, BoundingSphere)
Tests for equality between two objects.
public static bool operator ==(BoundingSphere left, BoundingSphere right)Parameters
- leftBoundingSphere
- The first value to compare. 
- rightBoundingSphere
- The second value to compare. 
Returns
- bool
- trueif- lefthas the same value as- right; otherwise,- false.
operator !=(BoundingSphere, BoundingSphere)
Tests for inequality between two objects.
public static bool operator !=(BoundingSphere left, BoundingSphere right)Parameters
- leftBoundingSphere
- The first value to compare. 
- rightBoundingSphere
- The second value to compare. 
Returns
- bool
- trueif- lefthas a different value than- right; otherwise,- false.