17 Extent2() { tx1_ = tx2_ = ty1_ = ty2_ = initVal<T>(); }
27 constexpr const Extent2 &operator=(
const Extent2 &e) { tx1_=e.tx1_; tx2_=e.tx2_; ty1_=e.ty1_; ty2_=e.ty2_;
return *
this; }
33 const T &
x1()
const {
return tx1_; }
35 const T &
x2()
const {
return tx2_; }
37 const T &
y1()
const {
return ty1_; }
39 const T &
y2()
const {
return ty2_; }
41 const T &
dof1(uint32 u)
const {
48 const T &
dof2(uint32 u)
const {
55 T
width()
const {
return (tx2_-tx1_); }
57 T
height()
const {
return (ty2_-ty1_); }
81 bool isEmpty()
const {
return( (tx1_>=tx2_) || (ty1_>=ty2_) ); }
87 bool operator==(
const Extent2<T> &r)
const {
return ( (tx1_==r.tx1_)&&(tx2_==r.tx2_)&&(ty1_==r.ty1_)&&(ty2_==r.ty2_) ); }
95 bool isIn(
const Vector2<T> &v)
const {
return ((v.
x()>=tx1_)&&(v.
x()<=tx2_)&&(v.
y()>=ty1_)&&(v.
y()<=ty2_)); }
98 if ( (r.tx1_>=tx1_) && (r.tx2_<=tx2_) && (r.ty1_>=ty1_) && (r.ty2_<=ty2_) )
return true;
103 return ((v.
x()>=tx1_-tol)&&(v.
x()<=tx2_+tol)&&(v.
y()>=ty1_-tol)&&(v.
y()<=ty2_+tol));
107 if ( (r.tx1_>=tx1_-tol) && (r.tx2_<=tx2_+tol) && (r.ty1_>=ty1_-tol) && (r.ty2_<=ty2_+tol) )
return true;
112 if ((r.tx2_<tx1_) || (r.tx1_>tx2_) ||
113 (r.ty2_<ty1_) || (r.ty1_>ty2_))
return false;
118 if ((r.tx2_<tx1_-tol) || (r.tx1_>tx2_+tol) ||
119 (r.ty2_<ty1_-tol) || (r.ty1_>ty2_+tol))
return false;
148 void width(
const T &t) { tx2_ = tx1_ + t; }
150 void height(
const T &t) { ty2_ = ty1_ + t; }
182 Extent2<T> out(std::max<T>(tx1_,r.tx1_),std::min<T>(tx2_,r.tx2_),std::max<T>(ty1_,r.ty1_),std::min<T>(ty2_,r.ty2_));
187 tx1_ = std::min<T>(tx1_,r.tx1_);
188 tx2_ = std::max<T>(tx2_,r.tx2_);
189 ty1_ = std::min<T>(ty1_,r.ty1_);
190 ty2_ = std::max<T>(ty2_,r.ty2_);
195 tx1_ = std::min<T>(tx1_,v.
x());
196 tx2_ = std::max<T>(tx2_,v.
x());
197 ty1_ = std::min<T>(ty1_,v.
y());
198 ty2_ = std::max<T>(ty2_,v.
y());
215 const Extent2<T> &
expand(
const T &tol) { tx1_ -= tol; tx2_ += tol; ty1_ -= tol; ty2_ += tol;
return *
this; }
245 T pbound(
const T &min,
const T &v,
const T &max)
const {
return std::min(std::max(v,min),max); }
2D cartesian region in space.
Definition extent2.h:12
T & ry1()
Access reference to the minimum y extent.
Definition extent2.h:129
Extent2< T > operator+(const Vector2< T > &v) const
Binary addition operator, returns a Extent2 offset by v.
Definition extent2.h:176
T volume() const
Returns the volume of the extent assuming unit depth ( width() * height()).
Definition extent2.h:77
bool intersects(const Extent2< T > &r) const
Returns true if Extent2 r intersects (inclusive) the Extent2.
Definition extent2.h:111
const Extent2< T > & expandToInclude(const Extent2< T > &r)
Expands the extent of this Extent2 as necessary to completely include r.
Definition extent2.h:186
T & ry2()
Access reference to the maximum y extent.
Definition extent2.h:131
bool operator!=(const Extent2< T > &r) const
Comparison operator, no tolerance applied.
Definition extent2.h:89
static constexpr Extent2< T > nothing()
Static function returning object with maximum negative size, useful for calculating bounds.
Definition extent2.h:29
Vector2< T > c12() const
Returns one of the four characteristic corners of the 2D extent.
Definition extent2.h:63
Vector2< T > c22() const
Returns one of the four characteristic corners of the 2D extent.
Definition extent2.h:67
Vector2< T > size() const
Returns the size of the Extent2, the width() and height() encoded as a Vector2.
Definition extent2.h:73
Vector2< T > c11() const
Returns one of the four characteristic corners of the 2D extent.
Definition extent2.h:61
Extent2< T > expandedToInclude(const Vector2< T > &v) const
Returns a Extent2 expanded to include point v..
Definition extent2.h:208
Extent2< T > intersectedWith(const Extent2< T > &r) const
Definition extent2.h:181
T diagonal() const
Returns the length of the diagonal from the lower bound to the upper bound.
Definition extent2.h:79
T & rx1()
Access reference to the minimum x extent.
Definition extent2.h:125
const T & dof2(uint32 u) const
Returns the upper bound of degree-of-freedom dof.
Definition extent2.h:48
void lowerBound(const Vector2< T > &v)
Sets the lower bound of the Extent2, leaving the upper bound alone.
Definition extent2.h:160
const Extent2< T > & expandToInclude(const Vector2< T > &v)
Expands the extent of this Extent2 as necessary to completely include point v.
Definition extent2.h:194
Extent2(const Vector2< T > &v11, const Vector2< T > &v22)
Explicit constructor, given the lower and upper bounds as two Vector2.
Definition extent2.h:24
const T & y1() const
Returns the lower y-bound.
Definition extent2.h:37
Extent2< T > biggerBy(const T &fact) const
Definition extent2.h:236
Vector2< T > lowerBound() const
Returns the lower bound of the Extent2 (minimum x and y corner).
Definition extent2.h:69
Vector2< T > c21() const
Returns one of the four characteristic corners of the 2D extent.
Definition extent2.h:65
T & rdof1(uint32 u)
Reference access to lower bound of degree-of-freedom dof.
Definition extent2.h:133
const T & y2() const
Returns the upper y-bound.
Definition extent2.h:39
void upperBound(const Vector2< T > &v)
Sets the upper bound of the Extent2, leaving the lower bound alone.
Definition extent2.h:162
bool tolIntersects(const Extent2< T > &r, const T &tol) const
Returns true if Extent2 r intersects (inclusive) the Extent2 with an added tolerance factor.
Definition extent2.h:117
const T & x2() const
Returns the upper x-bound.
Definition extent2.h:35
void c11(const Vector2< T > &v)
Sets one of the four characteristic corners of the extent, leaving the other two values alone.
Definition extent2.h:152
const T & dof1(uint32 u) const
Returns the lower bound of degree-of-freedom dof.
Definition extent2.h:41
Extent2< T > expandedToInclude(const Extent2< T > &r) const
Returns a Extent2 expanded to completely include r.
Definition extent2.h:202
Extent2(const Extent2< T > &r)
Copy constructor.
Definition extent2.h:26
Vector2< T > centroid() const
Returns the centroid of the Extent2 as a Vector2.
Definition extent2.h:59
Extent2< T > center(const Vector2< T > &v) const
Returns a Extent2 centered about point v.
Definition extent2.h:229
T width() const
Returns the size of the x-extent (x2-x1)
Definition extent2.h:55
bool isIn(const Extent2< T > &r) const
Returns true Extent2 v is inside (inclusive) the Extent2.
Definition extent2.h:97
bool tolIsIn(const Vector2< T > &v, const T &tol) const
Returns true if point v is inside (inclusive) the Extent2 with an added tolerance factor.
Definition extent2.h:102
bool operator<(const Extent2< T > &r) const
Comparison operator, using area() as a metric.
Definition extent2.h:91
bool tolIsEmpty(const double &tol=limits< double >::epsilon() *100) const
Returns true if the area of the Extent2 is <= 0 with a tolerance.
Definition extent2.h:83
void size(const Vector2< T > &v)
Sets the size of the Extent2 by moving the maximum x and y extents, leaving the minimum alone.
Definition extent2.h:164
Extent2< T > expanded(const T &tol) const
Definition extent2.h:218
const Extent2< T > & operator+=(const Vector2< T > &v)
In place addition operator, offsets the exent by v.
Definition extent2.h:170
void height(const T &t)
Sets the height of the Extent2 by moving the maximum y extent, leaving the minimum alone.
Definition extent2.h:150
T & rdof2(uint32 u)
Reference access to lower bound of degree-of-freedom dof.
Definition extent2.h:140
bool operator==(const Extent2< T > &r) const
Comparison operator, no tolerance applied.
Definition extent2.h:87
void c22(const Vector2< T > &v)
Sets one of the four characteristic corners of the extent, leaving the other two values alone.
Definition extent2.h:158
bool isIn(const Vector2< T > &v) const
Returns true if point v is inside (inclusive) the Extent2.
Definition extent2.h:95
Extent2(const T &x1, const T &x2, const T &y1, const T &y2)
Explicit constructor, given the x and y extents.
Definition extent2.h:22
const Extent2< T > & expand(const T &tol)
Definition extent2.h:215
Extent2()
Default constructor, no data initialization.
Definition extent2.h:19
bool tolIsIn(const Extent2< T > &r, const T &tol) const
Returns true Extent2 v is inside (inclusive) the Extent2 with an added tolerance factor.
Definition extent2.h:106
Vector2< T > upperBound() const
Returns the upper bound of the Extent2 (maximum x and y corner).
Definition extent2.h:71
const Extent2< T > & operator-=(const Vector2< T > &v)
In place subtraction operator, offsets the exent by -v.
Definition extent2.h:172
Vector2< T > bound(const Vector2< T > &v) const
Forces the point v to fall within the Extent2, by clamping the x and y values to fall within it's ext...
Definition extent2.h:166
T & rx2()
Access reference to the maximum x extent.
Definition extent2.h:127
void c21(const Vector2< T > &v)
Sets one of the four characteristic corners of the extent, leaving the other two values alone.
Definition extent2.h:156
void width(const T &t)
Sets the width of the Extent2 by moving the maximum x extent, leaving the minimum alone.
Definition extent2.h:148
T height() const
Return sthe size of the y-extent (y2-y1)
Definition extent2.h:57
void c12(const Vector2< T > &v)
Sets one of the four characteristic corners of the extent, leaving the other two values alone.
Definition extent2.h:154
const T & x1() const
Returns the lower x-bound.
Definition extent2.h:33
T area() const
Returns the width()*height() - could be negative.
Definition extent2.h:75
bool isEmpty() const
Returns true if the area of the Extent2 is <= 0.
Definition extent2.h:81
bool operator>(const Extent2< T > &r) const
Comparison operator, using area() as a metric.
Definition extent2.h:93
Extent2< T > operator-(const Vector2< T > &v) const
Binary subtraction operator, returns a Extent2 offset by -v.
Definition extent2.h:178
const Extent2< T > & center(const Vector2< T > &v)
Centers this Extent2 about point v.
Definition extent2.h:220
2D vector utility class.
Definition vect.h:34
constexpr const T & x() const
X component access.
Definition vect.h:58
constexpr const T & y() const
Y component access.
Definition vect.h:60
debug checked shorthand for std::numeric_limits<T>::
Definition limit.h:25
2D and 3D vector utility classes.