23 inline vec2() : x(0.0f), y(0.0f) { }
25 inline vec2(
float x,
float y) : x(x), y(y) {}
27 inline vec2(
float x) : x(x), y(x) {}
29 inline vec2 yx()
const {
return { y, x }; }
31 inline vec2 xx()
const {
return { x, x }; }
33 inline vec2 yy()
const {
return { y, y }; }
100 return !memcmp(&a, &b,
sizeof(a));
108 return{ (b.
x < a.
x) ? b.
x : a.
x,
109 (b.
y < a.
y) ? b.
y : a.
y };
113 return{ (a.
x < b.
x) ? b.
x : a.
x,
114 (a.
y < b.
y) ? b.
y : a.
y };
118 return min_(max_(x, minVal), maxVal);
122 return a * (1.0f - t) + b * t;
126 return sqrtf(a.
x * a.
x + a.
y * a.
y);
135 return length(a - b);
140 return length2(a - b);
144 return a / length(a);
148 return a.
x * b.
x + a.
y * b.
y;
158 inline vec3() : x(0.0f), y(0.0f), z(0.0f) { }
160 inline vec3(
float x,
float y,
float z) : x(x), y(y), z(z) {}
162 inline vec3(
float x) : x(x), y(x), z(x) {}
237 return !memcmp(&a, &b,
sizeof(a));
245 return{ (b.
x < a.
x) ? b.
x : a.
x,
246 (b.
y < a.
y) ? b.
y : a.
y,
247 (b.
z < a.
z) ? b.
z : a.
z };
251 return{ (a.
x < b.
x) ? b.
x : a.
x,
252 (a.
y < b.
y) ? b.
y : a.
y,
253 (a.
z < b.
z) ? b.
z : a.
z };
256 return min_(max_(x, minVal), maxVal);
260 return a * (1.0f - t) + b * t;
264 return sqrtf(a.
x * a.
x + a.
y * a.
y + a.
z * a.
z);
268 return length(a - b);
272 return a / length(a);
276 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z;
286 inline vec4() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) { }
288 inline vec4(
float x,
float y,
float z,
float w) : x(x), y(y), z(z), w(w) {}
290 inline vec4(
float x) : x(x), y(x), z(x), w(x) {}
292 inline vec4(
const float val[4]) : x(val[0]), y(val[1]), z(val[2]), w(val[3]) { }
295 return !memcmp(&a, &b,
sizeof(a));
383 return{ (b.
x < a.
x) ? b.
x : a.
x,
384 (b.
y < a.
y) ? b.
y : a.
y,
385 (b.
z < a.
z) ? b.
z : a.
z,
386 (b.
w < a.
w) ? b.
w : a.
w };
390 return{ (a.
x < b.
x) ? b.
x : a.
x,
391 (a.
y < b.
y) ? b.
y : a.
y,
392 (a.
z < b.
z) ? b.
z : a.
z,
393 (a.
w < b.
w) ? b.
w : a.
w };
396 inline void load(
const float* val) {
403 inline void store(
float* val)
const {
424 inline float width()
const {
return right - left; }
425 inline float height()
const {
return bottom - top; }
426 inline float x()
const {
return left; }
427 inline float y()
const {
return top; }
428 inline float center_x()
const {
return (left + right) * 0.5f; }
429 inline float center_y()
const {
return (top + bottom) * 0.5f; }
436 return *
this == MakeEmpty();
440 return width() > 0 && height() > 0;
443 inline void Inset(
float dx,
float dy) {
454 inline void Move(
float dx,
float dy) {
462 return width() * height();
471 if (rhs.
left < left) left = rhs.
left;
472 if (rhs.
top < top) top = rhs.
top;
481 *
this = { p.
x, p.
y, p.
x, p.
y };
484 if (p.
x < left) left = p.
x;
485 if (p.
y < top) top = p.
y;
486 if (p.
x > right) right = p.
x;
487 if (p.
y > bottom) bottom = p.
y;
492 return p.
x >= left && p.
x <= right &&
493 p.
y >= top && p.
y <= bottom;
497 return left <= r.
left && top <= r.
top &&
502 return !(rhs.
left > right ||
509 return{ (left < other.
left) ? other.
left : left,
510 (top < other.
top) ? other.
top : top,
516 return !memcmp(&a, &b,
sizeof(a));
534 inline int width()
const {
return right - left; }
535 inline int height()
const {
return bottom - top; }
536 inline int x()
const {
return left; }
537 inline int y()
const {
return top; }
538 inline int center_x()
const {
return (
int)std::round((left + right) * 0.5f); }
539 inline int center_y()
const {
return (
int)std::round((top + bottom) * 0.5f); }
546 return *
this == MakeEmpty();
550 return width() > 0 && height() > 0;
564 inline void Move(
int dx,
int dy) {
572 return width() * height();
581 if (rhs.
left < left) left = rhs.
left;
582 if (rhs.
top < top) top = rhs.
top;
591 *
this = { (int)std::floor(p.
x), (int)std::floor(p.
y), (int)std::ceil(p.
x), (int)std::ceil(p.
y) };
594 if ((
int)std::floor(p.
x) < left) left = (
int)std::floor(p.
x);
595 if ((
int)std::floor(p.
y) < top) top = (int)std::floor(p.
y);
596 if ((
int)std::ceil(p.
x) > right) right = (
int)std::ceil(p.
x);
597 if ((
int)std::ceil(p.
y) > bottom) bottom = (int)std::ceil(p.
y);
602 return p.
x >= left && p.
x <= right &&
603 p.
y >= top && p.
y <= bottom;
607 return left <= r.
left && top <= r.
top &&
614 return !(rhs.
left > right - 1 ||
616 rhs.
top > bottom - 1 ||
621 return{ (left < other.
left) ? other.
left : left,
622 (top < other.
top) ? other.
top : top,
628 return !memcmp(&a, &b,
sizeof(a));
#define UExport
Definition Exports.h:25
vec2 Point
Point is typedef'd to a 2D vector.
Definition Geometry.h:414
Integer Rectangle Helper.
Definition Geometry.h:529
void Join(const IntRect &rhs)
Definition Geometry.h:575
friend bool operator==(const IntRect &a, const IntRect &b)
Definition Geometry.h:627
int x() const
Definition Geometry.h:536
bool Contains(const IntRect &r) const
Definition Geometry.h:606
void Outset(int dx, int dy)
Definition Geometry.h:560
int right
Definition Geometry.h:530
int bottom
Definition Geometry.h:530
void Join(const Point &p)
Definition Geometry.h:588
Point origin() const
Definition Geometry.h:541
friend bool operator!=(const IntRect &a, const IntRect &b)
Definition Geometry.h:631
int y() const
Definition Geometry.h:537
bool IsEmpty() const
Definition Geometry.h:545
bool Intersects(const IntRect &rhs) const
Definition Geometry.h:611
void Move(int dx, int dy)
Definition Geometry.h:564
int center_x() const
Definition Geometry.h:538
void Inset(int dx, int dy)
Definition Geometry.h:553
IntRect Intersect(const IntRect &other) const
Definition Geometry.h:620
void SetEmpty()
Definition Geometry.h:543
bool IsValid() const
Definition Geometry.h:549
bool Contains(const Point &p) const
Definition Geometry.h:601
int height() const
Definition Geometry.h:535
int width() const
Definition Geometry.h:534
int left
Definition Geometry.h:530
int center_y() const
Definition Geometry.h:539
static constexpr IntRect MakeEmpty()
Definition Geometry.h:532
int top
Definition Geometry.h:530
int area() const
Definition Geometry.h:571
Float Rectangle Helper.
Definition Geometry.h:419
void Inset(float dx, float dy)
Definition Geometry.h:443
float y() const
Definition Geometry.h:427
void Move(float dx, float dy)
Definition Geometry.h:454
Rect Intersect(const Rect &other) const
Definition Geometry.h:508
void Join(const Point &p)
Definition Geometry.h:478
float bottom
Definition Geometry.h:420
friend bool operator==(const Rect &a, const Rect &b)
Definition Geometry.h:515
bool Contains(const Rect &r) const
Definition Geometry.h:496
friend bool operator!=(const Rect &a, const Rect &b)
Definition Geometry.h:519
float height() const
Definition Geometry.h:425
Point origin() const
Definition Geometry.h:431
float center_x() const
Definition Geometry.h:428
float right
Definition Geometry.h:420
float area() const
Definition Geometry.h:461
float left
Definition Geometry.h:420
float center_y() const
Definition Geometry.h:429
bool IsEmpty() const
Definition Geometry.h:435
vec4 ToVec4()
Definition Geometry.h:523
static constexpr Rect MakeEmpty()
Definition Geometry.h:422
float x() const
Definition Geometry.h:426
float width() const
Definition Geometry.h:424
void Join(const Rect &rhs)
Definition Geometry.h:465
bool Intersects(const Rect &rhs) const
Definition Geometry.h:501
void SetEmpty()
Definition Geometry.h:433
bool IsValid() const
Definition Geometry.h:439
void Outset(float dx, float dy)
Definition Geometry.h:450
bool Contains(const Point &p) const
Definition Geometry.h:491
float top
Definition Geometry.h:420
Rounded Rectangle Helper.
Definition Geometry.h:639
float GetSignedDistance(const Point &p) const
Rect rect
Definition Geometry.h:640
bool Intersect(const RoundedRect &other, RoundedRect &result) const
Rect CalculateInterior() const
2D Vector Helper
Definition Geometry.h:20
vec2 & operator+=(const vec2 &rhs)
Definition Geometry.h:51
vec2 & operator+=(float rhs)
Definition Geometry.h:75
friend float length2(const vec2 &a)
Definition Geometry.h:130
vec2 yy() const
Definition Geometry.h:33
vec2 xx() const
Definition Geometry.h:31
friend vec2 mix(const vec2 &a, const vec2 &b, float t)
Definition Geometry.h:121
vec2 yx() const
Definition Geometry.h:29
friend float dot(const vec2 &a, const vec2 &b)
Definition Geometry.h:147
friend float distance(const vec2 &a, const vec2 &b)
Definition Geometry.h:134
friend float distance2(const vec2 &a, const vec2 &b)
Definition Geometry.h:139
vec2 & operator/=(float rhs)
Definition Geometry.h:93
vec2 & operator/=(const vec2 &rhs)
Definition Geometry.h:69
friend vec2 operator-(vec2 lhs, const vec2 &rhs)
Definition Geometry.h:37
vec2()
Definition Geometry.h:23
vec2 & operator-=(const vec2 &rhs)
Definition Geometry.h:57
friend vec2 operator+(vec2 lhs, const vec2 &rhs)
Definition Geometry.h:35
friend vec2 operator*(vec2 lhs, const vec2 &rhs)
Definition Geometry.h:39
friend vec2 normalize(const vec2 &a)
Definition Geometry.h:143
vec2(float x, float y)
Definition Geometry.h:25
vec2 & operator*=(const vec2 &rhs)
Definition Geometry.h:63
friend vec2 clamp(const vec2 &x, const vec2 &minVal, const vec2 &maxVal)
Definition Geometry.h:117
friend vec2 max_(const vec2 &a, const vec2 &b)
Definition Geometry.h:112
friend vec2 operator/(vec2 lhs, float rhs)
Definition Geometry.h:49
friend bool operator==(const vec2 &a, const vec2 &b)
Definition Geometry.h:99
float y
Definition Geometry.h:21
friend bool operator!=(const vec2 &a, const vec2 &b)
Definition Geometry.h:103
friend vec2 operator+(vec2 lhs, float rhs)
Definition Geometry.h:43
friend vec2 operator*(vec2 lhs, float rhs)
Definition Geometry.h:47
friend vec2 min_(const vec2 &a, const vec2 &b)
Definition Geometry.h:107
vec2 & operator*=(float rhs)
Definition Geometry.h:87
friend vec2 operator/(vec2 lhs, const vec2 &rhs)
Definition Geometry.h:41
float x
Definition Geometry.h:21
vec2 & operator-=(float rhs)
Definition Geometry.h:81
friend vec2 operator-(vec2 lhs, float rhs)
Definition Geometry.h:45
friend float length(const vec2 &a)
Definition Geometry.h:125
vec2(float x)
Definition Geometry.h:27
3D Vector Helper
Definition Geometry.h:155
friend float distance(const vec3 &a, const vec3 &b)
Definition Geometry.h:267
vec3 & operator/=(float rhs)
Definition Geometry.h:229
friend float length(const vec3 &a)
Definition Geometry.h:263
friend vec3 operator/(vec3 lhs, float rhs)
Definition Geometry.h:178
vec3 & operator*=(float rhs)
Definition Geometry.h:222
friend vec3 operator/(vec3 lhs, const vec3 &rhs)
Definition Geometry.h:170
friend vec3 operator*(vec3 lhs, float rhs)
Definition Geometry.h:176
vec3 & operator*=(const vec3 &rhs)
Definition Geometry.h:194
friend vec3 operator+(vec3 lhs, const vec3 &rhs)
Definition Geometry.h:164
vec3 & operator/=(const vec3 &rhs)
Definition Geometry.h:201
friend vec3 max_(const vec3 &a, const vec3 &b)
Definition Geometry.h:250
vec3 & operator+=(const vec3 &rhs)
Definition Geometry.h:180
vec3 & operator+=(float rhs)
Definition Geometry.h:208
vec3(float x, float y, float z)
Definition Geometry.h:160
friend vec3 normalize(const vec3 &a)
Definition Geometry.h:271
friend vec3 operator-(vec3 lhs, const vec3 &rhs)
Definition Geometry.h:166
friend vec3 operator-(vec3 lhs, float rhs)
Definition Geometry.h:174
friend vec3 operator*(vec3 lhs, const vec3 &rhs)
Definition Geometry.h:168
friend vec3 mix(const vec3 &a, const vec3 &b, float t)
Definition Geometry.h:259
float y
Definition Geometry.h:156
friend vec3 clamp(const vec3 &x, const vec3 &minVal, const vec3 &maxVal)
Definition Geometry.h:255
vec3 & operator-=(const vec3 &rhs)
Definition Geometry.h:187
vec3 & operator-=(float rhs)
Definition Geometry.h:215
friend bool operator!=(const vec3 &a, const vec3 &b)
Definition Geometry.h:240
vec3(float x)
Definition Geometry.h:162
float x
Definition Geometry.h:156
friend float dot(const vec3 &a, const vec3 &b)
Definition Geometry.h:275
friend bool operator==(const vec3 &a, const vec3 &b)
Definition Geometry.h:236
friend vec3 min_(const vec3 &a, const vec3 &b)
Definition Geometry.h:244
friend vec3 operator+(vec3 lhs, float rhs)
Definition Geometry.h:172
float z
Definition Geometry.h:156
vec3()
Definition Geometry.h:158
4D Vector Helper
Definition Geometry.h:283
vec4(float x)
Definition Geometry.h:290
void load(const float *val)
Definition Geometry.h:396
vec4()
Definition Geometry.h:286
vec4 & operator+=(const vec4 &rhs)
Definition Geometry.h:318
void store(float *val) const
Definition Geometry.h:403
vec4 & operator*=(const vec4 &rhs)
Definition Geometry.h:334
vec4 & operator-=(const vec4 &rhs)
Definition Geometry.h:326
vec4 & operator+=(float rhs)
Definition Geometry.h:350
friend vec4 operator-(vec4 lhs, float rhs)
Definition Geometry.h:312
vec4(const float val[4])
Definition Geometry.h:292
vec4 & operator*=(float rhs)
Definition Geometry.h:366
float w
Definition Geometry.h:284
friend vec4 operator/(vec4 lhs, float rhs)
Definition Geometry.h:316
vec4 & operator/=(float rhs)
Definition Geometry.h:374
friend vec4 min_(const vec4 &a, const vec4 &b)
Definition Geometry.h:382
vec4(float x, float y, float z, float w)
Definition Geometry.h:288
friend vec4 operator-(vec4 lhs, const vec4 &rhs)
Definition Geometry.h:304
friend vec4 operator*(vec4 lhs, const vec4 &rhs)
Definition Geometry.h:306
friend vec4 operator+(vec4 lhs, const vec4 &rhs)
Definition Geometry.h:302
float y
Definition Geometry.h:284
friend vec4 operator/(vec4 lhs, const vec4 &rhs)
Definition Geometry.h:308
vec4 & operator/=(const vec4 &rhs)
Definition Geometry.h:342
vec4 & operator-=(float rhs)
Definition Geometry.h:358
friend bool operator==(const vec4 &a, const vec4 &b)
Definition Geometry.h:294
float x
Definition Geometry.h:284
friend vec4 operator+(vec4 lhs, float rhs)
Definition Geometry.h:310
friend bool operator!=(const vec4 &a, const vec4 &b)
Definition Geometry.h:298
friend vec4 max_(const vec4 &a, const vec4 &b)
Definition Geometry.h:389
float z
Definition Geometry.h:284
friend vec4 operator*(vec4 lhs, float rhs)
Definition Geometry.h:314