Description
The Contains
method determines whether a given point, represented by a Vector3
, is located within the boundaries of the sphere. This method is useful for collision detection or spatial queries where you need to verify if a point lies inside a spherical region.
Usage
To use the Contains
method, you need to have an instance of the Sphere
struct. You can then call the method by passing a reference to a Vector3
point. The method will return true
if the point is inside the sphere, and false
otherwise.
Example
// Create a sphere with a center at (0, 0, 0) and a radius of 5
Sphere sphere = new Sphere { Center = new Vector3(0, 0, 0), Radius = 5 };
// Define a point to check
Vector3 point = new Vector3(2, 2, 2);
// Check if the point is inside the sphere
bool isInside = sphere.Contains(ref point);
// Output the result
// isInside will be true if the point is within the sphere's radius from its center