Returns the cartesian product of multiple 1D arrays. For example, cartesian([0], [1, 2], [3, 4, 5]) returns:

array([[0, 1, 3],
       [0, 1, 4],
       [0, 1, 5],
       [0, 2, 3],
       [0, 2, 4],
       [0, 2, 5]])

Works with arbitrary objects.


Serializes an object’s attributes into a JSON string with support for mathutils objects.

All rotation objects are converted to a 4-element list representing wxyz quaternion form. All vectors are converted to a 3-element list.


Generates n rotations sampled uniformly from the group of all 3D rotations, SO(3).


n – (int): number of rotations to generate


List of mathutils.Quaternion objects.

starfish.utils.uniform_sphere(n, random=None)

Generates n points on the surface of a sphere that are “evenly spaced” using the golden spiral method. Based on https://stackoverflow.com/a/44164075.

  • n – (int): number of points to generate over the surface of the sphere

  • random – (int): if None, return all generated points. Otherwise, randomly sample this many points from the generated ones (default: None)


A tuple of the form (theta, phi), where theta and phi are each numpy arrays of length n. theta is the azimuthal angle, and phi is the polar angle.