geoclide.shapes module#

Common machinery shared by the geoclide shapes.

This module defines the Shape base class, from which the quadrics (Sphere, Spheroid, Disk) and the triangle shapes (Triangle, TriangleMesh) derive, holding the object-to-world and world-to-object transformations. It also provides the get_intersect_dataset function, which gathers the results of a ray-shape intersection test into an xarray dataset.

geoclide.shapes.get_intersect_dataset(shape_name: str, r: Ray, t: float | ndarray | None = None, is_intersection: bool | ndarray = False, u: float | ndarray | None = None, v: float | ndarray | None = None, dpdu: ndarray | None = None, dpdv: ndarray | None = None, diag_calc: bool = False) Dataset[source]#

Create dataset containing the intersection test information

  • The intersect method return (when parameter ds_output = False) of all quadrics, Triangle and TriangleMesh classes gives directly the inputs of this function

Parameters:
shape_namestr

The shape class name

rRay

The ray(s) used for the intersection test

tfloat or ndarray, optional

The t ray variable for its first intersection at the shape surface. In case of an ndarray, it is 1-D, or 2-D for a set of rays and a set of triangles

is_intersectionbool or ndarray, optional

If there is an intersection -> True, else False. In case of an ndarray, it is an ndarray of booleans, 1-D, or 2-D for a set of rays and a set of triangles

ufloat or ndarray, optional

The u coordinate of the parametric representation. In case of an ndarray, it is 1-D, or 2-D for a set of rays and a set of triangles

vfloat or ndarray, optional

The v coordinate of the parametric representation. In case of an ndarray, it is 1-D, or 2-D for a set of rays and a set of triangles

dpdundarray, optional

The surface partial derivative of phit with respect to u. It is 1-D, or 2-D for a set of rays and a set of triangles

dpdvndarray, optional

The surface partial derivative of phit with respect to v. It is 1-D, or 2-D for a set of rays and a set of triangles

diag_calcbool, optional

This indicates whether a diagonal calculation has been performed

Returns:
Dataset

Xarray dataset containing the intersection information.

Key variables included:

  • o: The origin(s) of the ray(s) [xyz]

  • d: The direction(s) of the ray(s) [xyz]

  • mint: The mint attribute of the ray(s)

  • maxt: The maxt attribute of the ray(s)

  • is_intersection: If there is an intersection -> True, else False

  • thit: The t ray variable(s) of the intersection point(s)

  • u: The u coordinate(s) of the parametric representation

  • v: The v coordinate(s) of the parametric representation

  • phit: The intersection point(s) [xyz]

  • nhit: The surface normal(s) at the intersection point(s) [xyz]

  • dpdu: The surface partial derivative(s) of phit with respect to u [xyz]

  • dpdv: The surface partial derivative(s) of phit with respect to v [xyz]

In case of a set of rays and/or a set of shapes, the variables get an extra nrays/nobj/ndiag dimension.