The OpenD Programming Language

sphereVar

Uniform distribution on a sphere.

sphereVar
(
T = double
)
()

Return Value

Type: SphereVariable!T

X ~ 1 with X[0]^^2 + .. + X[$-1]^^2 = 1

Examples

Generate random points on a circle

import mir.random.engine;
import mir.math.common: fabs;

double[2] x;
sphereVar()(rne, x);
assert(fabs(x[0] * x[0] + x[1] * x[1] - 1) < 1e-10);

Meta