Description
The Capsule.FromHeightAndRadius
method creates a new Capsule
instance using the specified height and radius. A capsule is a geometric shape that consists of a cylinder with hemispherical ends. This method is useful for generating capsules in 3D space, which can be used in various physics and rendering calculations.
Usage
To use the FromHeightAndRadius
method, call it with the desired height and radius values. The method will return a Capsule
object that represents the specified dimensions.
Parameters:
height
(System.Single
): The total height of the capsule, including the cylindrical and hemispherical parts.
radius
(System.Single
): The radius of the capsule's cylindrical part and hemispherical ends.
Returns: A Capsule
object with the specified height and radius.
Example
// Example of creating a capsule with a height of 10 units and a radius of 2 units.
Capsule myCapsule = Capsule.FromHeightAndRadius(10.0f, 2.0f);
// Accessing properties of the capsule
Vector3 centerA = myCapsule.CenterA;
Vector3 centerB = myCapsule.CenterB;
float radius = myCapsule.Radius;
// Getting a random point inside the capsule
Vector3 randomPointInside = myCapsule.RandomPointInside;
// Getting a random point on the edge of the capsule
Vector3 randomPointOnEdge = myCapsule.RandomPointOnEdge;