()
return np.array([x, y, z], dtype=np.float64)
Returns a random 3D vector with unit length.

  Generates a 3D vector selected uniformly from the unit sphere.

  Returns:
    A normalized 3D vector in a numpy array.
Returns a random 3D vector with unit length.
Returns a random 3D vector with unit length .
def Vector3RandomUnit():
  """Returns a random 3D vector with unit length.

  Generates a 3D vector selected uniformly from the unit sphere.

  Returns:
    A normalized 3D vector in a numpy array.
  """
  longitude = np.random.uniform(low=-math.pi, high=math.pi)
  sin_latitude = np.random.uniform(low=-1.0, high=1.0)
  cos_latitude = math.sqrt(1.0 - sin_latitude * sin_latitude)
  x = math.cos(longitude) * cos_latitude
  y = math.sin(longitude) * cos_latitude
  z = sin_latitude
  return np.array([x, y, z], dtype=np.float64)
def Vector3RandomUnit ( ) : longitude = np . random . uniform ( low = - math . pi , high = math . pi ) sin_latitude = np . random . uniform ( low = - 1.0 , high = 1.0 ) cos_latitude = math . sqrt ( 1.0 - sin_latitude * sin_latitude ) x = math . cos ( longitude ) * cos_latitude y = math . sin ( longitude ) * cos_latitude z = sin_latitude return np . array ( [ x , y , z ] , dtype = np . float64 )