1.4. Spatial Acceleration¶

class
raysect.core.boundingbox.
BoundingBox2D
¶ Axisaligned 2D bounding box.
Parameters: 
contains
()¶ Returns true if the given 2D point lies inside the bounding box.
Parameters: point (Point2D) – A given test point. Return type: boolean

extend
()¶ 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.
Parameters:  point (Point2D) – the point to use for extending the bounding box.
 padding (float) – optional padding parameter, gives extra margin around the new point.

extent
()¶ Returns the spatial extend of this bounding box along the given dimension.
Parameters: axis (int) – specifies the axis to return, {0: X axis, 1: Y axis}. Return type: float

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: int

largest_extent
()¶ Find the largest spatial extent across all axes.
Returns: distance along the largest bounding box axis. Return type: float

pad
()¶ 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

surface_area
()¶ Returns the surface area of the bounding box.
Return type: float

union
()¶ 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.

vertices
()¶ Get the list of vertices for this bounding box.
Returns: A list of Point2D’s representing the corners of the bounding box. Return type: list


class
raysect.core.boundingbox.
BoundingBox3D
¶ Axisaligned 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, coordinate transforms can be avoided.
Parameters: 
contains
()¶ 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: BoundingSphere3D

extend
()¶ 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.
Parameters:  point (Point3D) – the point to use for extending the bounding box.
 padding (float) – optional padding parameter, gives extra margin around the new point.

extent
()¶ Returns the spatial extend of this bounding box along the given dimension.
Parameters: axis (int) – specifies the axis to return, {0: X axis, 1: Y axis, 2: Z axis}. Return type: float

full_intersection
()¶ 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: tuple

hit
()¶ 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: int

largest_extent
()¶ Find the largest spatial extent across all axes.
Returns: distance along the largest bounding box axis. Return type: float

pad
()¶ 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

surface_area
()¶ Returns the surface area of the bounding box.
Return type: float

union
()¶ 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: list

volume
()¶ Returns the volume of the bounding box.
Return type: float
