Eigen::AlignedBox< Scalar_, AmbientDim_ > Class Template Reference

An axis aligned box. More...

Public Types

enum  { AmbientDimAtCompileTime }
 
enum  CornerType {
  Min ,
  Max ,
  BottomLeft ,
  BottomRight ,
  TopLeft ,
  TopRight ,
  BottomLeftFloor ,
  BottomRightFloor ,
  TopLeftFloor ,
  TopRightFloor ,
  BottomLeftCeil ,
  BottomRightCeil ,
  TopLeftCeil ,
  TopRightCeil
}
 
typedef Eigen::Index Index
 
typedef ScalarTraits::NonInteger NonInteger
 
typedef ScalarTraits::Real RealScalar
 
typedef Scalar_ Scalar
 
typedef NumTraits< ScalarScalarTraits
 
typedef Matrix< Scalar, AmbientDimAtCompileTime, 1 > VectorType
 
typedef CwiseBinaryOp< internal::scalar_sum_op< Scalar >, const VectorType, const VectorTypeVectorTypeSum
 

Public Member Functions

 AlignedBox ()
 
template<typename OtherScalarType >
 AlignedBox (const AlignedBox< OtherScalarType, AmbientDimAtCompileTime > &other)
 
template<typename Derived >
 AlignedBox (const MatrixBase< Derived > &p)
 
template<typename OtherVectorType1 , typename OtherVectorType2 >
 AlignedBox (const OtherVectorType1 &_min, const OtherVectorType2 &_max)
 
 AlignedBox (Index _dim)
 
template<typename NewScalarType >
internal::cast_return_type< AlignedBox, AlignedBox< NewScalarType, AmbientDimAtCompileTime > >::type cast () const
 
AlignedBoxclamp (const AlignedBox &b)
 
bool contains (const AlignedBox &b) const
 
template<typename Derived >
bool contains (const MatrixBase< Derived > &p) const
 
VectorType corner (CornerType corner) const
 
CwiseBinaryOp< internal::scalar_difference_op< Scalar, Scalar >, const VectorType, const VectorTypediagonal () const
 
Index dim () const
 
const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE (VectorTypeSum, RealScalar, quotient) center() const
 
AlignedBoxextend (const AlignedBox &b)
 
template<typename Derived >
AlignedBoxextend (const MatrixBase< Derived > &p)
 
NonInteger exteriorDistance (const AlignedBox &b) const
 
template<typename Derived >
NonInteger exteriorDistance (const MatrixBase< Derived > &p) const
 
AlignedBox intersection (const AlignedBox &b) const
 
bool intersects (const AlignedBox &b) const
 
bool isApprox (const AlignedBox &other, const RealScalar &prec=ScalarTraits::dummy_precision()) const
 
bool isEmpty () const
 
bool isNull () const
 
VectorType &() max ()
 
const VectorType &() max () const
 
AlignedBox merged (const AlignedBox &b) const
 
VectorType &() min ()
 
const VectorType &() min () const
 
VectorType sample () const
 
void setEmpty ()
 
void setNull ()
 
const CwiseBinaryOp< internal::scalar_difference_op< Scalar, Scalar >, const VectorType, const VectorTypesizes () const
 
Scalar squaredExteriorDistance (const AlignedBox &b) const
 
template<typename Derived >
Scalar squaredExteriorDistance (const MatrixBase< Derived > &p) const
 
template<int Mode, int Options>
void transform (const Transform< Scalar, AmbientDimAtCompileTime, Mode, Options > &transform)
 
template<int Mode, int Options>
void transform (const typename Transform< Scalar, AmbientDimAtCompileTime, Mode, Options >::TranslationType &translation)
 
template<int Mode, int Options>
AlignedBox transformed (const Transform< Scalar, AmbientDimAtCompileTime, Mode, Options > &transform) const
 
template<typename Derived >
AlignedBoxtranslate (const MatrixBase< Derived > &a_t)
 
template<typename Derived >
AlignedBox translated (const MatrixBase< Derived > &a_t) const
 
Scalar volume () const
 
 ~AlignedBox ()
 

Protected Attributes

VectorType m_max
 
VectorType m_min
 

Detailed Description

template<typename Scalar_, int AmbientDim_>
class Eigen::AlignedBox< Scalar_, AmbientDim_ >

An axis aligned box.

This is defined in the Geometry module.

Template Parameters
Scalar_the type of the scalar coefficients
AmbientDim_the dimension of the ambient space, can be a compile time value or Dynamic.

This class represents an axis aligned box as a pair of the minimal and maximal corners.

Warning
The result of most methods is undefined when applied to an empty box. You can check for empty boxes using isEmpty().
See also
Global aligned box typedefs

Definition at line 68 of file AlignedBox.h.

Member Typedef Documentation

◆ Index

template<typename Scalar_ , int AmbientDim_>
typedef Eigen::Index Eigen::AlignedBox< Scalar_, AmbientDim_ >::Index
Deprecated:
since Eigen 3.3

Definition at line 75 of file AlignedBox.h.

◆ NonInteger

template<typename Scalar_ , int AmbientDim_>
typedef ScalarTraits::NonInteger Eigen::AlignedBox< Scalar_, AmbientDim_ >::NonInteger

Definition at line 77 of file AlignedBox.h.

◆ RealScalar

template<typename Scalar_ , int AmbientDim_>
typedef ScalarTraits::Real Eigen::AlignedBox< Scalar_, AmbientDim_ >::RealScalar

Definition at line 76 of file AlignedBox.h.

◆ Scalar

template<typename Scalar_ , int AmbientDim_>
typedef Scalar_ Eigen::AlignedBox< Scalar_, AmbientDim_ >::Scalar

Definition at line 73 of file AlignedBox.h.

◆ ScalarTraits

template<typename Scalar_ , int AmbientDim_>
typedef NumTraits<Scalar> Eigen::AlignedBox< Scalar_, AmbientDim_ >::ScalarTraits

Definition at line 74 of file AlignedBox.h.

◆ VectorType

template<typename Scalar_ , int AmbientDim_>
typedef Matrix<Scalar,AmbientDimAtCompileTime,1> Eigen::AlignedBox< Scalar_, AmbientDim_ >::VectorType

Definition at line 78 of file AlignedBox.h.

◆ VectorTypeSum

template<typename Scalar_ , int AmbientDim_>
typedef CwiseBinaryOp<internal::scalar_sum_op<Scalar>, const VectorType, const VectorType> Eigen::AlignedBox< Scalar_, AmbientDim_ >::VectorTypeSum

Definition at line 79 of file AlignedBox.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Scalar_ , int AmbientDim_>
anonymous enum
Enumerator
AmbientDimAtCompileTime 

Definition at line 72 of file AlignedBox.h.

72 { AmbientDimAtCompileTime = AmbientDim_ };

◆ CornerType

template<typename Scalar_ , int AmbientDim_>
enum Eigen::AlignedBox::CornerType

Define constants to name the corners of a 1D, 2D or 3D axis aligned bounding box

Enumerator
Min 

1D names

Max 

1D names

BottomLeft 

Identifier for 2D corner

BottomRight 

Identifier for 2D corner

TopLeft 

Identifier for 2D corner

TopRight 

Identifier for 2D corner

BottomLeftFloor 

Identifier for 3D corner

BottomRightFloor 

Identifier for 3D corner

TopLeftFloor 

Identifier for 3D corner

TopRightFloor 

Identifier for 3D corner

BottomLeftCeil 

Identifier for 3D corner

BottomRightCeil 

Identifier for 3D corner

TopLeftCeil 

Identifier for 3D corner

TopRightCeil 

Identifier for 3D corner

Definition at line 82 of file AlignedBox.h.

Constructor & Destructor Documentation

◆ AlignedBox() [1/5]

template<typename Scalar_ , int AmbientDim_>
Eigen::AlignedBox< Scalar_, AmbientDim_ >::AlignedBox ( )
inline

Default constructor initializing a null box.

Definition at line 103 of file AlignedBox.h.

#define EIGEN_CONST_CONDITIONAL(cond)
Definition: Macros.h:1048
const int Dynamic
Definition: Constants.h:24

◆ AlignedBox() [2/5]

template<typename Scalar_ , int AmbientDim_>
Eigen::AlignedBox< Scalar_, AmbientDim_ >::AlignedBox ( Index  _dim)
inlineexplicit

Constructs a null box with _dim the dimension of the ambient space.

Definition at line 107 of file AlignedBox.h.

107  : m_min(_dim), m_max(_dim)
108  { setEmpty(); }
VectorType m_min
Definition: AlignedBox.h:403
VectorType m_max
Definition: AlignedBox.h:403

◆ AlignedBox() [3/5]

template<typename Scalar_ , int AmbientDim_>
template<typename OtherVectorType1 , typename OtherVectorType2 >
Eigen::AlignedBox< Scalar_, AmbientDim_ >::AlignedBox ( const OtherVectorType1 &  _min,
const OtherVectorType2 &  _max 
)
inline

Constructs a box with extremities _min and _max.

Warning
If either component of _min is larger than the same component of _max, the constructed box is empty.

Definition at line 113 of file AlignedBox.h.

113 : m_min(_min), m_max(_max) {}

◆ AlignedBox() [4/5]

template<typename Scalar_ , int AmbientDim_>
template<typename Derived >
Eigen::AlignedBox< Scalar_, AmbientDim_ >::AlignedBox ( const MatrixBase< Derived > &  p)
inlineexplicit

Constructs a box containing a single point p.

Definition at line 117 of file AlignedBox.h.

117  : m_min(p), m_max(m_min)
118  { }
float * p

◆ ~AlignedBox()

template<typename Scalar_ , int AmbientDim_>
Eigen::AlignedBox< Scalar_, AmbientDim_ >::~AlignedBox ( )
inline

Definition at line 120 of file AlignedBox.h.

120 {}

◆ AlignedBox() [5/5]

template<typename Scalar_ , int AmbientDim_>
template<typename OtherScalarType >
Eigen::AlignedBox< Scalar_, AmbientDim_ >::AlignedBox ( const AlignedBox< OtherScalarType, AmbientDimAtCompileTime > &  other)
inlineexplicit

Copy constructor with scalar type conversion

Definition at line 388 of file AlignedBox.h.

389  {
390  m_min = (other.min)().template cast<Scalar>();
391  m_max = (other.max)().template cast<Scalar>();
392  }

Member Function Documentation

◆ cast()

template<typename Scalar_ , int AmbientDim_>
template<typename NewScalarType >
internal::cast_return_type<AlignedBox, AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type Eigen::AlignedBox< Scalar_, AmbientDim_ >::cast ( ) const
inline
Returns
*this with scalar type casted to NewScalarType

Note that if NewScalarType is equal to the current scalar type of *this then this function smartly returns a const reference to *this.

Definition at line 380 of file AlignedBox.h.

381  {
382  return typename internal::cast_return_type<AlignedBox,
383  AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
384  }

◆ clamp()

template<typename Scalar_ , int AmbientDim_>
AlignedBox& Eigen::AlignedBox< Scalar_, AmbientDim_ >::clamp ( const AlignedBox< Scalar_, AmbientDim_ > &  b)
inline

Clamps *this by the box b and returns a reference to *this.

Note
If the boxes don't intersect, the resulting box is empty.
See also
intersection(), intersects()

Definition at line 258 of file AlignedBox.h.

259  {
260  m_min = m_min.cwiseMax(b.m_min);
261  m_max = m_max.cwiseMin(b.m_max);
262  return *this;
263  }
Array< int, 3, 1 > b

◆ contains() [1/2]

template<typename Scalar_ , int AmbientDim_>
bool Eigen::AlignedBox< Scalar_, AmbientDim_ >::contains ( const AlignedBox< Scalar_, AmbientDim_ > &  b) const
inline
Returns
true if the box b is entirely inside the box *this.

Definition at line 227 of file AlignedBox.h.

228  { return (m_min.array()<=(b.min)().array()).all() && ((b.max)().array()<=m_max.array()).all(); }
static const Eigen::internal::all_t all

◆ contains() [2/2]

template<typename Scalar_ , int AmbientDim_>
template<typename Derived >
bool Eigen::AlignedBox< Scalar_, AmbientDim_ >::contains ( const MatrixBase< Derived > &  p) const
inline
Returns
true if the point p is inside the box *this.

Definition at line 220 of file AlignedBox.h.

221  {
222  typename internal::nested_eval<Derived,2>::type p_n(p.derived());
223  return (m_min.array()<=p_n.array()).all() && (p_n.array()<=m_max.array()).all();
224  }

◆ corner()

template<typename Scalar_ , int AmbientDim_>
VectorType Eigen::AlignedBox< Scalar_, AmbientDim_ >::corner ( CornerType  corner) const
inline
Returns
the vertex of the bounding box at the corner defined by the corner-id corner. It works only for a 1D, 2D or 3D bounding box. For 1D bounding boxes corners are named by 2 enum constants: BottomLeft and BottomRight. For 2D bounding boxes, corners are named by 4 enum constants: BottomLeft, BottomRight, TopLeft, TopRight. For 3D bounding boxes, the following names are added: BottomLeftCeil, BottomRightCeil, TopLeftCeil, TopRightCeil.

Definition at line 184 of file AlignedBox.h.

185  {
186  EIGEN_STATIC_ASSERT(AmbientDim_ <= 3, THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE);
187 
188  VectorType res;
189 
190  Index mult = 1;
191  for(Index d=0; d<dim(); ++d)
192  {
193  if( mult & corner ) res[d] = m_max[d];
194  else res[d] = m_min[d];
195  mult *= 2;
196  }
197  return res;
198  }
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
Matrix< Scalar, AmbientDimAtCompileTime, 1 > VectorType
Definition: AlignedBox.h:78
VectorType corner(CornerType corner) const
Definition: AlignedBox.h:184
Eigen::Index Index
Definition: AlignedBox.h:75
Index dim() const
Definition: AlignedBox.h:123

◆ diagonal()

template<typename Scalar_ , int AmbientDim_>
CwiseBinaryOp< internal::scalar_difference_op<Scalar,Scalar>, const VectorType, const VectorType> Eigen::AlignedBox< Scalar_, AmbientDim_ >::diagonal ( ) const
inline
Returns
an expression for the bounding box diagonal vector if the length of the diagonal is needed: diagonal().norm() will provide it.

Definition at line 172 of file AlignedBox.h.

173  { return sizes(); }
const CwiseBinaryOp< internal::scalar_difference_op< Scalar, Scalar >, const VectorType, const VectorType > sizes() const
Definition: AlignedBox.h:161

◆ dim()

template<typename Scalar_ , int AmbientDim_>
Index Eigen::AlignedBox< Scalar_, AmbientDim_ >::dim ( ) const
inline
Returns
the dimension in which the box holds

Definition at line 123 of file AlignedBox.h.

◆ EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE()

template<typename Scalar_ , int AmbientDim_>
const Eigen::AlignedBox< Scalar_, AmbientDim_ >::EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE ( VectorTypeSum  ,
RealScalar  ,
quotient   
) const
inline
Returns
the center of the box

Definition at line 153 of file AlignedBox.h.

155  { return (m_min+m_max)/RealScalar(2); }
ScalarTraits::Real RealScalar
Definition: AlignedBox.h:76

◆ extend() [1/2]

template<typename Scalar_ , int AmbientDim_>
AlignedBox& Eigen::AlignedBox< Scalar_, AmbientDim_ >::extend ( const AlignedBox< Scalar_, AmbientDim_ > &  b)
inline

Extends *this such that it contains the box b and returns a reference to *this.

See also
merged, extend(const MatrixBase&)

Definition at line 248 of file AlignedBox.h.

249  {
250  m_min = m_min.cwiseMin(b.m_min);
251  m_max = m_max.cwiseMax(b.m_max);
252  return *this;
253  }

◆ extend() [2/2]

template<typename Scalar_ , int AmbientDim_>
template<typename Derived >
AlignedBox& Eigen::AlignedBox< Scalar_, AmbientDim_ >::extend ( const MatrixBase< Derived > &  p)
inline

Extends *this such that it contains the point p and returns a reference to *this.

See also
extend(const AlignedBox&)

Definition at line 238 of file AlignedBox.h.

239  {
240  typename internal::nested_eval<Derived,2>::type p_n(p.derived());
241  m_min = m_min.cwiseMin(p_n);
242  m_max = m_max.cwiseMax(p_n);
243  return *this;
244  }

◆ exteriorDistance() [1/2]

template<typename Scalar_ , int AmbientDim_>
NonInteger Eigen::AlignedBox< Scalar_, AmbientDim_ >::exteriorDistance ( const AlignedBox< Scalar_, AmbientDim_ > &  b) const
inline
Returns
the distance between the boxes b and *this, and zero if the boxes intersect.
See also
squaredExteriorDistance(const AlignedBox&), exteriorDistance(const MatrixBase&)

Definition at line 321 of file AlignedBox.h.

#define EIGEN_USING_STD(FUNC)
Definition: Macros.h:1080
ScalarTraits::NonInteger NonInteger
Definition: AlignedBox.h:77
Scalar squaredExteriorDistance(const MatrixBase< Derived > &p) const
Definition: AlignedBox.h:410
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)

◆ exteriorDistance() [2/2]

template<typename Scalar_ , int AmbientDim_>
template<typename Derived >
NonInteger Eigen::AlignedBox< Scalar_, AmbientDim_ >::exteriorDistance ( const MatrixBase< Derived > &  p) const
inline
Returns
the distance between the point p and the box *this, and zero if p is inside the box.
See also
squaredExteriorDistance(const MatrixBase&), exteriorDistance(const AlignedBox&)

Definition at line 314 of file AlignedBox.h.

◆ intersection()

template<typename Scalar_ , int AmbientDim_>
AlignedBox Eigen::AlignedBox< Scalar_, AmbientDim_ >::intersection ( const AlignedBox< Scalar_, AmbientDim_ > &  b) const
inline

Returns an AlignedBox that is the intersection of b and *this

Note
If the boxes don't intersect, the resulting box is empty.
See also
intersects(), clamp, contains()

Definition at line 268 of file AlignedBox.h.

269  {return AlignedBox(m_min.cwiseMax(b.m_min), m_max.cwiseMin(b.m_max)); }

◆ intersects()

template<typename Scalar_ , int AmbientDim_>
bool Eigen::AlignedBox< Scalar_, AmbientDim_ >::intersects ( const AlignedBox< Scalar_, AmbientDim_ > &  b) const
inline
Returns
true if the box b is intersecting the box *this.
See also
intersection, clamp

Definition at line 232 of file AlignedBox.h.

233  { return (m_min.array()<=(b.max)().array()).all() && ((b.min)().array()<=m_max.array()).all(); }

◆ isApprox()

template<typename Scalar_ , int AmbientDim_>
bool Eigen::AlignedBox< Scalar_, AmbientDim_ >::isApprox ( const AlignedBox< Scalar_, AmbientDim_ > &  other,
const RealScalar prec = ScalarTraits::dummy_precision() 
) const
inline
Returns
true if *this is approximately equal to other, within the precision determined by prec.
See also
MatrixBase::isApprox()

Definition at line 398 of file AlignedBox.h.

399  { return m_min.isApprox(other.m_min, prec) && m_max.isApprox(other.m_max, prec); }

◆ isEmpty()

template<typename Scalar_ , int AmbientDim_>
bool Eigen::AlignedBox< Scalar_, AmbientDim_ >::isEmpty ( ) const
inline
Returns
true if the box is empty.
See also
setEmpty

Definition at line 133 of file AlignedBox.h.

133 { return (m_min.array() > m_max.array()).any(); }

◆ isNull()

template<typename Scalar_ , int AmbientDim_>
bool Eigen::AlignedBox< Scalar_, AmbientDim_ >::isNull ( ) const
inline
Deprecated:
use isEmpty()

Definition at line 126 of file AlignedBox.h.

126 { return isEmpty(); }
bool isEmpty() const
Definition: AlignedBox.h:133

◆ max() [1/2]

template<typename Scalar_ , int AmbientDim_>
VectorType&() Eigen::AlignedBox< Scalar_, AmbientDim_ >::max ( )
inline
Returns
a non const reference to the maximal corner

Definition at line 150 of file AlignedBox.h.

150 { return m_max; }

◆ max() [2/2]

template<typename Scalar_ , int AmbientDim_>
const VectorType&() Eigen::AlignedBox< Scalar_, AmbientDim_ >::max ( ) const
inline
Returns
the maximal corner

Definition at line 148 of file AlignedBox.h.

148 { return m_max; }

◆ merged()

template<typename Scalar_ , int AmbientDim_>
AlignedBox Eigen::AlignedBox< Scalar_, AmbientDim_ >::merged ( const AlignedBox< Scalar_, AmbientDim_ > &  b) const
inline

Returns an AlignedBox that is the union of b and *this.

Note
Merging with an empty box may result in a box bigger than *this.
See also
extend(const AlignedBox&)

Definition at line 274 of file AlignedBox.h.

275  { return AlignedBox(m_min.cwiseMin(b.m_min), m_max.cwiseMax(b.m_max)); }

◆ min() [1/2]

template<typename Scalar_ , int AmbientDim_>
VectorType&() Eigen::AlignedBox< Scalar_, AmbientDim_ >::min ( )
inline
Returns
a non const reference to the minimal corner

Definition at line 146 of file AlignedBox.h.

146 { return m_min; }

◆ min() [2/2]

template<typename Scalar_ , int AmbientDim_>
const VectorType&() Eigen::AlignedBox< Scalar_, AmbientDim_ >::min ( ) const
inline
Returns
the minimal corner

Definition at line 144 of file AlignedBox.h.

144 { return m_min; }

◆ sample()

template<typename Scalar_ , int AmbientDim_>
VectorType Eigen::AlignedBox< Scalar_, AmbientDim_ >::sample ( ) const
inline
Returns
a random point inside the bounding box sampled with a uniform distribution

Definition at line 202 of file AlignedBox.h.

203  {
204  VectorType r(dim());
205  for(Index d=0; d<dim(); ++d)
206  {
208  {
209  r[d] = m_min[d] + (m_max[d]-m_min[d])
210  * internal::random<Scalar>(Scalar(0), Scalar(1));
211  }
212  else
213  r[d] = internal::random(m_min[d], m_max[d]);
214  }
215  return r;
216  }

◆ setEmpty()

template<typename Scalar_ , int AmbientDim_>
void Eigen::AlignedBox< Scalar_, AmbientDim_ >::setEmpty ( )
inline

Makes *this an empty box.

See also
isEmpty

Definition at line 137 of file AlignedBox.h.

138  {
139  m_min.setConstant( ScalarTraits::highest() );
140  m_max.setConstant( ScalarTraits::lowest() );
141  }
Derived & setConstant(Index size, const Scalar &val)

◆ setNull()

template<typename Scalar_ , int AmbientDim_>
void Eigen::AlignedBox< Scalar_, AmbientDim_ >::setNull ( )
inline
Deprecated:
use setEmpty()

Definition at line 129 of file AlignedBox.h.

129 { setEmpty(); }

◆ sizes()

template<typename Scalar_ , int AmbientDim_>
const CwiseBinaryOp< internal::scalar_difference_op<Scalar,Scalar>, const VectorType, const VectorType> Eigen::AlignedBox< Scalar_, AmbientDim_ >::sizes ( ) const
inline
Returns
the lengths of the sides of the bounding box. Note that this function does not get the same result for integral or floating scalar types: see

Definition at line 161 of file AlignedBox.h.

162  { return m_max - m_min; }

◆ squaredExteriorDistance() [1/2]

template<typename Scalar , int AmbientDim>
Scalar Eigen::AlignedBox< Scalar, AmbientDim >::squaredExteriorDistance ( const AlignedBox< Scalar_, AmbientDim_ > &  b) const
inline
Returns
the squared distance between the boxes b and *this, and zero if the boxes intersect.
See also
exteriorDistance(const AlignedBox&), squaredExteriorDistance(const MatrixBase&)

Definition at line 432 of file AlignedBox.h.

433 {
434  Scalar dist2(0);
435  Scalar aux;
436  for (Index k=0; k<dim(); ++k)
437  {
438  if( m_min[k] > b.m_max[k] )
439  {
440  aux = m_min[k] - b.m_max[k];
441  dist2 += aux*aux;
442  }
443  else if( b.m_min[k] > m_max[k] )
444  {
445  aux = b.m_min[k] - m_max[k];
446  dist2 += aux*aux;
447  }
448  }
449  return dist2;
450 }

◆ squaredExteriorDistance() [2/2]

template<typename Scalar , int AmbientDim>
template<typename Derived >
Scalar Eigen::AlignedBox< Scalar, AmbientDim >::squaredExteriorDistance ( const MatrixBase< Derived > &  p) const
inline
Returns
the squared distance between the point p and the box *this, and zero if p is inside the box.
See also
exteriorDistance(const MatrixBase&), squaredExteriorDistance(const AlignedBox&)

Definition at line 410 of file AlignedBox.h.

411 {
412  typename internal::nested_eval<Derived,2*AmbientDim>::type p(a_p.derived());
413  Scalar dist2(0);
414  Scalar aux;
415  for (Index k=0; k<dim(); ++k)
416  {
417  if( m_min[k] > p[k] )
418  {
419  aux = m_min[k] - p[k];
420  dist2 += aux*aux;
421  }
422  else if( p[k] > m_max[k] )
423  {
424  aux = p[k] - m_max[k];
425  dist2 += aux*aux;
426  }
427  }
428  return dist2;
429 }

◆ transform() [1/2]

template<typename Scalar_ , int AmbientDim_>
template<int Mode, int Options>
void Eigen::AlignedBox< Scalar_, AmbientDim_ >::transform ( const Transform< Scalar, AmbientDimAtCompileTime, Mode, Options > &  transform)
inline

Transforms this box by transform and recomputes it to still be an axis-aligned box.

Note
This method is provided under BSD license (see the top of this file).

Definition at line 341 of file AlignedBox.h.

342  {
343  // Only Affine and Isometry transforms are currently supported.
344  EIGEN_STATIC_ASSERT(Mode == Affine || Mode == AffineCompact || Mode == Isometry, THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS);
345 
346  // Method adapted from FCL src/shape/geometric_shapes_utility.cpp#computeBV<AABB, Box>(...)
347  // https://github.com/flexible-collision-library/fcl/blob/fcl-0.4/src/shape/geometric_shapes_utility.cpp#L292
348  //
349  // Here's a nice explanation why it works: https://zeuxcg.org/2010/10/17/aabb-from-obb-with-component-wise-abs/
350 
351  // two times rotated extent
352  const VectorType rotated_extent_2 = transform.linear().cwiseAbs() * sizes();
353  // two times new center
354  const VectorType rotated_center_2 = transform.linear() * (this->m_max + this->m_min) +
355  Scalar(2) * transform.translation();
356 
357  this->m_max = (rotated_center_2 + rotated_extent_2) / Scalar(2);
358  this->m_min = (rotated_center_2 - rotated_extent_2) / Scalar(2);
359  }
void transform(const typename Transform< Scalar, AmbientDimAtCompileTime, Mode, Options >::TranslationType &translation)
Definition: AlignedBox.h:328
@ Affine
Definition: Constants.h:464
@ AffineCompact
Definition: Constants.h:466
@ Isometry
Definition: Constants.h:461

◆ transform() [2/2]

template<typename Scalar_ , int AmbientDim_>
template<int Mode, int Options>
void Eigen::AlignedBox< Scalar_, AmbientDim_ >::transform ( const typename Transform< Scalar, AmbientDimAtCompileTime, Mode, Options >::TranslationType &  translation)
inline

Specialization of transform for pure translation.

Definition at line 328 of file AlignedBox.h.

330  {
331  this->translate(translation);
332  }
AlignedBox & translate(const MatrixBase< Derived > &a_t)
Definition: AlignedBox.h:279

◆ transformed()

template<typename Scalar_ , int AmbientDim_>
template<int Mode, int Options>
AlignedBox Eigen::AlignedBox< Scalar_, AmbientDim_ >::transformed ( const Transform< Scalar, AmbientDimAtCompileTime, Mode, Options > &  transform) const
inline
Returns
a copy of *this transformed by transform and recomputed to still be an axis-aligned box.

Definition at line 366 of file AlignedBox.h.

367  {
368  AlignedBox result(m_min, m_max);
369  result.transform(transform);
370  return result;
371  }

◆ translate()

template<typename Scalar_ , int AmbientDim_>
template<typename Derived >
AlignedBox& Eigen::AlignedBox< Scalar_, AmbientDim_ >::translate ( const MatrixBase< Derived > &  a_t)
inline

Translate *this by the vector t and returns a reference to *this.

Definition at line 279 of file AlignedBox.h.

280  {
281  const typename internal::nested_eval<Derived,2>::type t(a_t.derived());
282  m_min += t;
283  m_max += t;
284  return *this;
285  }

◆ translated()

template<typename Scalar_ , int AmbientDim_>
template<typename Derived >
AlignedBox Eigen::AlignedBox< Scalar_, AmbientDim_ >::translated ( const MatrixBase< Derived > &  a_t) const
inline
Returns
a copy of *this translated by the vector t.

Definition at line 289 of file AlignedBox.h.

290  {
291  AlignedBox result(m_min, m_max);
292  result.translate(a_t);
293  return result;
294  }

◆ volume()

template<typename Scalar_ , int AmbientDim_>
Scalar Eigen::AlignedBox< Scalar_, AmbientDim_ >::volume ( ) const
inline
Returns
the volume of the bounding box

Definition at line 165 of file AlignedBox.h.

166  { return sizes().prod(); }

Member Data Documentation

◆ m_max

template<typename Scalar_ , int AmbientDim_>
VectorType Eigen::AlignedBox< Scalar_, AmbientDim_ >::m_max
protected

Definition at line 403 of file AlignedBox.h.

◆ m_min

template<typename Scalar_ , int AmbientDim_>
VectorType Eigen::AlignedBox< Scalar_, AmbientDim_ >::m_min
protected

Definition at line 403 of file AlignedBox.h.


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