geoclide.intersection module#
- geoclide.intersection.calc_intersection(shape, r, **kwargs)#
Performs intersection test between a shape and a ray and returns dataset
- Parameters:
- shapeBBox | Sphere | Spheroid | Disk | Triangle | TriangleMesh
The shape used for the intersection(s)
- rRay
The ray(s) used for the intersection(s)
- **kwargs
The keyword arguments are passed on to intersect method. The ds_output parameter is forced here to always be True.
- Returns:
- outxr.Dataset
Look-up table with the intersection information
Examples
>>> import geoclide as gc >>> sphere = gc.Sphere(radius=1.) # sphere of radius 1 >>> bbox = gc.BBox(p1=gc.Point(0., 0., 0.), p2=gc.Point(1.,1.,1.)) >>> ray = gc.Ray(o=gc.Point(-2., 0., 0.8), d=gc.Vector(1.,0.,0.)) >>> ds_sphere = gc.calc_intersection(sphere, ray) >>> ds_sphere <xarray.Dataset> Size: 753B Dimensions: (xyz: 3, dim_0: 4, dim_1: 4) Coordinates: * xyz (xyz) int64 24B 0 1 2 Dimensions without coordinates: dim_0, dim_1 Data variables: (12/20) o (xyz) float64 24B -2.0 0.0 0.8 d (xyz) float64 24B 1.0 0.0 0.0 mint int64 8B 0 maxt float64 8B inf is_intersection bool 1B True thit float64 8B 1.4 ... ... z_max float64 8B 1.0 phi_max float64 8B 360.0 wTo_m (dim_0, dim_1) float64 128B 1.0 0.0 0.0 0.0 ... 0.0 0.0 1.0 wTo_mInv (dim_0, dim_1) float64 128B 1.0 0.0 0.0 0.0 ... 0.0 0.0 1.0 oTw_m (dim_0, dim_1) float64 128B 1.0 0.0 0.0 0.0 ... 0.0 0.0 1.0 oTw_mInv (dim_0, dim_1) float64 128B 1.0 0.0 0.0 0.0 ... 0.0 0.0 1.0 >>> ds_box = gc.calc_intersection(bbox, ray) >>> ds_bbox <xarray.Dataset> Size: 169B Dimensions: (xyz: 3) Coordinates: * xyz (xyz) int64 24B 0 1 2 Data variables: is_intersection bool 1B True o (xyz) float64 24B -2.0 0.0 0.8 d (xyz) float64 24B 1.0 0.0 0.0 mint int64 8B 0 maxt float64 8B inf pmin (xyz) float64 24B 0.0 0.0 0.0 pmax (xyz) float64 24B 1.0 1.0 1.0 thit float64 8B 2.0 phit (xyz) float64 24B 0.0 0.0 0.8