musicflower.util.remap_to_xyz

musicflower.util.remap_to_xyz(amplitude, phase, inner_radius=0.4, inverted=False, spherical=True, rescale_func=<ufunc 'sqrt'>, axis=-1)[source]

Map a triangular map with amplitudes and phases to 3D space. The axis representing the triangular map must have a size of k=n(n+1)/2 for some integer n to represent a valid triangular map (n is the resolution of the triangular map). The default is axis=-1, that is, the last axis.

Parameters
  • amplitude (ndarray) – array with amplitudes in the interval [0, 1]

  • phase (ndarray) – array with phases in radians

  • inner_radius (float) – an offset to avoid collapsing points at the center

  • inverted (bool) – invert the radial dimension

  • spherical (bool) – use spherical coordinates to map to the upper half-sphere (zero amplitudes map to the zenith/top; amplitudes of one map to the horizontal plane); if False, cylindrical coordinates are used (the amplitude is used as the vertical dimension)

  • rescale_func (callable) – function to rescale amplitudes; this should monotonically rescale the interval [0, 1]; the default uses np.sqrt, which distorts towards high amplitudes, i.e., it “opens up the top of the flower”.

  • axis (int) – axis of the input arrays that represents the triangular map

Return type

Tuple[ndarray, ndarray, ndarray]

Returns

x, y, z: 1D arrays of length k containing the Cartesian coordinates.