Acoular 25.03 documentation

acoular.environments.spiral_sphere

«  acoular.environments.cartToCyl   ::   environments   ::   fbeamform  »

acoular.environments.spiral_sphere

acoular.environments.spiral_sphere(N, Om=None, b=None)

Generate unit vectors equally distributed over a sphere or a portion of it.

Internal helper function for the raycasting that returns an array of unit vectors of shape (N, 3) giving equally distributed directions on a part of sphere given by the center direction b and the solid angle Om.

The function uses spherical coordinates to distribute the points, the converts them to Cartesian coordinates. It also applies a transformation to reflect the points about a plane so that the direction defined by the vector b points toward the center of the sphere.

Parameters:
Nint

The number of points to generate on the sphere.

Omfloat, optional

The solid angle in steradians to cover on the sphere. Default is 2 * pi, which corresponds to a hemisphere. Smaller values result in covering a smaller portion of the hemisphere.

bnumpy.ndarray of floats, optional

A 3D unit vector specifying the desired center direction of the distribution. Points are mirrored such that this vector points toward the center of the sphere. Default is [0, 0, 1], which corresponds to the z-axis.

Returns:
numpy.ndarray of floats

An array of unit vectors representing points on the sphere, shape (3, N). Each column corresponds to a 3D Cartesian coordinate of a point.

Notes

  • The points are initially distributed using a spiral pattern in spherical coordinates. This ensures an approximately equal spacing between points over the specified portion of the sphere.

  • If a vector b is provided, the function mirrors the distribution using a Householder reflection so that b points toward the center.

  • The function avoids generating singularities at the poles by adjusting the spiral distribution formula.

Examples

Generate 100 points over a hemisphere:

>>> from acoular.environments import spiral_sphere
>>> points = spiral_sphere(100)
>>> points.shape
(3, 100)

Generate 50 points over half a hemisphere with the z-axis as the center direction:

>>> import numpy as np
>>> points = spiral_sphere(50, Om=np.pi, b=array((0, 0, 1)))
>>> points.shape
(3, 50)

Generate 200 points with a different direction vector:

>>> points = spiral_sphere(200, b=array((1, 0, 0)))
>>> points.shape
(3, 200)

«  acoular.environments.cartToCyl   ::   environments   ::   fbeamform  »