Thea
Public Types | Public Member Functions | List of all members
BoxN< N, T > Class Template Reference

An arbitrarily oriented box, implemented as an axis-aligned box in a coordinate frame. More...

#include <BoxN.hpp>

Inheritance diagram for BoxN< N, T >:
RayIntersectableN< N, T >

Public Types

typedef AxisAlignedBoxN< N, T > AxisAlignedBoxT
 N-dimensional axis-aligned box. More...
 
typedef CoordinateFrameN< N, T > CoordinateFrameT
 N-dimensional coordinate frame. More...
 
typedef Vector< N, T > VectorT
 N-dimensional vector. More...
 

Public Member Functions

 BoxN ()
 Default constructor. More...
 
 BoxN (AxisAlignedBoxT const &aab_, CoordinateFrameT const &frame_=CoordinateFrameT::identity())
 Initialize to an axis-aligned box in a coordinate frame. More...
 
template<typename U >
BoxN< N, U > cast () const
 Cast the box to a different scalar type. More...
 
bool contains (VectorT const &p) const
 Check if the box contains a point. More...
 
bool contains (AxisAlignedBoxT const &aab_) const
 Check if the box contains an axis-aligned box. More...
 
bool contains (BoxN const &other) const
 Check if the box contains another. More...
 
AxisAlignedBoxT getBounds () const
 Get an axis-aligned bounding box for the box. More...
 
VectorT getCenter () const
 Get the center of the box. More...
 
VectorT getExtent () const
 Get the extent of the box in the local frame. More...
 
AxisAlignedBoxT const & getLocalAAB () const
 Get the axis-aligned box in the local frame for the box. More...
 
AxisAlignedBoxTgetLocalAAB ()
 Get the axis-aligned box in the local frame for the box. More...
 
CoordinateFrameT const & getLocalFrame () const
 Get the local frame for the box. More...
 
CoordinateFrameTgetLocalFrame ()
 Get the local frame for the box. More...
 
VectorT getVertex (uintx i) const
 Get the i'th corner of the box, for i in the range [0, 2^N - 1]. More...
 
bool intersects (VectorT const &p) const
 Check if the box intersects (i.e. More...
 
bool intersects (AxisAlignedBoxT const &aab) const
 Check if the box intersects an axis-aligned box. More...
 
bool intersects (BoxN const &other) const
 Check if the box intersects another. More...
 
RayIntersectionN< N, T > rayIntersection (RayN< N, T > const &ray, T max_time=-1) const
 Get the intersection of a ray with the object, including the hit time and the normal at the intersection point. More...
 
rayIntersectionTime (RayN< N, T > const &ray, T max_time=-1) const
 Get the time taken for a ray to intersect the object, or a negative value if there was no intersection in the forward direction. More...
 
bool rayIntersects (RayN< N, T > const &ray, T max_time=-1) const
 Check if a ray intersects the object in the forward direction. More...
 
void setLocalAAB (AxisAlignedBoxT const &aab_)
 Set the axis-aligned box in the local frame for the box. More...
 
void setLocalFrame (CoordinateFrameT const &frame_)
 Set the local frame for the box. More...
 

Detailed Description

template<int N, typename T = Real>
class Thea::BoxN< N, T >

An arbitrarily oriented box, implemented as an axis-aligned box in a coordinate frame.

Definition at line 27 of file BoxN.hpp.

Member Typedef Documentation

N-dimensional axis-aligned box.

Definition at line 31 of file BoxN.hpp.

N-dimensional coordinate frame.

Definition at line 32 of file BoxN.hpp.

typedef Vector<N, T> VectorT

N-dimensional vector.

Definition at line 30 of file BoxN.hpp.

Constructor & Destructor Documentation

BoxN ( )

Default constructor.

Creates a null box.

Definition at line 37 of file BoxN.hpp.

BoxN ( AxisAlignedBoxT const &  aab_,
CoordinateFrameT const &  frame_ = CoordinateFrameT::identity() 
)

Initialize to an axis-aligned box in a coordinate frame.

Definition at line 40 of file BoxN.hpp.

Member Function Documentation

BoxN<N, U> cast ( ) const

Cast the box to a different scalar type.

Definition at line 44 of file BoxN.hpp.

bool contains ( VectorT const &  p) const

Check if the box contains a point.

Definition at line 95 of file BoxN.hpp.

bool contains ( AxisAlignedBoxT const &  aab_) const

Check if the box contains an axis-aligned box.

Definition at line 101 of file BoxN.hpp.

bool contains ( BoxN< N, T > const &  other) const

Check if the box contains another.

Definition at line 112 of file BoxN.hpp.

AxisAlignedBoxT getBounds ( ) const

Get an axis-aligned bounding box for the box.

Definition at line 125 of file BoxN.hpp.

VectorT getCenter ( ) const

Get the center of the box.

Definition at line 65 of file BoxN.hpp.

VectorT getExtent ( ) const

Get the extent of the box in the local frame.

Definition at line 68 of file BoxN.hpp.

AxisAlignedBoxT const& getLocalAAB ( ) const

Get the axis-aligned box in the local frame for the box.

Definition at line 47 of file BoxN.hpp.

AxisAlignedBoxT& getLocalAAB ( )

Get the axis-aligned box in the local frame for the box.

Definition at line 50 of file BoxN.hpp.

CoordinateFrameT const& getLocalFrame ( ) const

Get the local frame for the box.

Definition at line 56 of file BoxN.hpp.

CoordinateFrameT& getLocalFrame ( )

Get the local frame for the box.

Definition at line 59 of file BoxN.hpp.

VectorT getVertex ( uintx  i) const

Get the i'th corner of the box, for i in the range [0, 2^N - 1].

This function works as expected only if N <= sizeof(uintx).

Definition at line 74 of file BoxN.hpp.

bool intersects ( VectorT const &  p) const

Check if the box intersects (i.e.

contains) a point.

Definition at line 80 of file BoxN.hpp.

bool intersects ( AxisAlignedBoxT const &  aab) const

Check if the box intersects an axis-aligned box.

Definition at line 83 of file BoxN.hpp.

bool intersects ( BoxN< N, T > const &  other) const

Check if the box intersects another.

Definition at line 89 of file BoxN.hpp.

RayIntersectionN<N, T> rayIntersection ( RayN< N, T > const &  ray,
max_time = -1 
) const
virtual

Get the intersection of a ray with the object, including the hit time and the normal at the intersection point.

A negative time is returned if there was no intersection in the forward direction. If the normal cannot be computed, the zero vector is returned.

Parameters
rayThe ray to test for intersection.
max_timeMaximum allowable hit time, ignored if negative.
Note
The returned normal need not have unit length.

Reimplemented from RayIntersectableN< N, T >.

Definition at line 140 of file BoxN.hpp.

T rayIntersectionTime ( RayN< N, T > const &  ray,
max_time = -1 
) const
virtual

Get the time taken for a ray to intersect the object, or a negative value if there was no intersection in the forward direction.

All subclasses must reimplement this method. If the return value is negative, it should be at least

Parameters
rayThe ray to test for intersection.
max_timeMaximum allowable hit time, ignored if negative.

Implements RayIntersectableN< N, T >.

Definition at line 135 of file BoxN.hpp.

bool rayIntersects ( RayN< N, T > const &  ray,
max_time = -1 
) const
virtual

Check if a ray intersects the object in the forward direction.

Parameters
rayThe ray to test for intersection.
max_timeMaximum allowable hit time, ignored if negative.

Reimplemented from RayIntersectableN< N, T >.

Definition at line 130 of file BoxN.hpp.

void setLocalAAB ( AxisAlignedBoxT const &  aab_)

Set the axis-aligned box in the local frame for the box.

Definition at line 53 of file BoxN.hpp.

void setLocalFrame ( CoordinateFrameT const &  frame_)

Set the local frame for the box.

Definition at line 62 of file BoxN.hpp.


The documentation for this class was generated from the following file: