warp.sample_unit_sphere#
- warp.sample_unit_sphere(state: uint32) vec3f#
Kernel
Python
Uniformly sample a point inside the unit ball (radius <= 1).
Returns a
vec3. In a kernel, advancesstatein place; called from the Python scope, it does not modifystate, so repeated calls with the samestatereturn the same point (seerand_init()).The other
sample_unit_*helpers are called the same way (initializerngwithrand_init(), then pass it), differing only in the domain they sample:@wp.kernel def random_points(seed: int, out: wp.array[wp.vec3]): i = wp.tid() rng = wp.rand_init(seed, i) out[i] = wp.sample_unit_sphere(rng)