29#include "common/Interval.h"
35 template<
typename>
struct Sphere;
36 template<
typename>
struct Vector;
39 template<
typename Valtype>
42 typedef Valtype value_type;
63 Box() noexcept = default;
64 Box( Valtype xext, Valtype yext, Valtype zext ) noexcept;
65 explicit
Box( const
Vector<Valtype>& cuboid ) noexcept;
66 Box( Valtype xnear, Valtype ynear, Valtype znear, Valtype xfar, Valtype yfar, Valtype zfar ) noexcept;
130 Box&
FarX( Valtype val ) noexcept;
134 Box&
FarY( Valtype val ) noexcept;
138 Box&
FarZ( Valtype val ) noexcept;
147 Box&
EdgeX( Valtype width ) noexcept;
156 Box&
EdgeY( Valtype width ) noexcept;
165 Box&
EdgeZ( Valtype width ) noexcept;
169 auto
Volume() const noexcept -> decltype(Valtype{}*Valtype{}*Valtype{});
192 bool Includes( Valtype x, Valtype y, Valtype z ) const noexcept;
206 Box&
Expand( Valtype x, Valtype y, Valtype z ) noexcept;
242 template<typename Valtype>
243 bool Intersecting( const
Box<Valtype>& box, const
Sphere<Valtype>& sphere ) noexcept;
245 template<typename Valtype>
246 bool Intersecting( const
Box<Valtype>& boxA, const
Box<Valtype>& boxB ) noexcept;
251 template<typename Valtype> constexpr
252 bool operator==( const
Box<Valtype>& b1, const
Box<Valtype>& b2 ) noexcept;
253 template<typename Valtype> constexpr
254 bool operator!=( const
Box<Valtype>& b1, const
Box<Valtype>& b2 ) noexcept;
274template<typename Valtype> inline
275Box<Valtype>::
Box( Valtype xext, Valtype yext, Valtype zext ) noexcept
281template<
typename Valtype>
inline
283 :
m_WidthX{-diagonal.dx/2,diagonal.dx/2},
284 m_WidthY{-diagonal.dy/2,diagonal.dy/2},
285 m_WidthZ{-diagonal.dz/2,diagonal.dz/2}
288template<
typename Valtype>
inline
289Box<Valtype>::Box( Valtype xnear, Valtype ynear, Valtype znear, Valtype xfar, Valtype yfar, Valtype zfar ) noexcept
295template<
typename Valtype>
inline
297 :
m_WidthX{nearCorner.x,farCorner.x},
302template<
typename Valtype>
inline
310template<
typename Valtype>
inline
315template<
typename Valtype>
inline
323template<
typename Valtype>
inline
328template<
typename Valtype>
inline
333template<
typename Valtype>
inline
338template<
typename Valtype>
inline
343template<
typename Valtype>
inline
348template<
typename Valtype>
inline
353template<
typename Valtype>
inline
358template<
typename Valtype>
inline
363template<
typename Valtype>
inline
369template<
typename Valtype>
inline
375template<
typename Valtype>
inline
381template<
typename Valtype>
inline
387template<
typename Valtype>
inline
393template<
typename Valtype>
inline
399template<
typename Valtype>
inline
404template<
typename Valtype>
inline
410template<
typename Valtype>
inline
415template<
typename Valtype>
inline
421template<
typename Valtype>
inline
426template<
typename Valtype>
inline
432template<
typename Valtype>
inline
437template<
typename Valtype>
inline
442template<
typename Valtype>
inline
447template<
typename Valtype>
inline
449 m_WidthX.Union( b1.m_WidthX, b2.m_WidthX );
450 m_WidthY.Union( b1.m_WidthY, b2.m_WidthY );
451 m_WidthZ.Union( b1.m_WidthZ, b2.m_WidthZ );
456template<
typename Valtype>
inline
464template<
typename Valtype>
inline
469template<
typename Valtype>
inline
471 return Includes( pt.x, pt.y, pt.z );
474template<
typename Valtype>
inline
482template<
typename Valtype>
inline
484 return Expand( pt.x, pt.y, pt.z );
487template<
typename Valtype>
inline
496template<
typename Valtype>
inline
505template<
typename Valtype>
inline
513template<
typename Valtype>
inline
521template<
typename Valtype>
inline
524 return Intersecting( box, sphere.ExBox() );
527template<
typename Valtype>
inline
529 return Intersecting( boxA.m_WidthX, boxB.m_WidthX ) &&
530 Intersecting( boxA.m_WidthY, boxB.m_WidthY ) &&
531 Intersecting( boxA.m_WidthZ, boxB.m_WidthZ );
534template<
typename Valtype>
constexpr
536 return b1.m_WidthX == b2.m_WidthX && b1.m_WidthY == b2.m_WidthY && b1.m_WidthZ == b2.m_WidthZ;
539template<
typename Valtype>
constexpr
constexpr bool operator!=(const Interval< Valtype > &i1, const Interval< Valtype > &i2) noexcept
Interval operator.
Definition Interval.h:701
constexpr bool operator==(const Interval< Valtype > &i1, const Interval< Valtype > &i2) noexcept
Interval operator.
Definition Interval.h:696
The namespace provides classes and methods for spatial computations.
Definition Box.h:32
An interval describes the area between two numbers. It is understood to contain the near one and exlu...
Definition Interval.h:42
Axis aligned box.
Definition Box.h:41
dim::Value< Dimension< 1, 0, 0 > > EdgeZ() const noexcept
Definition Box.h:422
auto Volume() const noexcept -> decltype(dim::Value< Dimension< 1, 0, 0 > >{} *dim::Value< Dimension< 1, 0, 0 > >{} *dim::Value< Dimension< 1, 0, 0 > >{})
Definition Box.h:433
const Position< dim::Value< Dimension< 1, 0, 0 > > > Far() const noexcept
Definition Box.h:329
Box & Inflate(dim::Value< Dimension< 1, 0, 0 > > dx, dim::Value< Dimension< 1, 0, 0 > > dy, dim::Value< Dimension< 1, 0, 0 > > dz) noexcept
Definition Box.h:488
Vector< Valtype > Diagonal() const noexcept
Definition Box.h:438
common::Interval< Valtype > m_WidthZ
height
Definition Box.h:46
bool Normal() const noexcept
Definition Box.h:311
common::Interval< Valtype > m_WidthX
width
Definition Box.h:44
dim::Value< Dimension< 1, 0, 0 > > NearY() const noexcept
Definition Box.h:339
dim::Value< Dimension< 1, 0, 0 > > NearX() const noexcept
Definition Box.h:334
Box & Deflate(dim::Value< Dimension< 1, 0, 0 > > dx, dim::Value< Dimension< 1, 0, 0 > > dy, dim::Value< Dimension< 1, 0, 0 > > dz) noexcept
Definition Box.h:497
dim::Value< Dimension< 1, 0, 0 > > FarX() const noexcept
Definition Box.h:349
Box & Union(const Box &b1, const Box &b2) noexcept
Definition Box.h:448
dim::Value< Dimension< 1, 0, 0 > > FarY() const noexcept
Definition Box.h:354
Box & Normalize() noexcept
Definition Box.h:316
Box & Expand(dim::Value< Dimension< 1, 0, 0 > > x, dim::Value< Dimension< 1, 0, 0 > > y, dim::Value< Dimension< 1, 0, 0 > > z) noexcept
Definition Box.h:475
dim::Value< Dimension< 1, 0, 0 > > EdgeY() const noexcept
Definition Box.h:411
const Position< dim::Value< Dimension< 1, 0, 0 > > > Near() const noexcept
Definition Box.h:324
Box() noexcept=default
Does not initialize the members.
dim::Value< Dimension< 1, 0, 0 > > NearZ() const noexcept
Definition Box.h:344
Box & Init() noexcept
Definition Box.h:303
dim::Value< Dimension< 1, 0, 0 > > FarZ() const noexcept
Definition Box.h:359
Box & Round(int toDigit) noexcept
Definition Box.h:514
Box & Move(const Vector< dim::Value< Dimension< 1, 0, 0 > > > &dPos) noexcept
Definition Box.h:506
dim::Value< Dimension< 1, 0, 0 > > EdgeX() const noexcept
Definition Box.h:400
Position< dim::Value< Dimension< 1, 0, 0 > > > Center() const noexcept
Definition Box.h:443
bool Includes(dim::Value< Dimension< 1, 0, 0 > > x, dim::Value< Dimension< 1, 0, 0 > > y, dim::Value< Dimension< 1, 0, 0 > > z) const noexcept
Definition Box.h:465
common::Interval< Valtype > m_WidthY
depth
Definition Box.h:45
Implements a 3D - position in cartesian coordinates.
Definition Position.h:46
Sphere with center and radius.
Definition Sphere.h:39
Implements a 3D - vector in cartesian coordinates.
Definition Vector.h:48