Moby
AABB.h
1 /****************************************************************************
2  * Copyright 2010 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0
4  * License (obtainable from http://www.apache.org/licenses/LICENSE-2.0).
5  ****************************************************************************/
6 
7 #ifndef _MOBY_AABB_H_
8 #define _MOBY_AABB_H_
9 
10 #include <Moby/OBB.h>
11 #include <Moby/BV.h>
12 
13 namespace Moby {
14 
16 class AABB : public BV
17 {
18  public:
19  AABB() {}
20 
21  template <class InputIterator>
22  AABB(InputIterator begin, InputIterator end);
23 
24  virtual void transform(const Ravelin::Transform3d& T, BV* result) const;
25  virtual bool outside(const Point3d& point, double tol = NEAR_ZERO) const { return AABB::outside(*this, point, tol); }
26  virtual bool intersects(const LineSeg3& seg, double& tmin, double tmax, Point3d& q) const { return AABB::intersects(*this, seg, tmin, tmax, q); }
27  virtual std::ostream& to_vrml(std::ostream& out, const Ravelin::Pose3d& T) const;
28  virtual BVPtr calc_swept_BV(CollisionGeometryPtr g, const Ravelin::SVelocityd& v) const;
29  virtual double calc_volume() const;
30  virtual boost::shared_ptr<const Ravelin::Pose3d> get_relative_pose() const { return minp.pose; }
31  virtual Point3d get_lower_bounds() const;
32  virtual Point3d get_upper_bounds() const;
33  OBB get_OBB() const;
34  static bool intersects(const AABB& a, const AABB& b);
35  static bool intersects(const AABB& a, const AABB& b, const Ravelin::Transform3d& aTb);
36  static bool outside(const AABB& a, const Point3d& point, double tol = NEAR_ZERO);
37  static bool intersects(const AABB& a, const LineSeg3& seg, double& tmin, double tmax, Point3d& q);
38  static void get_closest_point(const AABB& a, const Point3d& p, Point3d& closest);
39  static double get_farthest_point(const AABB& a, const Point3d& p, Point3d& farthest);
40  AABB& operator=(const AABB& a);
41 
44 
47 }; // end class
48 
49 #include "AABB.inl"
50 
51 } // end namespace
52 
53 #endif
54 
OBB get_OBB() const
Gets the AABB as an OBB.
Definition: AABB.cpp:167
virtual Point3d get_lower_bounds() const
Gets the lower bounds for this AABB using an OBB.
Definition: AABB.cpp:236
boost::shared_ptr< BV > BVPtr
Bounding volume (BV) smart pointer.
Definition: Types.h:92
static void get_closest_point(const AABB &a, const Point3d &p, Point3d &closest)
Gets the closest point on the AABB to a point.
Definition: AABB.cpp:250
virtual boost::shared_ptr< const Ravelin::Pose3d > get_relative_pose() const
Gets the associated pose for this bounding volume.
Definition: AABB.h:30
An oriented bounding box that optionally allows building an OBB tree.
Definition: OBB.h:38
virtual Point3d get_upper_bounds() const
Gets the upper bounds for this AABB using an OBB.
Definition: AABB.cpp:243
static double get_farthest_point(const AABB &a, const Point3d &p, Point3d &farthest)
Gets the farthest point on the AABB to a point.
Definition: AABB.cpp:271
An abstract bounding volume.
Definition: BV.h:38
virtual bool outside(const Point3d &point, double tol=NEAR_ZERO) const
Determines whether a point is outside the bounding volume.
Definition: AABB.h:25
boost::shared_ptr< CollisionGeometry > CollisionGeometryPtr
Collision geometry smart pointer.
Definition: Types.h:77
virtual std::ostream & to_vrml(std::ostream &out, const Ravelin::Pose3d &T) const
Sends this AABB to VRML.
Definition: AABB.cpp:178
An axis-aligned bounding box.
Definition: AABB.h:16
AABB & operator=(const AABB &a)
Copies an AABB.
Definition: AABB.cpp:16
virtual bool intersects(const LineSeg3 &seg, double &tmin, double tmax, Point3d &q) const
Determines whether a line segment intersects the bounding volume.
Definition: AABB.h:26
Ravelin::Vector3d Point3d
Typedef to distinguish between a 3D vector and a point.
Definition: Types.h:47
Point3d minp
The lower corner of the AABB.
Definition: AABB.h:43
virtual BVPtr calc_swept_BV(CollisionGeometryPtr g, const Ravelin::SVelocityd &v) const
Constructs a velocity expanded OBB using the AABB.
Definition: AABB.cpp:221
std::pair< Point3d, Point3d > LineSeg3
Typedef to make specifying line segments easier.
Definition: Types.h:50
virtual void transform(const Ravelin::Transform3d &T, BV *result) const
Transforms the OBB using the given transform.
Definition: AABB.cpp:108
virtual double calc_volume() const
Calculates the volume of this AABB.
Definition: AABB.cpp:230
Point3d maxp
The upper corner of the AABB;.
Definition: AABB.h:46