pysdic.compute_bouguer_law#
- compute_bouguer_law(surface_points, surface_normals, light_positions)[source]#
Compute the Bouguer law ratio between irradiance \(E\) at source intensity \(I\) for a set of \(N_p\) surface points and a set of \(N_l\) light source positions.
\[\frac{E}{I} = \frac{\cos \theta}{r^2}\]where \(\theta\) is the angle between the surface normal and the light direction computed as the positive dot product between the surface normal and the direction vector. Note that \((A \cdot B)\) denotes the positive dot product between vectors \(A\) and \(B\) given by \(\max(0, A^T B)\).
Note
The inputs arrays will be converted to
numpy.float64for computation. The output array will be also of typenumpy.float64.- Parameters:
surface_points (ArrayLike) – An array of shape \((N_p, 3)\) or \((3,)\) representing the coordinates of \(N_p\) surface points in 3-dimensional space. If a 1D array is provided, it is treated as a single surface point \((1, 3)\).
surface_normals (ArrayLike) – An array of shape \((N_p, 3)\) or \((3,)\) representing the normal vectors at each surface point. Must have the same shape as
surface_points.light_positions (ArrayLike) – An array of shape \((N_l, 3)\) or \((3,)\) representing the position(s) of the light source(s). If a 1D array is provided, it is treated as a single light source \((1, 3)\).
- Returns:
An array of \((N_p, N_l)\) representing the Bouguer law ratio \(\frac{E}{I}\) at each surface point for each light source.
- Return type:
- Raises:
TypeError – If the inputs cannot be converted to floating-point numpy arrays.
ValueError – If the dimensions of the input arrays are inconsistent.
Examples
Lets compute the Bouguer law ratio for a set of surface points and normals with a single light source:
1import numpy 2from pysdic import compute_bouguer_law 3 4surface_points = numpy.array( 5 [[0.0, 0.0, 0.0], 6 [1.0, 0.0, 0.0], 7 [0.0, 1.0, 0.0]] 8) 9surface_normals = numpy.array( 10 [[0.0, 0.0, 1.0], 11 [0.0, 0.0, 1.0], 12 [0.0, 0.0, 1.0]] 13) 14light_positions = numpy.array([0.0, 0.0, 10.0]) 15 16bouguer_ratios = compute_bouguer_law( 17 surface_points, 18 surface_normals, 19 light_positions 20) 21 22print(f"Bouguer ratios (Shape: {bouguer_ratios.shape}):") 23print(bouguer_ratios)
Bouguer ratios (Shape: (3, 1)): [[0.01 ] [0.00985185] [0.00985185]]