30 const T &
x1()
const {
return tx1_; }
32 const T &
x2()
const {
return tx2_; }
34 const T &
y1()
const {
return ty1_; }
36 const T &
y2()
const {
return ty2_; }
38 const T &
dof1(uint32 u)
const {
45 const T &
dof2(uint32 u)
const {
52 T
width()
const {
return (tx2_-tx1_); }
54 T
height()
const {
return (ty2_-ty1_); }
78 bool isEmpty()
const {
return( (tx1_>=tx2_) || (ty1_>=ty2_) ); }
84 bool operator==(
const Extent2<T> &r)
const {
return ( (tx1_==r.tx1_)&&(tx2_==r.tx2_)&&(ty1_==r.ty1_)&&(ty2_==r.ty2_) ); }
92 bool isIn(
const Vector2<T> &v)
const {
return ((v.
x()>=tx1_)&&(v.
x()<=tx2_)&&(v.
y()>=ty1_)&&(v.
y()<=ty2_)); }
95 if ( (r.tx1_>=tx1_) && (r.tx2_<=tx2_) && (r.ty1_>=ty1_) && (r.ty2_<=ty2_) )
return true;
100 return ((v.
x()>=tx1_-tol)&&(v.
x()<=tx2_+tol)&&(v.
y()>=ty1_-tol)&&(v.
y()<=ty2_+tol));
104 if ( (r.tx1_>=tx1_-tol) && (r.tx2_<=tx2_+tol) && (r.ty1_>=ty1_-tol) && (r.ty2_<=ty2_+tol) )
return true;
109 if ((r.tx2_<tx1_) || (r.tx1_>tx2_) ||
110 (r.ty2_<ty1_) || (r.ty1_>ty2_))
return false;
115 if ((r.tx2_<tx1_-tol) || (r.tx1_>tx2_+tol) ||
116 (r.ty2_<ty1_-tol) || (r.ty1_>ty2_+tol))
return false;
145 void width(
const T &t) { tx2_ = tx1_ + t; }
147 void height(
const T &t) { ty2_ = ty1_ + t; }
179 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_));
184 tx1_ = std::min<T>(tx1_,r.tx1_);
185 tx2_ = std::max<T>(tx2_,r.tx2_);
186 ty1_ = std::min<T>(ty1_,r.ty1_);
187 ty2_ = std::max<T>(ty2_,r.ty2_);
192 tx1_ = std::min<T>(tx1_,v.
x());
193 tx2_ = std::max<T>(tx2_,v.
x());
194 ty1_ = std::min<T>(ty1_,v.
y());
195 ty2_ = std::max<T>(ty2_,v.
y());
212 const Extent2<T> &
expand(
const T &tol) { tx1_ -= tol; tx2_ += tol; ty1_ -= tol; ty2_ += tol;
return *
this; }
242 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:126
Extent2< T > operator+(const Vector2< T > &v) const
Binary addition operator, returns a Extent2 offset by v.
Definition extent2.h:173
T volume() const
Returns the volume of the extent assuming unit depth ( width() * height()).
Definition extent2.h:74
bool intersects(const Extent2< T > &r) const
Returns true if Extent2 r intersects (inclusive) the Extent2.
Definition extent2.h:108
const Extent2< T > & expandToInclude(const Extent2< T > &r)
Expands the extent of this Extent2 as necessary to completely include r.
Definition extent2.h:183
T & ry2()
Access reference to the maximum y extent.
Definition extent2.h:128
bool operator!=(const Extent2< T > &r) const
Comparison operator, no tolerance applied.
Definition extent2.h:86
static constexpr Extent2< T > nothing()
Definition extent2.h:26
Vector2< T > c12() const
Returns one of the four characteristic corners of the 2D extent.
Definition extent2.h:60
Vector2< T > c22() const
Returns one of the four characteristic corners of the 2D extent.
Definition extent2.h:64
Vector2< T > size() const
Returns the size of the Extent2, the width() and height() encoded as a Vector2.
Definition extent2.h:70
Vector2< T > c11() const
Returns one of the four characteristic corners of the 2D extent.
Definition extent2.h:58
Extent2< T > expandedToInclude(const Vector2< T > &v) const
Returns a Extent2 expanded to include point v..
Definition extent2.h:205
Extent2< T > intersectedWith(const Extent2< T > &r) const
Definition extent2.h:178
T diagonal() const
Returns the length of the diagonal from the lower bound to the upper bound.
Definition extent2.h:76
T & rx1()
Access reference to the minimum x extent.
Definition extent2.h:122
const T & dof2(uint32 u) const
Returns the upper bound of degree-of-freedom dof.
Definition extent2.h:45
void lowerBound(const Vector2< T > &v)
Sets the lower bound of the Extent2, leaving the upper bound alone.
Definition extent2.h:157
const Extent2< T > & expandToInclude(const Vector2< T > &v)
Expands the extent of this Extent2 as necessary to completely include point v.
Definition extent2.h:191
Extent2(const Vector2< T > &v11, const Vector2< T > &v22)
Explicit constructor, given the lower and upper bounds as two Vector2.
Definition extent2.h:23
const T & y1() const
Returns the lower y-bound.
Definition extent2.h:34
Extent2< T > biggerBy(const T &fact) const
Definition extent2.h:233
Vector2< T > lowerBound() const
Returns the lower bound of the Extent2 (minimum x and y corner).
Definition extent2.h:66
Vector2< T > c21() const
Returns one of the four characteristic corners of the 2D extent.
Definition extent2.h:62
T & rdof1(uint32 u)
Reference access to lower bound of degree-of-freedom dof.
Definition extent2.h:130
const T & y2() const
Returns the upper y-bound.
Definition extent2.h:36
void upperBound(const Vector2< T > &v)
Sets the upper bound of the Extent2, leaving the lower bound alone.
Definition extent2.h:159
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:114
const T & x2() const
Returns the upper x-bound.
Definition extent2.h:32
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:149
const T & dof1(uint32 u) const
Returns the lower bound of degree-of-freedom dof.
Definition extent2.h:38
Extent2< T > expandedToInclude(const Extent2< T > &r) const
Returns a Extent2 expanded to completely include r.
Definition extent2.h:199
Vector2< T > centroid() const
Returns the centroid of the Extent2 as a Vector2.
Definition extent2.h:56
Extent2< T > center(const Vector2< T > &v) const
Returns a Extent2 centered about point v.
Definition extent2.h:226
T width() const
Returns the size of the x-extent (x2-x1)
Definition extent2.h:52
bool isIn(const Extent2< T > &r) const
Returns true Extent2 v is inside (inclusive) the Extent2.
Definition extent2.h:94
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:99
bool operator<(const Extent2< T > &r) const
Comparison operator, using area() as a metric.
Definition extent2.h:88
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:80
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:161
Extent2< T > expanded(const T &tol) const
Definition extent2.h:215
const Extent2< T > & operator+=(const Vector2< T > &v)
In place addition operator, offsets the exent by v.
Definition extent2.h:167
void height(const T &t)
Sets the height of the Extent2 by moving the maximum y extent, leaving the minimum alone.
Definition extent2.h:147
T & rdof2(uint32 u)
Reference access to lower bound of degree-of-freedom dof.
Definition extent2.h:137
bool operator==(const Extent2< T > &r) const
Comparison operator, no tolerance applied.
Definition extent2.h:84
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:155
bool isIn(const Vector2< T > &v) const
Returns true if point v is inside (inclusive) the Extent2.
Definition extent2.h:92
Extent2(const T &x1, const T &x2, const T &y1, const T &y2)
Explicit constructor, given the x and y extents.
Definition extent2.h:21
const Extent2< T > & expand(const T &tol)
Definition extent2.h:212
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:103
Vector2< T > upperBound() const
Returns the upper bound of the Extent2 (maximum x and y corner).
Definition extent2.h:68
const Extent2< T > & operator-=(const Vector2< T > &v)
In place subtraction operator, offsets the exent by -v.
Definition extent2.h:169
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:163
T & rx2()
Access reference to the maximum x extent.
Definition extent2.h:124
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:153
void width(const T &t)
Sets the width of the Extent2 by moving the maximum x extent, leaving the minimum alone.
Definition extent2.h:145
T height() const
Return sthe size of the y-extent (y2-y1)
Definition extent2.h:54
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:151
const T & x1() const
Returns the lower x-bound.
Definition extent2.h:30
T area() const
Returns the width()*height() - could be negative.
Definition extent2.h:72
bool isEmpty() const
Returns true if the area of the Extent2 is <= 0.
Definition extent2.h:78
bool operator>(const Extent2< T > &r) const
Comparison operator, using area() as a metric.
Definition extent2.h:90
Extent2< T > operator-(const Vector2< T > &v) const
Binary subtraction operator, returns a Extent2 offset by -v.
Definition extent2.h:175
constexpr Extent2()=default
Default constructor, no data initialization.
const Extent2< T > & center(const Vector2< T > &v)
Centers this Extent2 about point v.
Definition extent2.h:217
2D vector utility class.
Definition vect.h:32
constexpr const T & x() const
X component access.
Definition vect.h:53
constexpr const T & y() const
Y component access.
Definition vect.h:55
debug checked shorthand for std::numeric_limits<T>::
Definition limit.h:25
2D and 3D vector utility classes.