46 #ifndef EIGEN_ALIGNEDBOX_H 47 #define EIGEN_ALIGNEDBOX_H 50 #include "./InternalHeaderCheck.h" 68 template <
typename Scalar_,
int AmbientDim_>
71 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar_, AmbientDim_)
72 enum { AmbientDimAtCompileTime = AmbientDim_ };
73 typedef Scalar_ Scalar;
74 typedef NumTraits<Scalar> ScalarTraits;
76 typedef typename ScalarTraits::Real RealScalar;
77 typedef typename ScalarTraits::NonInteger NonInteger;
109 if (EIGEN_CONST_CONDITIONAL(AmbientDimAtCompileTime !=
Dynamic))
setEmpty();
118 template <
typename OtherVectorType1,
typename OtherVectorType2>
119 EIGEN_DEVICE_FUNC
inline AlignedBox(
const OtherVectorType1& _min,
const OtherVectorType2& _max)
120 : m_min(_min), m_max(_max) {}
123 template <
typename Derived>
130 return AmbientDimAtCompileTime ==
Dynamic ? m_min.size() :
Index(AmbientDimAtCompileTime);
141 EIGEN_DEVICE_FUNC
inline bool isEmpty()
const {
return (m_min.array() > m_max.array()).any(); }
162 return (m_min + m_max) / RealScalar(2);
172 return m_max - m_min;
198 EIGEN_STATIC_ASSERT(AmbientDim_ <= 3, THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE);
218 if (!ScalarTraits::IsInteger) {
219 r[d] = m_min[d] + (m_max[d] - m_min[d]) * internal::random<Scalar>(Scalar(0), Scalar(1));
221 r[d] = internal::random(m_min[d], m_max[d]);
227 template <
typename Derived>
229 typename internal::nested_eval<Derived, 2>::type p_n(p.
derived());
230 return (m_min.array() <= p_n.array()).
all() && (p_n.array() <= m_max.array()).
all();
235 return (m_min.array() <= (b.min)().array()).
all() && ((b.max)().array() <= m_max.array()).
all();
241 return (m_min.array() <= (b.max)().array()).
all() && ((b.min)().array() <= m_max.array()).
all();
246 template <
typename Derived>
248 typename internal::nested_eval<Derived, 2>::type p_n(p.
derived());
249 m_min = m_min.cwiseMin(p_n);
250 m_max = m_max.cwiseMax(p_n);
257 m_min = m_min.cwiseMin(b.m_min);
258 m_max = m_max.cwiseMax(b.m_max);
266 m_min = m_min.cwiseMax(b.m_min);
267 m_max = m_max.cwiseMin(b.m_max);
275 return AlignedBox(m_min.cwiseMax(b.m_min), m_max.cwiseMin(b.m_max));
282 return AlignedBox(m_min.cwiseMin(b.m_min), m_max.cwiseMax(b.m_max));
286 template <
typename Derived>
288 const typename internal::nested_eval<Derived, 2>::type t(a_t.
derived());
295 template <
typename Derived>
298 result.translate(a_t);
306 template <
typename Derived>
319 template <
typename Derived>
335 template <
int Mode,
int Options>
347 template <
int Mode,
int Options>
351 THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS);
362 transform.linear() * (this->m_max + this->m_min) + Scalar(2) *
transform.translation();
364 this->m_max = (rotated_center_2 + rotated_extent_2) / Scalar(2);
365 this->m_min = (rotated_center_2 - rotated_extent_2) / Scalar(2);
372 template <
int Mode,
int Options>
385 template <
typename NewScalarType>
386 EIGEN_DEVICE_FUNC
inline 387 typename internal::cast_return_type<AlignedBox, AlignedBox<NewScalarType, AmbientDimAtCompileTime> >::type
389 return typename internal::cast_return_type<AlignedBox, AlignedBox<NewScalarType, AmbientDimAtCompileTime> >::type(
394 template <
typename OtherScalarType>
396 m_min = (other.min)().template cast<Scalar>();
397 m_max = (other.max)().template cast<Scalar>();
405 const RealScalar& prec = ScalarTraits::dummy_precision())
const {
406 return m_min.isApprox(other.m_min, prec) && m_max.isApprox(other.m_max, prec);
410 VectorType m_min, m_max;
413 template <
typename Scalar,
int AmbientDim>
414 template <
typename Derived>
417 typename internal::nested_eval<Derived, 2 * AmbientDim>::type p(a_p.
derived());
420 for (
Index k = 0; k < dim(); ++k) {
421 if (m_min[k] > p[k]) {
422 aux = m_min[k] - p[k];
424 }
else if (p[k] > m_max[k]) {
425 aux = p[k] - m_max[k];
432 template <
typename Scalar,
int AmbientDim>
436 for (
Index k = 0; k < dim(); ++k) {
437 if (m_min[k] > b.m_max[k]) {
438 aux = m_min[k] - b.m_max[k];
440 }
else if (b.m_min[k] > m_max[k]) {
441 aux = b.m_min[k] - m_max[k];
465 #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ 467 typedef AlignedBox<Type, Size> AlignedBox##SizeSuffix##TypeSuffix; 469 #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ 470 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 1, 1) \ 471 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ 472 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ 473 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ 474 EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) 476 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
int, i)
477 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
float, f)
478 EIGEN_MAKE_TYPEDEFS_ALL_SIZES(
double, d)
480 #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES 481 #undef EIGEN_MAKE_TYPEDEFS 485 #endif // EIGEN_ALIGNEDBOX_H Index dim() const
Definition: AlignedBox.h:129
AlignedBox & extend(const MatrixBase< Derived > &p)
Definition: AlignedBox.h:247
static constexpr Eigen::internal::all_t all
Definition: IndexedViewHelper.h:86
AlignedBox()
Definition: AlignedBox.h:108
constexpr Derived & derived()
Definition: EigenBase.h:49
AlignedBox & translate(const MatrixBase< Derived > &a_t)
Definition: AlignedBox.h:287
bool intersects(const AlignedBox &b) const
Definition: AlignedBox.h:240
NonInteger exteriorDistance(const MatrixBase< Derived > &p) const
Definition: AlignedBox.h:320
AlignedBox(const AlignedBox< OtherScalarType, AmbientDimAtCompileTime > &other)
Definition: AlignedBox.h:395
bool isApprox(const AlignedBox &other, const RealScalar &prec=ScalarTraits::dummy_precision()) const
Definition: AlignedBox.h:404
bool contains(const AlignedBox &b) const
Definition: AlignedBox.h:234
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
const VectorType &() max() const
Definition: AlignedBox.h:155
VectorType sample() const
Definition: AlignedBox.h:215
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
Definition: Constants.h:455
void transform(const typename Transform< Scalar, AmbientDimAtCompileTime, Mode, Options >::TranslationType &translation)
Definition: AlignedBox.h:336
bool isNull() const
Definition: AlignedBox.h:134
Definition: AlignedBox.h:98
Scalar squaredExteriorDistance(const MatrixBase< Derived > &p) const
Definition: AlignedBox.h:415
An axis aligned box.
Definition: ForwardDeclarations.h:465
AlignedBox transformed(const Transform< Scalar, AmbientDimAtCompileTime, Mode, Options > &transform) const
Definition: AlignedBox.h:374
Represents a translation transformation.
Definition: ForwardDeclarations.h:463
AlignedBox intersection(const AlignedBox &b) const
Definition: AlignedBox.h:274
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:75
CornerType
Definition: AlignedBox.h:82
AlignedBox & extend(const AlignedBox &b)
Definition: AlignedBox.h:256
Definition: Constants.h:460
internal::cast_return_type< AlignedBox, AlignedBox< NewScalarType, AmbientDimAtCompileTime > >::type cast() const
Definition: AlignedBox.h:388
bool isEmpty() const
Definition: AlignedBox.h:141
const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(VectorTypeSum, RealScalar, quotient) center() const
Definition: AlignedBox.h:160
Scalar volume() const
Definition: AlignedBox.h:176
AlignedBox(Index _dim)
Definition: AlignedBox.h:113
void transform(const Transform< Scalar, AmbientDimAtCompileTime, Mode, Options > &transform)
Definition: AlignedBox.h:348
Definition: AlignedBox.h:85
Definition: AlignedBox.h:91
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
Eigen::Index Index
Definition: AlignedBox.h:75
CwiseBinaryOp< internal::scalar_difference_op< Scalar, Scalar >, const VectorType, const VectorType > diagonal() const
Definition: AlignedBox.h:184
NonInteger exteriorDistance(const AlignedBox &b) const
Definition: AlignedBox.h:328
VectorType corner(CornerType corner) const
Definition: AlignedBox.h:197
Definition: AlignedBox.h:90
AlignedBox(const MatrixBase< Derived > &p)
Definition: AlignedBox.h:124
Derived & setConstant(Index size, const Scalar &val)
Definition: CwiseNullaryOp.h:363
Definition: AlignedBox.h:92
AlignedBox translated(const MatrixBase< Derived > &a_t) const
Definition: AlignedBox.h:296
Definition: AlignedBox.h:103
Definition: AlignedBox.h:89
AlignedBox merged(const AlignedBox &b) const
Definition: AlignedBox.h:281
const VectorType &() min() const
Definition: AlignedBox.h:151
Definition: AlignedBox.h:97
bool contains(const MatrixBase< Derived > &p) const
Definition: AlignedBox.h:228
Definition: AlignedBox.h:100
AlignedBox & clamp(const AlignedBox &b)
Definition: AlignedBox.h:265
VectorType &() min()
Definition: AlignedBox.h:153
Definition: AlignedBox.h:84
const int Dynamic
Definition: Constants.h:25
Definition: AlignedBox.h:101
void setNull()
Definition: AlignedBox.h:137
Definition: Constants.h:458
const CwiseBinaryOp< internal::scalar_difference_op< Scalar, Scalar >, const VectorType, const VectorType > sizes() const
Definition: AlignedBox.h:171
void setEmpty()
Definition: AlignedBox.h:145
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
Definition: AlignedBox.h:102
AlignedBox(const OtherVectorType1 &_min, const OtherVectorType2 &_max)
Definition: AlignedBox.h:119
Definition: AlignedBox.h:96
VectorType &() max()
Definition: AlignedBox.h:157
Definition: AlignedBox.h:99