pynif3d.utils

pynif3d.utils.check_in_options(variable, options, variable_name)
pynif3d.utils.normalize(x)

Normalizes an input vector.

Parameters

x (np.array) – Array containing the vector’s coordinates.

Returns

Array containing the normalized coordinates.

Return type

np.array

pynif3d.utils.radians(theta_deg)

Converts an angle from degrees to radians.

Parameters

theta_deg (float) – Angle value in degrees.

Returns

Angle value in radians.

Return type

float

pynif3d.utils.ray_sphere_intersection(rays_d, spheres_o, radius=1.0)

Computes the intersection points between a given set of spheres placed at origins spheres_o and a given set of ray directions rays_d.

Parameters
  • rays_d (torch.Tensor) – Tensor containing the ray directions. Its shape is (batch_size, n_rays, 3).

  • spheres_o (torch.Tensor) – Tensor containing the sphere origins. Its shape is (batch_size, n_rays, 3).

  • radius (float) – The radius of the spheres.

Returns

Tuple containing the two intersection velocities per ray (as a

(batch_size, n_rays, 2) tensor) and a mask (as a (batch_size, n_rays) tensor). The rays which intersect the sphere are marked as True, while the ones that do not are marked as False.

Return type

tuple

pynif3d.utils.rotation_mat(angle, axis)

Creates a rotation matrix given an angle and a coordinate axis.

Parameters
  • angle (float) – Rotation angle (in radians).

  • axis (str) – Rotation axis (“x”, “y” or “z”).

Returns

Rotation matrix of shape (4, 4).

Return type

np.array

pynif3d.utils.translation_mat(t, axis='z')

Generates a translation matrix given an input translation vector.

Parameters
  • t (float) – Array containing the translation vector’s coordinates.

  • axis (str) – Rotation axis (“x”, “y” or “z”). Default is “z”.

Returns

Translation matrix of shape (4, 4).

Return type

np.array