46#ifndef EIGEN_ALIGNEDBOX_H
47#define EIGEN_ALIGNEDBOX_H
65template <
typename _Scalar,
int _AmbientDim>
69EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,
_AmbientDim)
71 typedef _Scalar Scalar;
75 typedef typename ScalarTraits::NonInteger NonInteger;
88 TopLeft=2, TopRight=3,
93 TopLeftFloor=2, TopRightFloor=3,
94 BottomLeftCeil=4, BottomRightCeil=5,
95 TopLeftCeil=6, TopRightCeil=7
102 {
if (EIGEN_CONST_CONDITIONAL(AmbientDimAtCompileTime!=
Dynamic))
setEmpty(); }
110 template<
typename OtherVectorType1,
typename OtherVectorType2>
114 template<
typename Derived>
121 EIGEN_DEVICE_FUNC
inline Index dim()
const {
return AmbientDimAtCompileTime==
Dynamic ? m_min.size() :
Index(AmbientDimAtCompileTime); }
131 EIGEN_DEVICE_FUNC
inline bool isEmpty()
const {
return (m_min.array() > m_max.array()).any(); }
160 {
return m_max - m_min; }
163 EIGEN_DEVICE_FUNC
inline Scalar
volume()
const
184 EIGEN_STATIC_ASSERT(
_AmbientDim <= 3, THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE);
192 else res[d] = m_min[d];
205 if(!ScalarTraits::IsInteger)
207 r[d] = m_min[d] + (m_max[d]-m_min[d])
208 * internal::random<Scalar>(Scalar(0), Scalar(1));
211 r[d] = internal::random(m_min[d], m_max[d]);
217 template<
typename Derived>
221 return (m_min.array()<=
p_n.
array()).all() && (
p_n.
array()<=m_max.array()).all();
226 {
return (m_min.array()<=(b.
min)().array()).all() && ((b.
max)().array()<=m_max.array()).all(); }
231 {
return (m_min.array()<=(b.
max)().array()).all() && ((b.
min)().array()<=m_max.array()).all(); }
235 template<
typename Derived>
239 m_min = m_min.cwiseMin(
p_n);
240 m_max = m_max.cwiseMax(
p_n);
248 m_min = m_min.cwiseMin(b.m_min);
249 m_max = m_max.cwiseMax(b.m_max);
258 m_min = m_min.cwiseMax(b.m_min);
259 m_max = m_max.cwiseMin(b.m_max);
267 {
return AlignedBox(m_min.cwiseMax(b.m_min), m_max.cwiseMin(b.m_max)); }
273 {
return AlignedBox(m_min.cwiseMin(b.m_min), m_max.cwiseMax(b.m_max)); }
276 template<
typename Derived>
286 template<
typename Derived>
298 template<
typename Derived>
311 template<
typename Derived>
325 template<
int Mode,
int Options>
338 template<
int Mode,
int Options>
342 EIGEN_STATIC_ASSERT(Mode ==
Affine || Mode ==
AffineCompact || Mode ==
Isometry, THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS);
353 Scalar(2) * transform.translation();
363 template<
int Mode,
int Options>
376 template<
typename NewScalarType>
385 template<
typename OtherScalarType>
397 {
return m_min.isApprox(other.m_min,
prec) && m_max.isApprox(other.m_max,
prec); }
401 VectorType m_min, m_max;
406template<
typename Scalar,
int AmbientDim>
407template<
typename Derived>
413 for (
Index k=0; k<dim(); ++k)
415 if( m_min[k] > p[k] )
417 aux = m_min[k] - p[k];
420 else if( p[k] > m_max[k] )
422 aux = p[k] - m_max[k];
429template<
typename Scalar,
int AmbientDim>
434 for (
Index k=0; k<dim(); ++k)
436 if( m_min[k] > b.m_max[k] )
438 aux = m_min[k] - b.m_max[k];
441 else if( b.m_min[k] > m_max[k] )
443 aux = b.m_min[k] - m_max[k];
466#define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
468typedef AlignedBox<Type, Size> AlignedBox##SizeSuffix##TypeSuffix;
470#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
471EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 1, 1) \
472EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
473EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
474EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
475EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X)
477EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
int, i)
478EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
float, f)
479EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
double, d)
481#undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
482#undef EIGEN_MAKE_TYPEDEFS
\geometry_module
Definition AlignedBox.h:67
EIGEN_DEVICE_FUNC AlignedBox translated(const MatrixBase< Derived > &a_t) const
Definition AlignedBox.h:287
EIGEN_DEVICE_FUNC bool isEmpty() const
Definition AlignedBox.h:131
EIGEN_DEVICE_FUNC AlignedBox & extend(const AlignedBox &b)
Extends *this such that it contains the box b and returns a reference to *this.
Definition AlignedBox.h:246
EIGEN_DEVICE_FUNC bool contains(const MatrixBase< Derived > &p) const
Definition AlignedBox.h:218
EIGEN_DEVICE_FUNC void setNull()
Definition AlignedBox.h:127
EIGEN_DEVICE_FUNC AlignedBox(Index _dim)
Constructs a null box with _dim the dimension of the ambient space.
Definition AlignedBox.h:105
EIGEN_DEVICE_FUNC void transform(const Transform< Scalar, AmbientDimAtCompileTime, Mode, Options > &transform)
Transforms this box by transform and recomputes it to still be an axis-aligned box.
Definition AlignedBox.h:339
EIGEN_DEVICE_FUNC AlignedBox(const MatrixBase< Derived > &p)
Constructs a box containing a single point p.
Definition AlignedBox.h:115
EIGEN_DEVICE_FUNC VectorType corner(CornerType corner) const
Definition AlignedBox.h:182
EIGEN_DEVICE_FUNC AlignedBox & clamp(const AlignedBox &b)
Clamps *this by the box b and returns a reference to *this.
Definition AlignedBox.h:256
EIGEN_DEVICE_FUNC VectorType sample() const
Definition AlignedBox.h:200
EIGEN_DEVICE_FUNC bool isNull() const
Definition AlignedBox.h:124
EIGEN_DEVICE_FUNC VectorType &() max()
Definition AlignedBox.h:148
EIGEN_DEVICE_FUNC const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(VectorTypeSum, RealScalar, quotient) center() const
Definition AlignedBox.h:151
EIGEN_DEVICE_FUNC AlignedBox & translate(const MatrixBase< Derived > &a_t)
Translate *this by the vector t and returns a reference to *this.
Definition AlignedBox.h:277
EIGEN_DEVICE_FUNC const CwiseBinaryOp< internal::scalar_difference_op< Scalar, Scalar >, const VectorType, const VectorType > sizes() const
Definition AlignedBox.h:159
EIGEN_DEVICE_FUNC const VectorType &() min() const
Definition AlignedBox.h:142
EIGEN_DEVICE_FUNC AlignedBox transformed(const Transform< Scalar, AmbientDimAtCompileTime, Mode, Options > &transform) const
Definition AlignedBox.h:364
EIGEN_DEVICE_FUNC bool intersects(const AlignedBox &b) const
Definition AlignedBox.h:230
Eigen::Index Index
Definition AlignedBox.h:73
EIGEN_DEVICE_FUNC CwiseBinaryOp< internal::scalar_difference_op< Scalar, Scalar >, const VectorType, const VectorType > diagonal() const
Definition AlignedBox.h:170
EIGEN_DEVICE_FUNC AlignedBox merged(const AlignedBox &b) const
Returns an AlignedBox that is the union of b and *this.
Definition AlignedBox.h:272
EIGEN_DEVICE_FUNC internal::cast_return_type< AlignedBox, AlignedBox< NewScalarType, AmbientDimAtCompileTime > >::type cast() const
Definition AlignedBox.h:378
EIGEN_DEVICE_FUNC void transform(const typename Transform< Scalar, AmbientDimAtCompileTime, Mode, Options >::TranslationType &translation)
Specialization of transform for pure translation.
Definition AlignedBox.h:326
EIGEN_DEVICE_FUNC bool isApprox(const AlignedBox &other, const RealScalar &prec=ScalarTraits::dummy_precision()) const
Definition AlignedBox.h:396
EIGEN_DEVICE_FUNC Scalar squaredExteriorDistance(const MatrixBase< Derived > &p) const
Definition AlignedBox.h:408
EIGEN_DEVICE_FUNC bool contains(const AlignedBox &b) const
Definition AlignedBox.h:225
EIGEN_DEVICE_FUNC Index dim() const
Definition AlignedBox.h:121
EIGEN_DEVICE_FUNC AlignedBox intersection(const AlignedBox &b) const
Returns an AlignedBox that is the intersection of b and *this.
Definition AlignedBox.h:266
EIGEN_DEVICE_FUNC const VectorType &() max() const
Definition AlignedBox.h:146
EIGEN_DEVICE_FUNC AlignedBox & extend(const MatrixBase< Derived > &p)
Extends *this such that it contains the point p and returns a reference to *this.
Definition AlignedBox.h:236
EIGEN_DEVICE_FUNC NonInteger exteriorDistance(const AlignedBox &b) const
Definition AlignedBox.h:319
CornerType
Define constants to name the corners of a 1D, 2D or 3D axis aligned bounding box.
Definition AlignedBox.h:81
@ BottomLeft
Identifier for 2D corner.
Definition AlignedBox.h:87
@ Min
1D names
Definition AlignedBox.h:83
@ BottomLeftFloor
Identifier for 3D corner.
Definition AlignedBox.h:92
EIGEN_DEVICE_FUNC void setEmpty()
Makes *this an empty box.
Definition AlignedBox.h:135
EIGEN_DEVICE_FUNC AlignedBox()
Default constructor initializing a null box.
Definition AlignedBox.h:101
EIGEN_DEVICE_FUNC VectorType &() min()
Definition AlignedBox.h:144
EIGEN_DEVICE_FUNC Scalar volume() const
Definition AlignedBox.h:163
EIGEN_DEVICE_FUNC AlignedBox(const AlignedBox< OtherScalarType, AmbientDimAtCompileTime > &other)
Copy constructor with scalar type conversion.
Definition AlignedBox.h:386
EIGEN_DEVICE_FUNC AlignedBox(const OtherVectorType1 &_min, const OtherVectorType2 &_max)
Constructs a box with extremities _min and _max.
Definition AlignedBox.h:111
EIGEN_DEVICE_FUNC NonInteger exteriorDistance(const MatrixBase< Derived > &p) const
Definition AlignedBox.h:312
EIGEN_DEVICE_FUNC Scalar prod() const
Definition Redux.h:493
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ArrayWrapper< Derived > array()
Definition MatrixBase.h:313
EIGEN_DEVICE_FUNC Derived & setConstant(Index size, const Scalar &val)
Resizes to the given size, and sets all coefficients in this expression to the given value val.
Definition CwiseNullaryOp.h:361
\geometry_module
Definition Translation.h:31
@ Affine
Transformation is an affine transformation stored as a (Dim+1)^2 matrix whose last row is assumed to ...
Definition Constants.h:460
@ AffineCompact
Transformation is an affine transformation stored as a (Dim) x (Dim+1) matrix.
Definition Constants.h:462
@ Isometry
Transformation is an isometry.
Definition Constants.h:457
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition Constants.h:22
Definition XprHelper.h:510