static Vector3 VectorInCube( System.Random self, float extents )
static Vector3 VectorInCube( System.Random self, BBox& box )

robot_2Generated
code_blocksInput

Description

The VectorInCube method is a static extension method for the System.Random class, provided by the Sandbox.SandboxSystemExtensions class. It generates a random Vector3 within a cube centered at the origin with the specified extents. This method is useful for generating random positions within a defined cubic space.

Usage

To use the VectorInCube method, you need to have an instance of System.Random. You can then call this method to generate a random Vector3 within a cube of the specified size.

Parameters:

  • self: An instance of System.Random used to generate random numbers.
  • extents: A float value representing half the length of the cube's side. The cube is centered at the origin, so the full side length is 2 * extents.

Returns: A Vector3 representing a random point within the specified cube.

Example

// Example usage of VectorInCube
System.Random random = new System.Random();
float extents = 5.0f;
Vector3 randomPoint = random.VectorInCube(extents);

// randomPoint is now a Vector3 within a cube centered at the origin with side length 10 (extents * 2)