Inside random_unit_vector()
, if random_in_unit_sphere()
returns a vector very close to
zero, passing that to unit_vector()
could result in a divide-by-zero fault.
One way to avoid this would be if the rejection method in random_in_unit_sphere()
also
rejected near-zero values. There is a near_zero()
function introduced later (in 10.3), that
would be useful here.