CUGL
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
CUVec2.h
1 //
2 // CUVec2.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This module provides support for a 2d vector. It has support for basic
6 // arithmetic, as well as some common line intersection properties.
7 //
8 // Because math objects are intended to be on the stack, we do not provide
9 // any shared pointer support in this class.
10 //
11 // This module is based on an original file from GamePlay3D: http://gameplay3d.org.
12 // It has been modified to support the CUGL framework.
13 //
14 // CUGL zlib License:
15 // This software is provided 'as-is', without any express or implied
16 // warranty. In no event will the authors be held liable for any damages
17 // arising from the use of this software.
18 //
19 // Permission is granted to anyone to use this software for any purpose,
20 // including commercial applications, and to alter it and redistribute it
21 // freely, subject to the following restrictions:
22 //
23 // 1. The origin of this software must not be misrepresented; you must not
24 // claim that you wrote the original software. If you use this software
25 // in a product, an acknowledgment in the product documentation would be
26 // appreciated but is not required.
27 //
28 // 2. Altered source versions must be plainly marked as such, and must not
29 // be misrepresented as being the original software.
30 //
31 // 3. This notice may not be removed or altered from any source distribution.
32 //
33 // Author: Walker White
34 // Version: 5/30/16
35 
36 #ifndef __CU_VEC2_H__
37 #define __CU_VEC2_H__
38 
39 #include <math.h>
40 #include <string>
41 #include <functional>
42 #include "CUMathBase.h"
43 
44 namespace cugl {
45 
46 // Forward references for conversions
47 class Size;
48 class Vec3;
49 class Vec4;
50 
61 class Vec2 {
62 
63 #pragma mark Values
64 public:
66  float x;
68  float y;
69 
71  static const Vec2 ZERO;
73  static const Vec2 ONE;
75  static const Vec2 UNIT_X;
77  static const Vec2 UNIT_Y;
78 
80  static const Vec2 ANCHOR_MIDDLE;
82  static const Vec2 ANCHOR_BOTTOM_LEFT;
84  static const Vec2 ANCHOR_TOP_LEFT;
86  static const Vec2 ANCHOR_BOTTOM_RIGHT;
88  static const Vec2 ANCHOR_TOP_RIGHT;
90  static const Vec2 ANCHOR_MIDDLE_RIGHT;
92  static const Vec2 ANCHOR_MIDDLE_LEFT;
94  static const Vec2 ANCHOR_MIDDLE_TOP;
96  static const Vec2 ANCHOR_MIDDLE_BOTTOM;
97 
98 #pragma mark -
99 #pragma mark Constructors
100 public:
104  Vec2() : x(0), y(0) { }
105 
112  Vec2(float x, float y) { this->x = x; this->y = y; }
113 
119  Vec2(const float* array) { x = array[0]; y = array[1]; }
120 
127  Vec2(const Vec2& p1, const Vec2& p2) {
128  x = p2.x-p1.x; y = p2.y-p1.y;
129  }
130 
136  Vec2(const Vec2& copy) { x = copy.x; y = copy.y; }
137 
141  ~Vec2() {}
142 
143 
144 #pragma mark -
145 #pragma mark Setters
146 
153  Vec2& operator=(const Vec2& v) {
154  return set(v);
155  }
156 
164  Vec2& operator=(const float* array) {
165  return set(array);
166  }
167 
176  Vec2& set(float x, float y) {
177  this->x = x; this->y = y;
178  return *this;
179  }
180 
188  Vec2& set(const float* array) {
189  x = array[0]; y = array[1];
190  return *this;
191  }
192 
200  Vec2& set(const Vec2& v) {
201  x = v.x; y = v.y;
202  return *this;
203  }
204 
213  Vec2& set(const Vec2& p1, const Vec2& p2) {
214  x = p2.x-p1.x; y = p2.y-p1.y;
215  return *this;
216  }
217 
224  x = y = 0;
225  return *this;
226  }
227 
228 
229 #pragma mark -
230 #pragma mark Static Arithmetic
231 
238  static Vec2 forAngle(const float a) {
239  return Vec2(cosf(a), sinf(a));
240  }
241 
252  static Vec2* clamp(const Vec2& v, const Vec2& min, const Vec2& max, Vec2* dst);
253 
262  static float angle(const Vec2& v1, const Vec2& v2);
263 
273  static Vec2* add(const Vec2& v1, const Vec2& v2, Vec2* dst);
274 
285  static Vec2* subtract(const Vec2& v1, const Vec2& v2, Vec2* dst);
286 
298  static Vec2* scale(const Vec2& v, float s, Vec2* dst);
299 
311  static Vec2* scale(const Vec2& v1, const Vec2& v2, Vec2* dst);
312 
324  static Vec2* divide(const Vec2& v, float s, Vec2* dst);
325 
337  static Vec2* divide(const Vec2& v1, const Vec2& v2, Vec2* dst);
338 
351  static Vec2* reciprocate(const Vec2& v, Vec2* dst);
352 
361  static Vec2* negate(const Vec2& v, Vec2* dst);
362 
363 #pragma mark -
364 #pragma mark Arithmetic
365 
373  Vec2& clamp(const Vec2& min, const Vec2& max) {
374  x = clampf(x, min.x, max.x);
375  y = clampf(y, min.y, max.y);
376  return *this;
377  }
378 
389  Vec2 getClamp(const Vec2& min, const Vec2& max) const {
390  return Vec2(clampf(x,min.x,max.x), clampf(y, min.y, max.y));
391  }
392 
400  Vec2& add(const Vec2& v) {
401  x += v.x; y += v.y;
402  return *this;
403  }
404 
413  Vec2& add(float x, float y) {
414  this->x += x; this->y += y;
415  return *this;
416  }
417 
425  Vec2& subtract(const Vec2& v) {
426  x -= v.x; y -= v.y;
427  return *this;
428  }
429 
438  Vec2& subtract(float x, float y) {
439  this->x -= x; this->y -= y;
440  return *this;
441  }
442 
450  Vec2& scale(float s) {
451  x *= s; y *= s;
452  return *this;
453  }
454 
463  Vec2& scale(float sx, float sy) {
464  x *= sx; y *= sy;
465  return *this;
466  }
467 
475  Vec2& scale(const Vec2& v) {
476  x *= v.x; y *= v.y;
477  return *this;
478  }
479 
487  Vec2& divide(float s);
488 
497  Vec2& divide(float sx, float sy);
498 
508  Vec2& divide(const Vec2& v);
509 
516  x = -x; y = -y;
517  return *this;
518  }
519 
530  x = 1.0f/x; y = 1.0f/y;
531  return *this;
532  }
533 
541  Vec2 getNegation() const {
542  Vec2 result(*this);
543  return result.negate();
544  }
545 
557  Vec2 getReciprocal() const {
558  Vec2 result(*this);
559  return result.reciprocate();
560  }
561 
572  Vec2& map(std::function<float(float)> func) {
573  x = func(x); y = func(y);
574  return *this;
575  }
576 
587  Vec2 getMap(std::function<float(float)> func) const {
588  return Vec2(func(x), func(y));
589  }
590 
591 
592 #pragma mark -
593 #pragma mark Operators
594 
601  Vec2& operator+=(const Vec2& v) {
602  return add(v);
603  }
604 
612  Vec2& operator-=(const Vec2& v) {
613  return subtract(v);
614  }
615 
623  Vec2& operator*=(float s) {
624  return scale(s);
625  }
626 
634  Vec2& operator*=(const Vec2& v) {
635  return scale(v);
636  }
637 
645  Vec2& operator/=(float s) {
646  return divide(s);
647  }
648 
658  Vec2& operator/=(const Vec2& v) {
659  return divide(v);
660  }
661 
671  const Vec2 operator+(const Vec2& v) const {
672  Vec2 result(*this);
673  return result.add(v);
674  }
675 
685  const Vec2 operator-(const Vec2& v) const {
686  Vec2 result(*this);
687  return result.subtract(v);
688  }
689 
697  const Vec2 operator-() const {
698  Vec2 result(*this);
699  return result.negate();
700  }
701 
711  const Vec2 operator*(float s) const {
712  Vec2 result(*this);
713  return result.scale(s);
714  }
715 
726  const Vec2 operator*(const Vec2& v) const {
727  Vec2 result(*this);
728  return result.scale(v);
729  }
730 
740  const Vec2 operator/(float s) const {
741  Vec2 result(*this);
742  return result.divide(s);
743  }
744 
755  const Vec2 operator/(const Vec2& v) const {
756  Vec2 result(*this);
757  return result.divide(v);
758  }
759 
760 
761 #pragma mark -
762 #pragma mark Comparisons
763 
774  bool operator<(const Vec2& v) const {
775  return (x == v.x ? y < v.y : x < v.x);
776  }
777 
789  bool operator<=(const Vec2& v) const {
790  return (x == v.x ? y <= v.y : x <= v.x);
791  }
792 
804  bool operator>(const Vec2& v) const {
805  return (x == v.x ? y > v.y : x > v.x);
806  }
807 
819  bool operator>=(const Vec2& v) const {
820  return (x == v.x ? y >= v.y : x >= v.x);
821  }
822 
833  bool operator==(const Vec2& v) const {
834  return x == v.x && y == v.y;
835  }
836 
847  bool operator!=(const Vec2& v) const {
848  return x != v.x || y != v.y;
849  }
850 
861  bool under(const Vec2& v) const {
862  return x <= v.x && y <= v.y;
863  }
864 
875  bool over(const Vec2& v) const {
876  return x >= v.x && y >= v.y;
877  }
878 
890  bool equals(const Vec2& v, float variance=CU_MATH_EPSILON) const {
891  return distanceSquared(v) <= variance*variance;
892  }
893 
894 
895 #pragma mark -
896 #pragma mark Linear Attributes
897 
904  float getAngle() const {
905  return atan2f(y, x);
906  }
907 
918  float getAngle(const Vec2& other) const;
919 
925  bool isZero() const {
926  return x == 0.0f && y == 0.0f;
927  }
928 
936  bool isNearZero(float variance=CU_MATH_EPSILON) const {
937  return lengthSquared() < variance*variance;
938  }
939 
945  bool isOne() const {
946  return x == 1.0f && y == 1.0f;
947  }
948 
954  bool isInvertible() const {
955  return x != 0.0f && y != 0.0f;
956  }
957 
965  bool isUnit(float variance=CU_MATH_EPSILON) const {
966  float dot = lengthSquared()-1;
967  return dot < variance && dot > -variance;
968  }
969 
979  float distance(const Vec2& v) const {
980  return sqrt(distanceSquared(v));
981  }
982 
997  float distanceSquared(const Vec2& v) const {
998  return (x-v.x)*(x-v.x)+(y-v.y)*(y-v.y);
999  }
1000 
1008  float length() const {
1009  return sqrt(lengthSquared());
1010  }
1011 
1024  float lengthSquared() const {
1025  return x*x+y*y;
1026  }
1027 
1028 
1029 #pragma mark -
1030 #pragma mark Linear Algebra
1031 
1038  float dot(const Vec2& v) const { return (x * v.x + y * v.y); }
1039 
1050  float cross(const Vec2& other) const {
1051  return x*other.y - y*other.x;
1052  }
1053 
1064  Vec2& normalize();
1065 
1078  Vec2 result(*this);
1079  return result.normalize();
1080  }
1081 
1089  Vec2& rotate(float angle);
1090 
1099  Vec2& rotate(float angle, const Vec2& point);
1100 
1111  Vec2& rotate(const Vec2& other) {
1112  // The const is more of a guideline than a rule. Must bullet-proof.
1113  float tx = x; float ty = y;
1114  float ox = other.x; float oy = other.y;
1115  x = tx*ox - ty*oy; y = tx*oy + ty*ox;
1116  return *this;
1117  }
1118 
1129  Vec2& unrotate(const Vec2& other) {
1130  float tx = x; float ty = y;
1131  float ox = other.x; float oy = other.y;
1132  x = tx*ox + ty*oy; y = -tx*oy + ty*ox;
1133  return *this;
1134  }
1135 
1146  Vec2 getRotation(float angle);
1147 
1159  Vec2 getRotation(float angle, const Vec2& point);
1160 
1173  Vec2 getRotation(const Vec2& other) {
1174  return Vec2(x*other.x - y*other.y, x*other.y + y*other.x);
1175  }
1176 
1189  Vec2 getUnrotation(const Vec2& other) {
1190  return Vec2(x*other.x + y*other.y, y*other.x - x*other.y);
1191  }
1192 
1200  Vec2& perp() {
1201  float a = x; x = -y; y = a;
1202  return *this;
1203  }
1204 
1213  float a = x; x = y; y = -a;
1214  return *this;
1215  }
1216 
1226  Vec2 getPerp() const {
1227  return Vec2(-y, x);
1228  }
1229 
1239  Vec2 getRPerp() const {
1240  return Vec2(y, -x);
1241  }
1242 
1252  Vec2 getMidpoint(const Vec2& other) const {
1253  return Vec2((x + other.x) / 2.0f, (y + other.y) / 2.0f);
1254  }
1255 
1263  Vec2& project(const Vec2& other) {
1264  *this = getProjection(other);
1265  return *this;
1266  }
1267 
1277  Vec2 getProjection(const Vec2& other) const {
1278  return other * (dot(other)/other.dot(other));
1279  }
1280 
1281 
1294  Vec2& lerp(const Vec2& other, float alpha) {
1295  *this *= (1.f - alpha);
1296  return *this += other * alpha;
1297  }
1298 
1311  Vec2 getLerp(const Vec2& other, float alpha) {
1312  return *this * (1.f - alpha) + other * alpha;
1313  }
1314 
1315 
1316 #pragma mark -
1317 #pragma mark Static Linear Algebra
1318 
1327  static float dot(const Vec2& v1, const Vec2& v2);
1328 
1340  static float cross(const Vec2& v1, const Vec2& v2);
1341 
1353  static Vec2* normalize(const Vec2& v, Vec2* dst);
1354 
1364  static Vec2* midpoint(const Vec2& v1, const Vec2& v2, Vec2* dst);
1365 
1375  static Vec2* project(const Vec2& v1, const Vec2& v2, Vec2* dst);
1376 
1391  static Vec2* lerp(const Vec2& v1, const Vec2& v2, float alpha, Vec2* dst);
1392 
1417  static bool doesLineIntersect(const Vec2& A, const Vec2& B,
1418  const Vec2& C, const Vec2& D,
1419  float *S = nullptr, float *T = nullptr);
1420 
1434  static bool doesLineOverlap(const Vec2& A, const Vec2& B,
1435  const Vec2& C, const Vec2& D);
1436 
1450  static bool isLineParallel(const Vec2& A, const Vec2& B,
1451  const Vec2& C, const Vec2& D);
1452 
1465  static bool doesSegmentIntersect(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D);
1466 
1483  static bool doesSegmentOverlap(const Vec2& A, const Vec2& B,
1484  const Vec2& C, const Vec2& D,
1485  Vec2* S = nullptr, Vec2* E = nullptr);
1486 
1500  static Vec2 getIntersection(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D);
1501 
1502 
1503 #pragma mark -
1504 #pragma mark Conversion Methods
1505 public:
1516  std::string toString(bool verbose = false) const;
1517 
1519  operator std::string() const { return toString(); }
1520 
1522  operator Size() const;
1523 
1531  explicit Vec2(const Size& size);
1532 
1542  Vec2& operator= (const Size& size);
1543 
1551  Vec2& operator+=(const Size& right);
1552 
1560  Vec2& operator-=(const Size& right);
1561 
1571  const Vec2 operator+(const Size& right) const {
1572  Vec2 result(*this);
1573  return result += right;
1574  }
1575 
1585  const Vec2 operator-(const Size& right) const {
1586  Vec2 result(*this);
1587  return result -= right;
1588  }
1589 
1595  operator Vec3() const;
1596 
1604  explicit Vec2(const Vec3& v);
1605 
1615  Vec2& operator= (const Vec3& size);
1616 
1623  operator Vec4() const;
1624 
1633  explicit Vec2(const Vec4& v);
1634 
1645  Vec2& operator= (const Vec4& size);
1646 };
1647 
1648 
1649 #pragma mark -
1650 #pragma mark Friend Operations
1651 
1660 inline const Vec2 operator*(float x, const Vec2& v) {
1661  Vec2 result(v);
1662  return result.scale(x);
1663 }
1664 
1666 typedef Vec2 Point2;
1667 
1668 }
1669 
1670 #endif /* __CU_VEC2_H__ */
Vec2 & operator+=(const Vec2 &v)
Definition: CUVec2.h:601
static Vec2 * scale(const Vec2 &v, float s, Vec2 *dst)
Definition: CUSize.h:57
Vec2 & scale(float s)
Definition: CUVec2.h:450
Vec2 & operator/=(const Vec2 &v)
Definition: CUVec2.h:658
Vec2 & clamp(const Vec2 &min, const Vec2 &max)
Definition: CUVec2.h:373
float distance(const Vec2 &v) const
Definition: CUVec2.h:979
Vec2 getNegation() const
Definition: CUVec2.h:541
bool isUnit(float variance=CU_MATH_EPSILON) const
Definition: CUVec2.h:965
Vec2(const float *array)
Definition: CUVec2.h:119
Vec2 & add(float x, float y)
Definition: CUVec2.h:413
float distanceSquared(const Vec2 &v) const
Definition: CUVec2.h:997
float x
Definition: CUVec2.h:66
Vec2 getMap(std::function< float(float)> func) const
Definition: CUVec2.h:587
Vec2 getPerp() const
Definition: CUVec2.h:1226
static Vec2 * negate(const Vec2 &v, Vec2 *dst)
static Vec2 * clamp(const Vec2 &v, const Vec2 &min, const Vec2 &max, Vec2 *dst)
float y
Definition: CUVec2.h:68
static Vec2 * add(const Vec2 &v1, const Vec2 &v2, Vec2 *dst)
static const Vec2 ONE
Definition: CUVec2.h:73
Vec2 & map(std::function< float(float)> func)
Definition: CUVec2.h:572
static const Vec2 ANCHOR_MIDDLE_LEFT
Definition: CUVec2.h:92
Vec2 & operator-=(const Vec2 &v)
Definition: CUVec2.h:612
Vec2 & negate()
Definition: CUVec2.h:515
Vec2 & scale(float sx, float sy)
Definition: CUVec2.h:463
static Vec2 * subtract(const Vec2 &v1, const Vec2 &v2, Vec2 *dst)
static bool doesSegmentIntersect(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D)
Vec2 & operator=(const Vec2 &v)
Definition: CUVec2.h:153
std::string toString(bool verbose=false) const
Definition: CUVec2.h:61
Vec2 & perp()
Definition: CUVec2.h:1200
bool isOne() const
Definition: CUVec2.h:945
Vec2 & operator*=(float s)
Definition: CUVec2.h:623
Vec2 getRotation(const Vec2 &other)
Definition: CUVec2.h:1173
const Vec2 operator/(const Vec2 &v) const
Definition: CUVec2.h:755
Vec2 & scale(const Vec2 &v)
Definition: CUVec2.h:475
Vec2 getReciprocal() const
Definition: CUVec2.h:557
Vec2 & reciprocate()
Definition: CUVec2.h:529
const Vec2 operator-(const Vec2 &v) const
Definition: CUVec2.h:685
Vec2 getMidpoint(const Vec2 &other) const
Definition: CUVec2.h:1252
const Vec2 operator-(const Size &right) const
Definition: CUVec2.h:1585
Vec2 & subtract(float x, float y)
Definition: CUVec2.h:438
Vec2 & set(const Vec2 &v)
Definition: CUVec2.h:200
static const Vec2 ANCHOR_MIDDLE_BOTTOM
Definition: CUVec2.h:96
bool operator==(const Vec2 &v) const
Definition: CUVec2.h:833
Vec2(const Vec2 &p1, const Vec2 &p2)
Definition: CUVec2.h:127
bool under(const Vec2 &v) const
Definition: CUVec2.h:861
bool isZero() const
Definition: CUVec2.h:925
bool operator!=(const Vec2 &v) const
Definition: CUVec2.h:847
float length() const
Definition: CUVec2.h:1008
const Vec2 operator-() const
Definition: CUVec2.h:697
static float angle(const Vec2 &v1, const Vec2 &v2)
Vec2 & normalize()
Vec2 getClamp(const Vec2 &min, const Vec2 &max) const
Definition: CUVec2.h:389
Vec2 & operator=(const float *array)
Definition: CUVec2.h:164
Vec2 getLerp(const Vec2 &other, float alpha)
Definition: CUVec2.h:1311
static bool doesLineOverlap(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D)
static const Vec2 ANCHOR_TOP_RIGHT
Definition: CUVec2.h:88
static Vec2 * midpoint(const Vec2 &v1, const Vec2 &v2, Vec2 *dst)
static const Vec2 ANCHOR_MIDDLE_RIGHT
Definition: CUVec2.h:90
Vec2 getNormalization() const
Definition: CUVec2.h:1077
bool operator<=(const Vec2 &v) const
Definition: CUVec2.h:789
float lengthSquared() const
Definition: CUVec2.h:1024
Vec2 getRotation(float angle)
static Vec2 * divide(const Vec2 &v, float s, Vec2 *dst)
Vec2 Point2
Definition: CUVec2.h:1666
Vec2 & operator*=(const Vec2 &v)
Definition: CUVec2.h:634
float cross(const Vec2 &other) const
Definition: CUVec2.h:1050
bool operator<(const Vec2 &v) const
Definition: CUVec2.h:774
float getAngle() const
Definition: CUVec2.h:904
static const Vec2 ANCHOR_BOTTOM_LEFT
Definition: CUVec2.h:82
Vec2 & subtract(const Vec2 &v)
Definition: CUVec2.h:425
Vec2(const Vec2 &copy)
Definition: CUVec2.h:136
Vec2 & operator/=(float s)
Definition: CUVec2.h:645
const Vec2 operator*(const Vec2 &v) const
Definition: CUVec2.h:726
Definition: CUVec4.h:73
Vec2 getProjection(const Vec2 &other) const
Definition: CUVec2.h:1277
Vec2 getUnrotation(const Vec2 &other)
Definition: CUVec2.h:1189
static bool doesSegmentOverlap(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D, Vec2 *S=nullptr, Vec2 *E=nullptr)
const Vec2 operator*(float s) const
Definition: CUVec2.h:711
static const Vec2 ANCHOR_MIDDLE_TOP
Definition: CUVec2.h:94
Vec2 & add(const Vec2 &v)
Definition: CUVec2.h:400
static bool isLineParallel(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D)
static Vec2 * reciprocate(const Vec2 &v, Vec2 *dst)
const Vec2 operator+(const Vec2 &v) const
Definition: CUVec2.h:671
bool isNearZero(float variance=CU_MATH_EPSILON) const
Definition: CUVec2.h:936
Vec2(float x, float y)
Definition: CUVec2.h:112
Vec2 & lerp(const Vec2 &other, float alpha)
Definition: CUVec2.h:1294
bool isInvertible() const
Definition: CUVec2.h:954
~Vec2()
Definition: CUVec2.h:141
bool operator>=(const Vec2 &v) const
Definition: CUVec2.h:819
Vec2 & set(const float *array)
Definition: CUVec2.h:188
float dot(const Vec2 &v) const
Definition: CUVec2.h:1038
Vec2 getRPerp() const
Definition: CUVec2.h:1239
static Vec2 forAngle(const float a)
Definition: CUVec2.h:238
static const Vec2 UNIT_X
Definition: CUVec2.h:75
Vec2 & project(const Vec2 &other)
Definition: CUVec2.h:1263
bool equals(const Vec2 &v, float variance=CU_MATH_EPSILON) const
Definition: CUVec2.h:890
static Vec2 getIntersection(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D)
int operator*(Font::Style value)
Definition: CUFont.h:1503
Definition: CUVec3.h:61
const Vec2 operator+(const Size &right) const
Definition: CUVec2.h:1571
static bool doesLineIntersect(const Vec2 &A, const Vec2 &B, const Vec2 &C, const Vec2 &D, float *S=nullptr, float *T=nullptr)
static const Vec2 UNIT_Y
Definition: CUVec2.h:77
bool over(const Vec2 &v) const
Definition: CUVec2.h:875
Vec2 & rperp()
Definition: CUVec2.h:1212
Vec2 & set(float x, float y)
Definition: CUVec2.h:176
Definition: CUAnimationNode.h:52
Vec2 & rotate(const Vec2 &other)
Definition: CUVec2.h:1111
static const Vec2 ZERO
Definition: CUVec2.h:71
Vec2 & set(const Vec2 &p1, const Vec2 &p2)
Definition: CUVec2.h:213
const Vec2 operator/(float s) const
Definition: CUVec2.h:740
Vec2 & unrotate(const Vec2 &other)
Definition: CUVec2.h:1129
static const Vec2 ANCHOR_BOTTOM_RIGHT
Definition: CUVec2.h:86
bool operator>(const Vec2 &v) const
Definition: CUVec2.h:804
Vec2 & rotate(float angle)
Vec2()
Definition: CUVec2.h:104
static const Vec2 ANCHOR_MIDDLE
Definition: CUVec2.h:80
static const Vec2 ANCHOR_TOP_LEFT
Definition: CUVec2.h:84
Vec2 & setZero()
Definition: CUVec2.h:223