17 Extent2() { tx1_ = tx2_ = ty1_ = ty2_ = initVal<T>(); }
32 const T &
x1()
const {
return tx1_; }
34 const T &
x2()
const {
return tx2_; }
36 const T &
y1()
const {
return ty1_; }
38 const T &
y2()
const {
return ty2_; }
54 T
width()
const {
return (tx2_-tx1_); }
56 T
height()
const {
return (ty2_-ty1_); }
80 bool isEmpty()
const {
return( (tx1_>=tx2_) || (ty1_>=ty2_) ); }
86 bool operator==(
const Extent2<T> &r)
const {
return ( (tx1_==r.tx1_)&&(tx2_==r.tx2_)&&(ty1_==r.ty1_)&&(ty2_==r.ty2_) ); }
94 bool isIn(
const Vector2<T> &v)
const {
return ((v.
x()>=tx1_)&&(v.
x()<=tx2_)&&(v.
y()>=ty1_)&&(v.
y()<=ty2_)); }
97 if ( (r.tx1_>=tx1_) && (r.tx2_<=tx2_) && (r.ty1_>=ty1_) && (r.ty2_<=ty2_) )
return true;
102 return ((v.
x()>=tx1_-tol)&&(v.
x()<=tx2_+tol)&&(v.
y()>=ty1_-tol)&&(v.
y()<=ty2_+tol));
106 if ( (r.tx1_>=tx1_-tol) && (r.tx2_<=tx2_+tol) && (r.ty1_>=ty1_-tol) && (r.ty2_<=ty2_+tol) )
return true;
111 if ((r.tx2_<tx1_) || (r.tx1_>tx2_) ||
112 (r.ty2_<ty1_) || (r.ty1_>ty2_))
return false;
117 if ((r.tx2_<tx1_-tol) || (r.tx1_>tx2_+tol) ||
118 (r.ty2_<ty1_-tol) || (r.ty1_>ty2_+tol))
return false;
147 void width(
const T &t) { tx2_ = tx1_ + t; }
149 void height(
const T &t) { ty2_ = ty1_ + t; }
181 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_));
186 tx1_ = std::min<T>(tx1_,r.tx1_);
187 tx2_ = std::max<T>(tx2_,r.tx2_);
188 ty1_ = std::min<T>(ty1_,r.ty1_);
189 ty2_ = std::max<T>(ty2_,r.ty2_);
194 tx1_ = std::min<T>(tx1_,v.
x());
195 tx2_ = std::max<T>(tx2_,v.
x());
196 ty1_ = std::min<T>(ty1_,v.
y());
197 ty2_ = std::max<T>(ty2_,v.
y());
214 const Extent2<T> &
expand(
const T &tol) { tx1_ -= tol; tx2_ += tol; ty1_ -= tol; ty2_ += tol;
return *
this; }
244 T pbound(
const T &min,
const T &v,
const T &max)
const {
return std::min(std::max(v,min),max); }
Vector2< T > upperBound() const
Returns the upper bound of the Extent2 (maximum x and y corner).
Definition: extent2.h:70
const Extent2< T > & expandToInclude(const Vector2< T > &v)
Expands the extent of this Extent2 as necessary to completely include point v.
Definition: extent2.h:193
const Extent2< T > & expandToInclude(const Extent2< T > &r)
Expands the extent of this Extent2 as necessary to completely include r.
Definition: extent2.h:185
const Extent2< T > & operator+=(const Vector2< T > &v)
In place addition operator, offsets the exent by v.
Definition: extent2.h:169
const Extent2< T > & expand(const T &tol)
Definition: extent2.h:214
static constexpr Extent2< T > nothing()
Static function returning object with maximum negative size, useful for calculating bounds.
Definition: extent2.h:28
const T & y1() const
Returns the lower y-bound.
Definition: extent2.h:36
bool operator!=(const Extent2< T > &r) const
Comparison operator, no tolerance applied.
Definition: extent2.h:88
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:165
Extent2< T > center(const Vector2< T > &v) const
Returns a Extent2 centered about point v.
Definition: extent2.h:228
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:105
const Extent2< T > & center(const Vector2< T > &v)
Centers this Extent2 about point v.
Definition: extent2.h:219
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:163
T & rx2()
Access reference to the maximum x extent.
Definition: extent2.h:126
T diagonal() const
Returns the length of the diagonal from the lower bound to the upper bound.
Definition: extent2.h:78
T & rdof1(UInt u)
Reference access to lower bound of degree-of-freedom dof.
Definition: extent2.h:132
Extent2< T > expandedToInclude(const Extent2< T > &r) const
Returns a Extent2 expanded to completely include r.
Definition: extent2.h:201
2D and 3D vector utility classes.
const T & dof2(UInt u) const
Returns the upper bound of degree-of-freedom dof.
Definition: extent2.h:47
bool operator<(const Extent2< T > &r) const
Comparison operator, using area() as a metric.
Definition: extent2.h:90
Extent2()
Default constructor, no data initialization.
Definition: extent2.h:19
bool isIn(const Vector2< T > &v) const
Returns true if point v is inside (inclusive) the Extent2.
Definition: extent2.h:94
T width() const
Returns the size of the x-extent (x2-x1)
Definition: extent2.h:54
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:101
Vector2< T > lowerBound() const
Returns the lower bound of the Extent2 (minimum x and y corner).
Definition: extent2.h:68
T & ry1()
Access reference to the minimum y extent.
Definition: extent2.h:128
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:155
Vector2< T > c11() const
Returns one of the four characteristic corners of the 2D extent.
Definition: extent2.h:60
Extent2(const Extent2< T > &r)
Copy constructor.
Definition: extent2.h:26
T & ry2()
Access reference to the maximum y extent.
Definition: extent2.h:130
debug checked shorthand for std::numeric_limits<T>::
Definition: limit.h:25
unsigned int UInt
unsigned 32 bit
Definition: basedef.h:31
Extent2< T > biggerBy(const T &fact) const
Definition: extent2.h:235
Extent2< T > expanded(const T &tol) const
Definition: extent2.h:217
Vector2< T > c21() const
Returns one of the four characteristic corners of the 2D extent.
Definition: extent2.h:64
Extent2< Double > DExtent2
Definition: extent2.h:251
Extent2(const Vector2< T > &v11, const Vector2< T > &v22)
Explicit constructor, given the lower and upper bounds as two Vector2.
Definition: extent2.h:24
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:157
const T & dof1(UInt u) const
Returns the lower bound of degree-of-freedom dof.
Definition: extent2.h:40
const T & y() const
Y component access.
Definition: vect.h:56
bool operator==(const Extent2< T > &r) const
Comparison operator, no tolerance applied.
Definition: extent2.h:86
void height(const T &t)
Sets the height of the Extent2 by moving the maximum y extent, leaving the minimum alone.
Definition: extent2.h:149
Extent2< T > operator+(const Vector2< T > &v) const
Binary addition operator, returns a Extent2 offset by v.
Definition: extent2.h:175
2D vector utility class.
Definition: vect.h:31
Vector2< T > c22() const
Returns one of the four characteristic corners of the 2D extent.
Definition: extent2.h:66
bool intersects(const Extent2< T > &r) const
Returns true if Extent2 r intersects (inclusive) the Extent2.
Definition: extent2.h:110
Extent2< UInt > UExtent2
Definition: extent2.h:254
T & rx1()
Access reference to the minimum x extent.
Definition: extent2.h:124
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:153
Vector2< T > c12() const
Returns one of the four characteristic corners of the 2D extent.
Definition: extent2.h:62
const Extent2< T > & operator-=(const Vector2< T > &v)
In place subtraction operator, offsets the exent by -v.
Definition: extent2.h:171
bool operator>(const Extent2< T > &r) const
Comparison operator, using area() as a metric.
Definition: extent2.h:92
const T & y2() const
Returns the upper y-bound.
Definition: extent2.h:38
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:116
void upperBound(const Vector2< T > &v)
Sets the upper bound of the Extent2, leaving the lower bound alone.
Definition: extent2.h:161
bool isEmpty() const
Returns true if the area of the Extent2 is <= 0.
Definition: extent2.h:80
bool isIn(const Extent2< T > &r) const
Returns true Extent2 v is inside (inclusive) the Extent2.
Definition: extent2.h:96
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:151
2D cartesian region in space.
Definition: extent2.h:12
Extent2< T > intersectedWith(const Extent2< T > &r) const
Definition: extent2.h:180
const T & x() const
X component access.
Definition: vect.h:54
T area() const
Returns the width()*height() - could be negative.
Definition: extent2.h:74
Extent2< T > operator-(const Vector2< T > &v) const
Binary subtraction operator, returns a Extent2 offset by -v.
Definition: extent2.h:177
Vector2< T > centroid() const
Returns the centroid of the Extent2 as a Vector2.
Definition: extent2.h:58
T & rdof2(UInt u)
Reference access to lower bound of degree-of-freedom dof.
Definition: extent2.h:139
T volume() const
Returns the volume of the extent assuming unit depth ( width() * height()).
Definition: extent2.h:76
const T & x2() const
Returns the upper x-bound.
Definition: extent2.h:34
Extent2< Float > FExtent2
Definition: extent2.h:252
void width(const T &t)
Sets the width of the Extent2 by moving the maximum x extent, leaving the minimum alone.
Definition: extent2.h:147
Vector2< T > size() const
Returns the size of the Extent2, the width() and height() encoded as a Vector2.
Definition: extent2.h:72
void lowerBound(const Vector2< T > &v)
Sets the lower bound of the Extent2, leaving the upper bound alone.
Definition: extent2.h:159
T height() const
Return sthe size of the y-extent (y2-y1)
Definition: extent2.h:56
Extent2< Int > IExtent2
Definition: extent2.h:253
const T & x1() const
Returns the lower x-bound.
Definition: extent2.h:32
Extent2< T > expandedToInclude(const Vector2< T > &v) const
Returns a Extent2 expanded to include point v..
Definition: extent2.h:207
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:82