INNER CODE UNIT · Python
sample_point_on_sphere
VITA-Group/Diffusion4D · rendering/blender.py:52
def sample_point_on_sphere(radius: float) -> Tuple[float, float, float]:
"""Samples a point on a sphere with the given radius.
Args:
radius (float): Radius of the sphere.
Returns:
Tuple[float, float, float]: A point on the sphere.
"""
theta = random.random() * 2 * math.pi
phi = math.acos(2 * random.random() - 1)
return (
radius * math.sin(phi) * math.cos(theta),
radius * math.sin(phi) * math.sin(theta),
radius * math.cos(phi),
)