TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::Rect2D Class Reference

#include <Rect2D.h>

Public Member Functions

 Rect2D (const Any &any)
 
Any toAny () const
 
 Rect2D (const Rect2D &r)
 
 Rect2D ()
 
bool isEmpty () const
 
 Rect2D (const Vector2 &wh)
 
Vector2 extent () const
 
Point2 randomPoint () const
 Uniformly random point on the interior. More...
 
float width () const
 
float height () const
 
float x0 () const
 
float x1 () const
 
float y0 () const
 
float y1 () const
 
Point2 x0y0 () const
 
Point2 x1y0 () const
 
Point2 x0y1 () const
 
Point2 x1y1 () const
 
Vector2 wh () const
 
Point2 center () const
 
float area () const
 
bool isFinite () const
 
Rect2D lerp (const Rect2D &other, float alpha) const
 
bool contains (const Point2 &v) const
 
bool contains (const Rect2D &r) const
 
bool intersects (const Rect2D &r) const
 
bool intersectsOrTouches (const Rect2D &r) const
 
Rect2D operator* (float s) const
 
Rect2D operator* (const Vector2 &s) const
 
Rect2D operator/ (float s) const
 
Rect2D operator/ (const Vector2 &s) const
 
Rect2D operator+ (const Vector2 &v) const
 
Rect2D operator- (const Vector2 &v) const
 
bool operator== (const Rect2D &other) const
 
bool operator!= (const Rect2D &other) const
 
void serialize (class BinaryOutput &b) const
 
void deserialize (class BinaryInput &b)
 
Point2 corner (int i) const
 
Rect2D border (float delta) const
 
Rect2D expand (float delta) const
 
void merge (const Rect2D &other)
 
 Rect2D (const Rect2D &a, const Rect2D &b)
 
template<class T >
void clip (const Array< T > &inPoly, Array< T > &outPoly) const
 
Rect2D largestCenteredSubRect (float ww, float hh) const
 
Rect2D intersect (const Rect2D &other) const
 

Static Public Member Functions

static const Rect2Dempty ()
 
static Rect2D xyxy (float x0, float y0, float x1, float y1)
 
static Rect2D xyxy (const Point2 &v0, const Point2 &v1)
 
static Rect2D xywh (float x, float y, float w, float h)
 
static Rect2D xywh (const Point2 &v, const Vector2 &w)
 
static Rect2D inf ()
 

Private Member Functions

 Rect2D (bool)
 

Static Private Member Functions

template<class T >
static bool clipSide2D (const float p, bool clipGreater, int axis, const Array< T > &inPoly, Array< T > &outPoly)
 

Private Attributes

Point2 min
 
Point2 max
 

Detailed Description

If you are using this class for pixel rectangles, keep in mind that the last pixel you can draw to is at x0() + width() - 1.

Constructor & Destructor Documentation

G3D::Rect2D::Rect2D ( bool  )
inlineprivate

Uninitialized constructor

121 {}
G3D::Rect2D::Rect2D ( const Any any)
Parameters
anyMust either Rect2D::xywh(#, #, #, #) or Rect2D::xyxy(#, #, #, #)
41  {
42  if (any.name() == "Rect2D::empty" || any.name() == "AABox2D::empty") {
43  *this = empty();
44  return;
45  }
46 
47  any.verifyName("Rect2D::xyxy", "Rect2D::xywh");
48  any.verifyType(Any::ARRAY);
49  any.verifySize(4);
50  if (any.name() == "Rect2D::xywh") {
51  *this = Rect2D::xywh(any[0], any[1], any[2], any[3]);
52  } else {
53  *this = Rect2D::xyxy(any[0], any[1], any[2], any[3]);
54  }
55 }
bool any(float x)
Definition: g3dmath.h:424
Definition: Any.h:187
static const Rect2D & empty()
Definition: Rect2D.cpp:22
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
static Rect2D xywh(float x, float y, float w, float h)
Definition: Rect2D.h:260

+ Here is the call graph for this function:

G3D::Rect2D::Rect2D ( const Rect2D r)
inline
130 : min(r.min), max(r.max) {}
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
G3D::Rect2D::Rect2D ( )
inline

Creates the empty set rectangle.

134 : min(fnan(), fnan()), max(fnan(), fnan()) {}
float fnan()
Definition: g3dmath.cpp:82
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
G3D::Rect2D::Rect2D ( const Vector2 wh)
inline

Creates a rectangle at 0,0 with the given width and height

144 : min(0, 0), max(wh.x, wh.y) {}
Vector2 wh() const
Definition: Rect2D.h:211
float y
Definition: Vector2.h:50
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
G3D::Rect2D::Rect2D ( const Rect2D a,
const Rect2D b 
)
inline

Computes a rectangle that contains both a and b. Note that even if or has zero area, its origin will be included.

397  {
398  *this = a;
399  merge(b);
400  }
void merge(const Rect2D &other)
Definition: Rect2D.h:386

+ Here is the call graph for this function:

Member Function Documentation

float G3D::Rect2D::area ( ) const
inline
223  {
224  return width() * height();
225  }
float width() const
Definition: Rect2D.h:160
float height() const
Definition: Rect2D.h:168

+ Here is the call graph for this function:

Rect2D G3D::Rect2D::border ( float  delta) const
inline
Deprecated:
See also
expand()
359  {
360  return Rect2D::xywh(x0() + delta,
361  y0() + delta,
362  width() - 2.0f * delta,
363  height() - 2.0f * delta);
364  }
float y0() const
Definition: Rect2D.h:184
float width() const
Definition: Rect2D.h:160
float height() const
Definition: Rect2D.h:168
float x0() const
Definition: Rect2D.h:176
static Rect2D xywh(float x, float y, float w, float h)
Definition: Rect2D.h:260

+ Here is the call graph for this function:

Point2 G3D::Rect2D::center ( ) const
inline
219  {
220  return (max + min) * 0.5;
221  }
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
template<class T >
void G3D::Rect2D::clip ( const Array< T > &  inPoly,
Array< T > &  outPoly 
) const
inline

Clips so that the rightmost point of the outPoly is at rect.x1 (e.g. a 800x600 window produces rightmost point 799, not 800). The results are suitable for pixel rendering if iRounded. Templated so that it will work for Vector2,3,4 (the z and w components are interpolated linearly). The template parameter must define T.lerp and contain x and y components.

If the entire polygon is clipped by a single side, the result will be empty. The result might also have zero area but not be empty.

412  {
413 
414  const bool greaterThan = true;
415  const bool lessThan = false;
416  const int X = 0;
417  const int Y = 1;
418 
419  Array<T> temp;
420 
421  bool entirelyClipped =
422  clipSide2D(x0(), lessThan, X, inPoly, temp) ||
423  clipSide2D(x1(), greaterThan, X, temp, outPoly) ||
424  clipSide2D(y0(), lessThan, Y, outPoly, temp) ||
425  clipSide2D(y1(), greaterThan, Y, temp, outPoly);
426 
427  if (entirelyClipped) {
428  outPoly.clear();
429  }
430  }
float y0() const
Definition: Rect2D.h:184
#define X
Definition: CollisionDetection.cpp:2281
static bool clipSide2D(const float p, bool clipGreater, int axis, const Array< T > &inPoly, Array< T > &outPoly)
Definition: Rect2D.h:53
float y1() const
Definition: Rect2D.h:188
float x0() const
Definition: Rect2D.h:176
void clear(bool shrink=true)
Definition: Array.h:407
float x1() const
Definition: Rect2D.h:180
#define Y
Definition: CollisionDetection.cpp:2282

+ Here is the call graph for this function:

template<class T >
static bool G3D::Rect2D::clipSide2D ( const float  p,
bool  clipGreater,
int  axis,
const Array< T > &  inPoly,
Array< T > &  outPoly 
)
inlinestaticprivate

Returns true if the whole polygon is clipped.

Parameters
pValue of the point
axisIndex [0 or 1] of the axis to clip along?
clipGreaterAre we clipping greater than or less than the line?
inPolyPolygon being clipped
outPolyThe clipped polygon
55  {
56 
57  outPoly.clear();
58  int i0 = -1;
59 
60  Vector2 pt1;
61  bool c1 = true;
62 
63  float negate = clipGreater ? -1 : 1;
64 
65  // Find a point that is not clipped
66  for (i0 = 0; (i0 < inPoly.length()) && c1; ++i0) {
67  pt1 = inPoly[i0];
68  c1 = (negate * pt1[axis]) < (negate * p);
69  }
70 
71  // We incremented i0 one time to many
72  --i0;
73 
74  if (c1) {
75  // We could not find an unclipped point
76  return true;
77  }
78 
79  outPoly.append(pt1);
80 
81  // for each point in inPoly,
82  // if the point is outside the side and the previous one was also outside, continue
83  // if the point is outside the side and the previous one was inside, cut the line
84  // if the point is inside the side and the previous one was also inside, append the points
85  // if the point is inside the side and the previous one was outside, cut the line
86  for (int i = 1; i <= inPoly.length(); ++i) {
87  T pt2 = inPoly[(i + i0) % inPoly.length()];
88  bool c2 = (negate * pt2[axis]) < (negate * p);
89 
90  if (c1 ^ c2) {
91 
92  if (!c1 && c2 && (i > 1)) {
93  // Unclipped to clipped trasition and not the first iteration
94  outPoly.append(pt1);
95  }
96 
97  // only one point is clipped, find where the line crosses the clipping plane
98 
99 
100  float alpha;
101  if (pt2[axis] == pt1[axis]) {
102  alpha = 0;
103  } else {
104  alpha = (p - pt1[axis]) / (pt2[axis] - pt1[axis]);
105  }
106  outPoly.append(pt1.lerp(pt2, alpha));
107  } else if (! (c1 || c2) && (i != 1)) {
108  // neither point is clipped (don't do this the first time
109  // because we appended the first pt before the loop)
110  outPoly.append(pt1);
111  }
112 
113  pt1 = pt2;
114  c1 = c2;
115  }
116 
117  return false;
118  }
static G3D::Matrix::T negate(G3D::Matrix::T x)
Definition: Matrix.cpp:8
int length() const
Definition: Array.h:438
void clear(bool shrink=true)
Definition: Array.h:407
void append(const T &value)
Definition: Array.h:583

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool G3D::Rect2D::contains ( const Point2 v) const
inline
275  {
276  // This will automatically return false if isEmpty()
277  return (v.x >= min.x) && (v.y >= min.y) && (v.x <= max.x) && (v.y <= max.y);
278  }
float y
Definition: Vector2.h:50
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
bool G3D::Rect2D::contains ( const Rect2D r) const
inline
280  {
281  // This will automatically return false if isEmpty()
282  return (min.x <= r.min.x) && (min.y <= r.min.y) &&
283  (max.x >= r.max.x) && (max.y >= r.max.y);
284  }
float y
Definition: Vector2.h:50
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
Point2 G3D::Rect2D::corner ( int  i) const
inline

Returns the corners in the order: (min,min), (max,min), (max,max), (min,max).

339  {
340  debugAssert(i >= 0 && i < 4);
341  switch (i & 3) {
342  case 0:
343  return Point2(min.x, min.y);
344  case 1:
345  return Point2(max.x, min.y);
346  case 2:
347  return Point2(max.x, max.y);
348  case 3:
349  return Point2(min.x, max.y);
350  default:
351  // Should never get here
352  return Point2(0, 0);
353  }
354  }
Vector2 Point2
Definition: Vector2.h:492
float y
Definition: Vector2.h:50
#define debugAssert(exp)
Definition: debugAssert.h:160
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the caller graph for this function:

void G3D::Rect2D::deserialize ( class BinaryInput b)
34  {
35  min.deserialize(b);
36  max.deserialize(b);
37 }
void deserialize(class BinaryInput &b)
Definition: Vector2.cpp:119
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

const Rect2D & G3D::Rect2D::empty ( )
static
22  {
23  static Rect2D r;
24  return r;
25 }
Rect2D()
Definition: Rect2D.h:134

+ Here is the caller graph for this function:

Rect2D G3D::Rect2D::expand ( float  delta) const
inline

Returns a new Rect2D that is bigger/smaller by the specified amount (negative is shrink.)

368  {
369  float newX = x0() - delta;
370  float newY = y0() - delta;
371  float newW = width() + 2.0f * delta;
372  float newH = height() + 2.0f * delta;
373 
374  if (newW < 0.0f) {
375  newX = (x0() + width()) / 2.0f;
376  newW = 0.0f;
377  }
378 
379  if (newH < 0.0f) {
380  newY = (y0() + height()) / 2.0f;
381  newH = 0.0f;
382  }
383  return Rect2D::xywh(newX, newY, newW, newH);
384  }
float y0() const
Definition: Rect2D.h:184
float width() const
Definition: Rect2D.h:160
float height() const
Definition: Rect2D.h:168
float x0() const
Definition: Rect2D.h:176
static Rect2D xywh(float x, float y, float w, float h)
Definition: Rect2D.h:260

+ Here is the call graph for this function:

Vector2 G3D::Rect2D::extent ( ) const
inline
146  {
147  if (isEmpty()) {
148  return Vector2::zero();
149  } else {
150  return max - min;
151  }
152  }
bool isEmpty() const
Definition: Rect2D.h:139
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
static const Vector2 & zero()
Definition: Vector2.cpp:67

+ Here is the call graph for this function:

float G3D::Rect2D::height ( ) const
inline
168  {
169  if (isEmpty()) {
170  return 0;
171  } else {
172  return max.y - min.y;
173  }
174  }
bool isEmpty() const
Definition: Rect2D.h:139
float y
Definition: Vector2.h:50
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Rect2D G3D::Rect2D::inf ( )
inlinestatic

Constructs a Rect2D with infinite boundaries. Use isFinite() to test either min or max.

271  {
272  return xyxy(Vector2::inf(), Vector2::inf());
273  }
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
static const Vector2 & inf()
Definition: Vector2.cpp:82

+ Here is the call graph for this function:

Rect2D G3D::Rect2D::intersect ( const Rect2D other) const
inline

Returns the overlap region between the two rectangles. This may have zero area if they do not intersect. See the two-Rect2D constructor and merge() for a way to compute a union-like rectangle.

460  {
461  if (intersects(other)) {
462  return Rect2D::xyxy(min.max(other.min), max.min(other.max));
463  } else {
464  return empty();
465  }
466  }
bool intersects(const Rect2D &r) const
Definition: Rect2D.h:289
Vector2 min(const Vector2 &v) const
Definition: Vector2.h:452
static const Rect2D & empty()
Definition: Rect2D.cpp:22
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
Vector2 max(const Vector2 &v) const
Definition: Vector2.h:458

+ Here is the call graph for this function:

bool G3D::Rect2D::intersects ( const Rect2D r) const
inline

True if there is non-zero area to the intersection between this and r. Note that two rectangles that are adjacent do not intersect because there is zero area to the overlap, even though one of them "contains" the corners of the other.

289  {
290  // This will automatically return false if isEmpty()
291  return (min.x < r.max.x) && (min.y < r.max.y) &&
292  (max.x > r.min.x) && (max.y > r.min.y);
293  }
float y
Definition: Vector2.h:50
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the caller graph for this function:

bool G3D::Rect2D::intersectsOrTouches ( const Rect2D r) const
inline

Like intersection, but counts the adjacent case as touching.

296  {
297  // This will automatically return false if isEmpty()
298  return (min.x <= r.max.x) && (min.y <= r.max.y) &&
299  (max.x >= r.min.x) && (max.y >= r.min.y);
300  }
float y
Definition: Vector2.h:50
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
bool G3D::Rect2D::isEmpty ( ) const
inline

Returns true if this is the empty set, which is distinct from a zero-area rectangle.

139  {
140  return min.isNaN() && max.isNaN();
141  }
bool isNaN() const
Definition: Vector2.h:95
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool G3D::Rect2D::isFinite ( ) const
inline
227  {
228  return (min.isFinite() && max.isFinite());
229  }
bool isFinite() const
Definition: Vector2.h:476
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

Rect2D G3D::Rect2D::largestCenteredSubRect ( float  ww,
float  hh 
) const
inline

Returns the largest, centered Rect2D that can fit inside this while maintaining the aspect ratio of x:y. Convenient for displaying images in odd-shaped windows.

437  {
438  float textureAspect = hh / ww;
439  float viewAspect = height() / width();
440 
441  if (viewAspect > textureAspect) {
442  // The view is too tall
443  float h = width() * textureAspect;
444  float y = (height() - h) / 2;
445  return Rect2D::xywh(0, y, width(), h) + corner(0);
446  } else {
447  // The view is too wide
448  float w = height() / textureAspect;
449  float x = (width() - w) / 2;
450  return Rect2D::xywh(x, 0, w, height()) + corner(0);
451  }
452  }
Point2 corner(int i) const
Definition: Rect2D.h:339
float width() const
Definition: Rect2D.h:160
float height() const
Definition: Rect2D.h:168
G3D::int16 y
Definition: Vector2int16.h:38
static Rect2D xywh(float x, float y, float w, float h)
Definition: Rect2D.h:260
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

Rect2D G3D::Rect2D::lerp ( const Rect2D other,
float  alpha 
) const
inline
231  {
232  Rect2D out(false);
233 
234  out.min = min.lerp(other.min, alpha);
235  out.max = max.lerp(other.max, alpha);
236 
237  return out;
238  }
Vector2 lerp(const Vector2 &v, float alpha) const
Definition: Vector2.h:133
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
Vector2 max(const Vector2 &v) const
Definition: Vector2.h:458
Rect2D()
Definition: Rect2D.h:134

+ Here is the call graph for this function:

void G3D::Rect2D::merge ( const Rect2D other)
inline
386  {
387  if (isEmpty()) {
388  *this = other;
389  } else if (! other.isEmpty()) {
390  min = min.min(other.min);
391  max = max.max(other.max);
392  }
393  }
Vector2 min(const Vector2 &v) const
Definition: Vector2.h:452
bool isEmpty() const
Definition: Rect2D.h:139
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
Vector2 max(const Vector2 &v) const
Definition: Vector2.h:458

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool G3D::Rect2D::operator!= ( const Rect2D other) const
inline
330  {
331  return (min != other.min) || (max != other.max);
332  }
Vector2 min(const Vector2 &v) const
Definition: Vector2.h:452
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
Vector2 max(const Vector2 &v) const
Definition: Vector2.h:458
Rect2D G3D::Rect2D::operator* ( float  s) const
inline
302  {
303  return xyxy(min.x * s, min.y * s, max.x * s, max.y * s);
304  }
float y
Definition: Vector2.h:50
float x
Definition: Vector2.h:49
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

Rect2D G3D::Rect2D::operator* ( const Vector2 s) const
inline
306  {
307  return xyxy(min * s, max * s);
308  }
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

Rect2D G3D::Rect2D::operator+ ( const Vector2 v) const
inline
318  {
319  return xyxy(min + v, max + v);
320  }
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

Rect2D G3D::Rect2D::operator- ( const Vector2 v) const
inline
322  {
323  return xyxy(min - v, max - v);
324  }
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

Rect2D G3D::Rect2D::operator/ ( float  s) const
inline
310  {
311  return xyxy(min / s, max / s);
312  }
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

Rect2D G3D::Rect2D::operator/ ( const Vector2 s) const
inline
314  {
315  return xyxy(min / s, max / s);
316  }
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

bool G3D::Rect2D::operator== ( const Rect2D other) const
inline
326  {
327  return (min == other.min) && (max == other.max);
328  }
Vector2 min(const Vector2 &v) const
Definition: Vector2.h:452
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
Vector2 max(const Vector2 &v) const
Definition: Vector2.h:458
Point2 G3D::Rect2D::randomPoint ( ) const
inline

Uniformly random point on the interior.

155  {
156  return Point2(uniformRandom(0, max.x - min.x) + min.x,
157  uniformRandom(0, max.y - min.y) + min.y);
158  }
Vector2 Point2
Definition: Vector2.h:492
float y
Definition: Vector2.h:50
float uniformRandom(float low=0.0f, float hi=1.0f)
Definition: g3dmath.h:694
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

void G3D::Rect2D::serialize ( class BinaryOutput b) const
28  {
29  min.serialize(b);
30  max.serialize(b);
31 }
void serialize(class BinaryOutput &b) const
Definition: Vector2.cpp:125
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

Any G3D::Rect2D::toAny ( ) const

Converts the Rect2D to an Any.

59  {
60  if (isEmpty()) {
61  return Any(Any::ARRAY, "Rect2D::empty");
62  } else {
63  Any any(Any::ARRAY, "Rect2D::xywh");
64  any.append(Any(x0()), Any(y0()), Any(width()), Any(height()));
65  return any;
66  }
67 }
float y0() const
Definition: Rect2D.h:184
bool any(float x)
Definition: g3dmath.h:424
bool isEmpty() const
Definition: Rect2D.h:139
Definition: Any.h:187
float width() const
Definition: Rect2D.h:160
float height() const
Definition: Rect2D.h:168
float x0() const
Definition: Rect2D.h:176

+ Here is the call graph for this function:

Vector2 G3D::Rect2D::wh ( ) const
inline

Width and height

211  {
212  if (isEmpty()) {
213  return Vector2::zero();
214  } else {
215  return max - min;
216  }
217  }
bool isEmpty() const
Definition: Rect2D.h:139
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
static const Vector2 & zero()
Definition: Vector2.cpp:67

+ Here is the call graph for this function:

float G3D::Rect2D::width ( ) const
inline
160  {
161  if (isEmpty()) {
162  return 0;
163  } else {
164  return max.x - min.x;
165  }
166  }
bool isEmpty() const
Definition: Rect2D.h:139
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float G3D::Rect2D::x0 ( ) const
inline
176  {
177  return min.x;
178  }
float x
Definition: Vector2.h:49
Point2 min
Definition: Rect2D.h:42

+ Here is the caller graph for this function:

Point2 G3D::Rect2D::x0y0 ( ) const
inline

Min, min corner

193  {
194  return min;
195  }
Point2 min
Definition: Rect2D.h:42
Point2 G3D::Rect2D::x0y1 ( ) const
inline
201  {
202  return Point2(min.x, max.y);
203  }
Vector2 Point2
Definition: Vector2.h:492
float y
Definition: Vector2.h:50
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
float G3D::Rect2D::x1 ( ) const
inline
180  {
181  return max.x;
182  }
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42

+ Here is the caller graph for this function:

Point2 G3D::Rect2D::x1y0 ( ) const
inline
197  {
198  return Point2(max.x, min.y);
199  }
Vector2 Point2
Definition: Vector2.h:492
float y
Definition: Vector2.h:50
float x
Definition: Vector2.h:49
Point2 max
Definition: Rect2D.h:42
Point2 min
Definition: Rect2D.h:42
Point2 G3D::Rect2D::x1y1 ( ) const
inline

Max,max corner

206  {
207  return max;
208  }
Point2 max
Definition: Rect2D.h:42
static Rect2D G3D::Rect2D::xywh ( float  x,
float  y,
float  w,
float  h 
)
inlinestatic
260  {
261  return xyxy(x, y, x + w, y + h);
262  }
G3D::int16 y
Definition: Vector2int16.h:38
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Rect2D G3D::Rect2D::xywh ( const Point2 v,
const Vector2 w 
)
inlinestatic
264  {
265  return xyxy(v.x, v.y, v.x + w.x, v.y + w.y);
266  }
static Rect2D xyxy(float x0, float y0, float x1, float y1)
Definition: Rect2D.h:240

+ Here is the call graph for this function:

static Rect2D G3D::Rect2D::xyxy ( float  x0,
float  y0,
float  x1,
float  y1 
)
inlinestatic
240  {
241  Rect2D r(false);
242 
243  r.min.x = G3D::min(x0, x1);
244  r.min.y = G3D::min(y0, y1);
245  r.max.x = G3D::max(x0, x1);
246  r.max.y = G3D::max(y0, y1);
247 
248  return r;
249  }
float y0() const
Definition: Rect2D.h:184
T max(const T &x, const T &y)
Definition: g3dmath.h:320
float y1() const
Definition: Rect2D.h:188
T min(const T &x, const T &y)
Definition: g3dmath.h:305
float x0() const
Definition: Rect2D.h:176
float x1() const
Definition: Rect2D.h:180
Rect2D()
Definition: Rect2D.h:134

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Rect2D G3D::Rect2D::xyxy ( const Point2 v0,
const Point2 v1 
)
inlinestatic
251  {
252  Rect2D r(false);
253 
254  r.min = v0.min(v1);
255  r.max = v0.max(v1);
256 
257  return r;
258  }
Rect2D()
Definition: Rect2D.h:134

+ Here is the call graph for this function:

float G3D::Rect2D::y0 ( ) const
inline
184  {
185  return min.y;
186  }
float y
Definition: Vector2.h:50
Point2 min
Definition: Rect2D.h:42

+ Here is the caller graph for this function:

float G3D::Rect2D::y1 ( ) const
inline
188  {
189  return max.y;
190  }
float y
Definition: Vector2.h:50
Point2 max
Definition: Rect2D.h:42

+ Here is the caller graph for this function:

Member Data Documentation

Point2 G3D::Rect2D::max
private
Point2 G3D::Rect2D::min
private

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