Directivity Module
The directivity module provides tools to work with directivity.
The following conventions are used within this module:
- The inclination angle \(\theta\) has a range \([0, \pi]\).
- The azimuth angle \(\phi\) has a range \([0 , 2 \pi]\).
| FUNCTION | DESCRIPTION |
|---|---|
cardioid |
Generate a cardioid pattern. |
figure_eight |
Generate a figure-of-eight pattern. |
spherical_harmonic |
Calculate spherical harmonic of order |
spherical_to_cartesian |
Convert spherical coordinates to cartesian coordinates. |
cartesian_to_spherical |
Convert cartesian coordinates to spherical coordinates. |
| CLASS | DESCRIPTION |
|---|---|
Directivity |
Abstract class for directivity. |
Omni |
Class for omni-directional directivity. |
Cardioid |
Class for cardioid directivity. |
FigureEight |
Class for figure-of-eight directivity. |
SphericalHarmonic |
Class for spherical harmonic directivity. |
Custom |
Class for custom directivity. |
Classes
Directivity
Abstract directivity class.
This class defines several methods to be implemented by subclasses.
| PARAMETER | DESCRIPTION |
|---|---|
rotation
|
Rotation of the directivity pattern.
DEFAULT:
|
Source code in acoustic_toolbox/directivity.py
Functions
using_spherical
using_spherical(
theta, phi, r=None, include_rotation: bool = True
)
Return the directivity for given spherical coordinates.
| PARAMETER | DESCRIPTION |
|---|---|
theta
|
angle \(\theta\)
|
phi
|
angle \(\phi\)
|
r
|
norm (optional)
DEFAULT:
|
include_rotation
|
Apply the rotation to the directivity.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
|
Directivity. |
Todo
Correct for rotation!!!!
Source code in acoustic_toolbox/directivity.py
using_cartesian
using_cartesian(x, y, z, include_rotation: bool = True)
Return the directivity for given cartesian coordinates.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
x
|
y
|
y
|
z
|
z
|
include_rotation
|
Apply the rotation to the directivity.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
|
Directivity. |
Todo
Correct for rotation!!!!
Source code in acoustic_toolbox/directivity.py
plot
Directivity plot. Plot to filename when given.
| PARAMETER | DESCRIPTION |
|---|---|
filename
|
Filename
TYPE:
|
include_rotation
|
Apply the rotation to the directivity. By default the rotation is applied in this figure.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
Figure. |
Todo
filename
Source code in acoustic_toolbox/directivity.py
Omni
Bases: Directivity
Class to work with omni-directional directivity.
Source code in acoustic_toolbox/directivity.py
Cardioid
FigureEight
SphericalHarmonic
Bases: Directivity
Directivity of a spherical harmonic of degree n and order m.
Source code in acoustic_toolbox/directivity.py
Custom
Functions
cardioid
A cardioid pattern.
| PARAMETER | DESCRIPTION |
|---|---|
a
|
a
DEFAULT:
|
k
|
k
DEFAULT:
|
theta
|
angle \(\theta\)
|
| RETURNS | DESCRIPTION |
|---|---|
|
Cardioid pattern. |
figure_eight
A figure-of-eight pattern.
| PARAMETER | DESCRIPTION |
|---|---|
theta
|
angle \(\theta\)
|
phi
|
angle \(\phi\)
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
|
Figure-of-eight pattern. |
Source code in acoustic_toolbox/directivity.py
spherical_harmonic
Spherical harmonic of order m and degree n.
Note
The degree n is often denoted l.
See Also
Source code in acoustic_toolbox/directivity.py
spherical_to_cartesian
Convert spherical coordinates to cartesian coordinates.
| PARAMETER | DESCRIPTION |
|---|---|
r
|
norm
|
theta
|
angle \(\theta\)
|
phi
|
angle \(\phi\)
|
| RETURNS | DESCRIPTION |
|---|---|
x
|
\(x = r \sin{\theta}\cos{\phi}\) |
y
|
\(y = r \sin{\theta}\sin{\phi}\) |
z
|
\(z = r \cos{\theta}\) |
Source code in acoustic_toolbox/directivity.py
cartesian_to_spherical
Convert cartesian coordinates to spherical coordinates.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
x
|
y
|
y
|
z
|
z
|
| RETURNS | DESCRIPTION |
|---|---|
r
|
\(r = \sqrt{\left( x^2 + y^2 + z^2 \right)}\) |
theta
|
\(\theta = \arccos{\frac{z}{r}}\) |
phi
|
\(\phi = \arccos{\frac{y}{x}}\) |
Source code in acoustic_toolbox/directivity.py
plot
plot(d: Directivity, sphere: bool = False) -> Figure
Plot directivity d.
| PARAMETER | DESCRIPTION |
|---|---|
d
|
Directivity
TYPE:
|
sphere
|
Plot on a sphere.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
Figure |
Source code in acoustic_toolbox/directivity.py
:::