Struct beebox::Aabb [] [src]

pub struct Aabb { /* fields omitted */ }

An axis-aligned bounding box in 3D space.

The box can, for the most part, be thought of as being defined by two corners, a minimum corner and a maximum corner. All coordinates are 32-bit floats.

This representation does not allow empty boxes, which are occasionally useful. However, one can abuse the corner vectors and set the "minimum corner" to positive infinity and the "maximum corner" to negative infinity. Most AABB operations will handle this without extra work if they're written carefully, but it's an unnatural special case to keep in mind when working with the corners.

Aabb can be empty, which is implemented using the aforementioned trick, but as far as the interface is concerned, it upholds the "min corner, max corner" view: empty Aabbs cannot be constructed by specifying nonsensical corners (there is a separate constructor, empty()), and there is no minimum or maximum corner for an empty bounding box (the accessors panic).

Methods

impl Aabb
[src]

Constructs a bounding box from a set of points.

Empty sets of points are valid and result in an empty bounding box.

Returns the "minimum corner", i.e., the coordinate-wise minimum of the region of space described by the AABB.

Panics

Empty AABBs have no meaningful minimum, so calling this functions on an empty AABB panics.

Returns the "maximum corner", i.e., the coordinate-wise maximum of the region of space described by the AABB.

Panics

Empty AABBs have no meaningful maximum, so calling this functions on an empty AABB panics.

Constructs a bounding box by supplying the minimum and maximum coordinates directly.

Empty AABBs cannot be created through this function, consider using Aabb::empty().

Panics

Panics when the corners aren't really minimum and maximum, i.e. min[i] > max[i] in any dimension i.

Constructs an empty AABB which does not contain any points and can be union'd with other AABBs without affecting them.

Returns true if the box is empty, i.e., encompasses no space and not even a single point.

Expand the bounding box to also encompass the point p.

Updates the AABB to also encompass other. This is an in-place version of union.

Returns the smallest AABB that encompasses both self and other.

Returns the surface area of the box. This is useful for construction of bounding volume hierarchies.

Panics

Panics if the box is empty. While it might be possible to meaningfully assign surface area 0 to a non-existing surface, it's not 100% clear whether this is mathematically kosher and in the context of BVH construction, needing the surface area of an empty box probably indicates a bug.

Returns true if the [t0, t1] segment of the ray intersects this AABB. In other words, returns true if the ray intersects the AABB and the intersection point is r(t) := o + t * d for t in the interval [t0, t1]. (As usual, o denotes the ray origin and d the ray direction.)

The code is derived from Physically based rendering (cited in the crate documentation) and implements the algorithm from:

Williams, Amy, et al. "An efficient and robust ray-box intersection algorithm." ACM SIGGRAPH 2005 Courses.

Returns the center point of the box.

Panics

Panics if the box is empty.

Returns the axis along which the AABB is largest.

In case multiple axes are largest (e.g., because the AABB is empty or a cube), the result is one of the largest axes, but it is unspecified which one is returned.

Trait Implementations

impl Copy for Aabb
[src]

impl Clone for Aabb
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Aabb
[src]

Formats the value using the given formatter.

impl PartialEq for Aabb
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.