1.4. Spatial Acceleration
- class raysect.core.boundingbox.BoundingBox2D
Axis-aligned 2D bounding box.
- Parameters:
- contains(point)
Returns true if the given 2D point lies inside the bounding box.
- Parameters:
point (Point2D) – A given test point.
- Return type:
boolean
- extend(point, padding=0.0)
Enlarge this bounding box to enclose the given point.
The resulting bounding box will be larger so as to just enclose the existing bounding box and the new point. This class instance will be edited in place to have the new bounding box dimensions.
- extent(axis)
Returns the spatial extend of this bounding box along the given dimension.
- largest_axis()
Find the largest axis of this bounding box.
- Returns:
an int specifying the longest axis, {0: X axis, 1: Y axis}.
- Return type:
- largest_extent()
Find the largest spatial extent across all axes.
- Returns:
distance along the largest bounding box axis.
- Return type:
- pad(padding)
Makes the bounding box larger by the specified amount of padding.
Every bounding box axis will end up larger by a factor of 2 x padding.
- Parameters:
padding (float) – distance to use as padding margin
- pad_axis(axis, padding)
Makes the bounding box larger along the specified axis by amount of padding.
The specified bounding box axis will end up larger by a factor of 2 x padding.
- union(box)
Union this bounding box instance with the input bounding box.
The resulting bounding box will be larger so as to just enclose both bounding boxes. This class instance will be edited in place to have the new bounding box dimensions.
- Parameters:
box (BoundingBox2D) – A bounding box instance to union with this bounding box instance.
- class raysect.core.boundingbox.BoundingBox3D
Axis-aligned bounding box.
Represents a bounding box around a primitive’s surface. The points defining the lower and upper corners of the box must be specified in world space.
Axis aligned bounding box ray intersections are extremely fast to evaluate compared to intersections with more general geometry. Prior to testing a primitives hit() method the hit() method of the bounding box is called. If the bounding box is not hit, then the expensive primitive hit() method is avoided.
Combined with a spatial subdivision acceleration structure, the cost of ray- primitive evaluations can be heavily reduced (O(n) -> O(log n)).
For optimal speed the bounding box is aligned with the world space axes. As rays are propagated in world space, co-ordinate transforms can be avoided.
- Parameters:
- contains(point)
Returns true if the given 3D point lies inside the bounding box.
- Parameters:
point (Point3D) – A given test point.
- Return type:
boolean
- enclosing_sphere()
Returns a BoundingSphere3D guaranteed to enclose the bounding box.
The sphere is centred at the box centre. A small degree of padding is added to avoid numerical accuracy issues.
- Returns:
A BoundingSphere3D object.
- Return type:
- extend(point, padding=0.0)
Enlarge this bounding box to enclose the given point.
The resulting bounding box will be larger so as to just enclose the existing bounding box and the new point. This class instance will be edited in place to have the new bounding box dimensions.
- extent(axis)
Returns the spatial extend of this bounding box along the given dimension.
- full_intersection(ray)
Returns full intersection information for an intersection between a ray and a bounding box.
The first value is a boolean which is true if an intersection has occured, false otherwise. Each intersection with a bounding box will produce two intersections, one on the front and back of the box. The remaining two tuple parameters are floats representing the distance along the ray path to the respective intersections.
- Parameters:
ray – The ray to test for intersection
- Returns:
A tuple of intersection parameters, (hit, front_intersection, back_intersection).
- Return type:
- hit(ray)
Returns true if the ray hits the bounding box.
- Parameters:
ray (Ray) – The ray to test for intersection.
- Return type:
boolean
- largest_axis()
Find the largest axis of this bounding box.
- Returns:
an int specifying the longest axis, {0: X axis, 1: Y axis, 2: Z axis}.
- Return type:
- largest_extent()
Find the largest spatial extent across all axes.
- Returns:
distance along the largest bounding box axis.
- Return type:
- pad(padding)
Makes the bounding box larger by the specified amount of padding.
Every bounding box axis will end up larger by a factor of 2 x padding.
- Parameters:
padding (float) – distance to use as padding margin
- pad_axis(axis, padding)
Makes the bounding box larger along the specified axis by amount of padding.
The specified bounding box axis will end up larger by a factor of 2 x padding.
- union(box)
Union this bounding box instance with the input bounding box.
The resulting bounding box will be larger so as to just enclose both bounding boxes. This class instance will be edited in place to have the new bounding box dimensions.
- Parameters:
box (BoundingBox3D) – A bounding box instance to union with this bounding box instance.
- vertices()
Get the list of vertices for this bounding box.
- Returns:
A list of Point3D’s representing the corners of the bounding box.
- Return type:
- class raysect.core.boundingsphere.BoundingSphere3D
A bounding sphere.
Represents a bounding sphere around a primitive’s surface. The sphere’s centre point and radius must be specified in world space.
- Parameters:
- contains(point)
Returns true if the given 3D point lies inside the bounding sphere.
- Parameters:
point (Point3D) – A given test point.
- Return type:
boolean
- extend(point, padding=0.0)
Enlarge this bounding box to enclose the given point.
The resulting bounding box will be larger so as to just enclose the existing bounding box and the new point. This class instance will be edited in place to have the new bounding box dimensions.
- full_intersection(ray)
Returns full intersection information for an intersection between a ray and a bounding box.
The first value is a boolean which is true if an intersection has occured, false otherwise. Each intersection with a bounding box will produce two intersections, one on the front and back of the box. The remaining two tuple parameters are floats representing the distance along the ray path to the respective intersections.
- Parameters:
ray – The ray to test for intersection
- Returns:
A tuple of intersection parameters, (hit, front_intersection, back_intersection).
- Return type:
- hit(ray)
Returns true if the ray hits the bounding box.
- Parameters:
ray (Ray) – The ray to test for intersection.
- Return type:
boolean
- pad(padding)
Makes the bounding sphere larger by the specified amount of padding.
- Parameters:
padding (float) – Distance to use as padding margin.
- union(sphere)
Union this bounding sphere instance with the input bounding sphere.
The resulting bounding sphere will be larger so as to just enclose both bounding spheres. This class instance will be edited in place to have the new bounding sphere dimensions.
- Parameters:
sphere (BoundingSphere3D) – A bounding sphere instance to union with this bounding sphere instance.