sparrowpy.brdf#

Contain functions to create BRDFs from scattering coefficients.

Functions:

create_from_directional_scattering(...[, ...])

Create the BRDF from the directional scattering and write to SOFA file.

create_from_scattering(source_directions, ...)

Create the BRDF from a scattering coefficient and write to SOFA file.

sparrowpy.brdf.create_from_directional_scattering(source_directions, receiver_directions, directional_scattering, absorption_coefficient=None, file_path=None)[source]#

Create the BRDF from the directional scattering and write to SOFA file.

The directional scattering coefficient is assumed to be anisotropic. The sum of the directional scattering coefficient has be equal to 1. Therefore the BRDF is calculated as follows:

\[\rho(\mathbf{\Omega_i}, \mathbf{\Omega_o}) = \frac{(1-\alpha)}{ (\mathbf{\Omega_o} \cdot \mathbf{n}) \cdot w_o} s_{d}( \mathbf{\Omega_i}, \mathbf{\Omega_o})\]
where:
  • \(\mathbf{\Omega_i}\) and \(\mathbf{\Omega_o}\) are the incident and outgoing directions, respectively.

  • \(s_{d}\) is the directional scattering coefficient [1].

  • \(\alpha\) is the absorption coefficient.

  • \(\mathbf{n}\) is the normal vector of the surface.

  • \(w_o\) is weighting factor of the outgoing angular sector (unit sphere).

Note that the weights doesn’t need to be normalized, they get scaled as required.

Parameters:
  • source_directions (Coordinates) – source directions for the BRDF, should contain weights. cshape of data should be (n_sources)

  • receiver_directions (Coordinates) – receiver directions for the BRDF, should contain weights. cshape of data should be (n_receivers)

  • directional_scattering (FrequencyData) – frequency dependent directional scattering coefficient data from [1]. cshape of data should be (n_sources, n_receivers).

  • absorption_coefficient (FrequencyData) – frequency dependent absorption coefficient data, by default no absorption. cshape of data should be (1, ).

  • file_path (string, path, optional) – path where sofa file should be saved, by default no file is saved.

References

sparrowpy.brdf.create_from_scattering(source_directions, receiver_directions, scattering_coefficient, absorption_coefficient=None, file_path=None)[source]#

Create the BRDF from a scattering coefficient and write to SOFA file.

The scattering coefficient is assumed to be anisotropic and based on [2]. The BRDF is discretized as follows:

\[\rho(\mathbf{\Omega_i}, \mathbf{\Omega_o}) = \frac{(1-s)(1-\alpha)}{\mathbf{\Omega_i} \cdot \mathbf{n}} \frac{1}{w_o} \delta(\mathbf{\Omega_i}-M(\mathbf{\Omega_o})) + \frac{s(1-\alpha)}{\pi}\]
where:
  • \(\mathbf{\Omega_i}\) and \(\mathbf{\Omega_o}\) are the incident and outgoing directions, respectively.

  • \(s\) is the scattering coefficient.

  • \(\alpha\) is the absorption coefficient.

  • \(\mathbf{n}\) is the normal vector of the surface.

  • \(\delta\) is the Dirac delta function.

  • \(w_o\) is weighting factor of the outgoing angular sector (unit sphere).

  • \(M\) s the mirror reflection transformation \(M(\theta, \phi)=M(\theta, \pi-\phi)\).

Note that the weights doesn’t need to be normalized, they get scaled as required.

Parameters:
  • source_directions (Coordinates) – source directions for the BRDF, should contain weights. cshape of data should be (n_sources)

  • receiver_directions (Coordinates) – receiver directions for the BRDF, should contain weights. cshape of data should be (n_receivers)

  • scattering_coefficient (FrequencyData) – frequency dependent scattering coefficient data. cshape of data should be (1, ).

  • absorption_coefficient (FrequencyData) – frequency dependent absorption coefficient data, by default no absorption. cshape of data should be (1, ).

  • file_path (string, path) – path where sofa file should be saved, by default no file is saved.

Returns:

brdf – BRDF data.

Return type:

FrequencyData

References

Examples

>>> import pyfar as pf
>>> import sparrowpy as sp
>>> import numpy as np
>>> scattering_coefficient = pf.FrequencyData(0.5, [100])
>>> directions = pf.samplings.sph_gaussian(sh_order=3)
>>> directions = directions[directions.z > 0]
>>> brdf = sp.brdf.create_from_scattering(
...     directions, directions,
...     scattering_coefficient)