16 #ifndef SURGSIM_MATH_AABB_H
17 #define SURGSIM_MATH_AABB_H
19 #include <Eigen/Geometry>
27 typedef Eigen::AlignedBox<float, 3>
Aabbf;
30 typedef Eigen::AlignedBox<double, 3>
Aabbd;
40 template <
class Scalar,
int Dim>
42 const Eigen::AlignedBox<Scalar, Dim>& aabb1,
45 typedef typename Eigen::AlignedBox<Scalar, Dim>::VectorType VectorType;
47 VectorType vector = (aabb1.center() - aabb0.center()).array().abs();
48 VectorType totalSizes = ((aabb0.sizes() + aabb1.sizes()) * 0.5).array() + tolerance;
50 return (vector.array() <= totalSizes.array()).all();
59 template <
class Scalar,
int Dim>
61 const Eigen::AlignedBox<Scalar, Dim>& b)
63 return !a.intersection(b).isEmpty();
70 template <
class Scalar,
int Dim,
int MType>
72 const Eigen::Matrix<Scalar, Dim, 1, MType>& vector0,
73 const Eigen::Matrix<Scalar, Dim, 1, MType>& vector1,
74 const Eigen::Matrix<Scalar, Dim, 1, MType>& vector2)
76 Eigen::AlignedBox<Scalar, Dim> result(vector0);
77 result.extend(vector1);
78 result.extend(vector2);
79 return std::move(result);
Definition: DriveElementFromInputBehavior.cpp:27
Eigen::AlignedBox< float, 3 > Aabbf
Wrapper around the Eigen type.
Definition: Aabb.h:27
Eigen::AlignedBox< double, 3 > Aabbd
Wrapper around the Eigen type.
Definition: Aabb.h:30
bool doAabbIntersect(const Eigen::AlignedBox< Scalar, Dim > &aabb0, const Eigen::AlignedBox< Scalar, Dim > &aabb1, double tolerance)
Determine whether two AABBs have an intersection with each other, for the calculation see http://www...
Definition: Aabb.h:41
Eigen::AlignedBox< Scalar, Dim > makeAabb(const Eigen::Matrix< Scalar, Dim, 1, MType > &vector0, const Eigen::Matrix< Scalar, Dim, 1, MType > &vector1, const Eigen::Matrix< Scalar, Dim, 1, MType > &vector2)
Convenience function for creating a bounding box from three vertices (e.g.
Definition: Aabb.h:71