CUGL 1.3
Cornell University Game Library
CUVec4.h
1 //
2 // CUVec4.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This module provides support for a 4d vector. It has support for basic
6 // arithmetic, as well as conversions to color formats. It also has
7 // homogenous vector support for Vec3.
8 //
9 // Because math objects are intended to be on the stack, we do not provide
10 // any shared pointer support in this class.
11 //
12 // This module is based on an original file from GamePlay3D: http://gameplay3d.org.
13 // It has been modified to support the CUGL framework.
14 //
15 // CUGL MIT License:
16 // This software is provided 'as-is', without any express or implied
17 // warranty. In no event will the authors be held liable for any damages
18 // arising from the use of this software.
19 //
20 // Permission is granted to anyone to use this software for any purpose,
21 // including commercial applications, and to alter it and redistribute it
22 // freely, subject to the following restrictions:
23 //
24 // 1. The origin of this software must not be misrepresented; you must not
25 // claim that you wrote the original software. If you use this software
26 // in a product, an acknowledgment in the product documentation would be
27 // appreciated but is not required.
28 //
29 // 2. Altered source versions must be plainly marked as such, and must not
30 // be misrepresented as being the original software.
31 //
32 // 3. This notice may not be removed or altered from any source distribution.
33 //
34 // Author: Walker White
35 // Version: 5/30/16
36 
37 #ifndef __CU_VEC4_H__
38 #define __CU_VEC4_H__
39 
40 #include <math.h>
41 #include <functional>
42 #include <cugl/util/CUDebug.h>
43 #include "CUMathBase.h"
44 #include "CURect.h"
45 
46 namespace cugl {
47 
48 // Forward reference for conversions
49 class Color4;
50 class Color4f;
51 class Vec2;
52 class Vec3;
53 
64 class Vec4 {
65 
66 #pragma mark Values
67 public:
68 #if defined CU_MATH_VECTOR_SSE
69  union {
70  __attribute__((__aligned__(16))) struct {
72  float x;
74  float y;
76  float z;
78  float w;
79  };
80  __m128 v;
81  };
82 #elif defined CU_MATH_VECTOR_NEON64
83  union {
84  __attribute__((__aligned__(16))) struct {
86  float x;
88  float y;
90  float z;
92  float w;
93  };
94  float32x4_t v;
95  };
96 #else
97 
98  float x;
100  float y;
102  float z;
104  float w;
105 #endif
106 
108  static const Vec4 ZERO;
110  static const Vec4 ONE;
112  static const Vec4 UNIT_X;
114  static const Vec4 UNIT_Y;
116  static const Vec4 UNIT_Z;
118  static const Vec4 UNIT_W;
119 
120  // Homogenous constants
122  static const Vec4 HOMOG_ORIGIN;
124  static const Vec4 HOMOG_X;
126  static const Vec4 HOMOG_Y;
128  static const Vec4 HOMOG_Z;
129 
130 #pragma mark -
131 #pragma mark Constructors
132 public:
136  Vec4() : x(0), y(0), z(0), w(0) {}
137 
146  Vec4(float x, float y, float z, float w) {
147  #if defined CU_MATH_VECTOR_SSE
148  v = _mm_set_ps(w, z, y, x);
149  #elif defined CU_MATH_VECTOR_NEON64
150  v = {x, y, z, w};
151  #else
152  this->x = x; this->y = y; this->z = z; this->w = w;
153  #endif
154  }
155 
163  Vec4(const float* array) {
164  std::memcpy(this, array, 4*sizeof(float));
165  }
166 
173  Vec4(const Vec4& p1, const Vec4& p2) {
174  #if defined CU_MATH_VECTOR_SSE
175  v = _mm_sub_ps(p2.v,p1.v);
176  #elif defined CU_MATH_VECTOR_NEON64
177  v = vsubq_f32(p2.v,p1.v);
178  #else
179  x = p2.x-p1.x; y = p2.y-p1.y; z = p2.z-p1.z; w = p2.w-p1.w;
180  #endif
181  }
182 
183 
184 #pragma mark -
185 #pragma mark Setters
186 
195  Vec4& operator=(const float* array) {
196  return set(array);
197  }
198 
209  Vec4& set(float x, float y, float z, float w) {
210  #if defined CU_MATH_VECTOR_SSE
211  v = _mm_set_ps(w, z, y, x);
212  #elif defined CU_MATH_VECTOR_NEON64
213  v = {x, y, z, w};
214  #else
215  this->x = x; this->y = y; this->z = z; this->w = w;
216  #endif
217  return *this;
218  }
219 
229  Vec4& set(const float* array) {
230  std::memcpy(this, array, 4*sizeof(float));
231  return *this;
232  }
233 
241  Vec4& set(const Vec4& v) {
242  #if defined CU_MATH_VECTOR_SSE || defined CU_MATH_VECTOR_NEON64
243  this->v = v.v;
244  #else
245  x = v.x; y = v.y; z = v.z; w = v.w;
246  #endif
247  return *this;
248  }
249 
258  Vec4& set(const Vec4& p1, const Vec4& p2) {
259  #if defined CU_MATH_VECTOR_SSE
260  v = _mm_sub_ps(p2.v,p1.v);
261  #elif defined CU_MATH_VECTOR_NEON64
262  v = vsubq_f32(p2.v,p1.v);
263  #else
264  x = p2.x-p1.x; y = p2.y-p1.y; z = p2.z-p1.z; w = p2.w-p1.w;
265  #endif
266  return *this;
267  }
268 
275  #if defined CU_MATH_VECTOR_SSE
276  v = _mm_setzero_ps();
277  #elif defined CU_MATH_VECTOR_NEON64
278  v = vmovq_n_f32(0.0f);
279  #else
280  x = y = z = w = 0;
281  #endif
282  return *this;
283  }
284 
285 
286 #pragma mark -
287 #pragma mark Static Arithmetic
288 
298  static Vec4* clamp(const Vec4& v, const Vec4& min, const Vec4& max, Vec4* dst);
299 
315  static float angle(const Vec4& v1, const Vec4& v2);
316 
326  static Vec4* add(const Vec4& v1, const Vec4& v2, Vec4* dst);
327 
339  static Vec4* subtract(const Vec4& v1, const Vec4& v2, Vec4* dst);
340 
352  static Vec4* scale(const Vec4& v, float s, Vec4* dst);
353 
365  static Vec4* scale(const Vec4& v1, const Vec4& v2, Vec4* dst);
366 
378  static Vec4* divide(const Vec4& v, float s, Vec4* dst);
379 
391  static Vec4* divide(const Vec4& v1, const Vec4& v2, Vec4* dst);
392 
405  static Vec4* reciprocate(const Vec4& v, Vec4* dst);
406 
415  static Vec4* negate(const Vec4& v, Vec4* dst);
416 
417 
418 #pragma mark -
419 #pragma mark Arithmetic
420 
428  Vec4& clamp(const Vec4& min, const Vec4& max);
429 
440  Vec4 getClamp(const Vec4& min, const Vec4& max) const {
441  return Vec4(clampf(x,min.x,max.x), clampf(y,min.y,max.y),
442  clampf(z,min.z,max.z), clampf(w,min.w,max.w));
443  }
444 
452  Vec4& add(const Vec4& v) {
453  #if defined CU_MATH_VECTOR_SSE
454  this->v = _mm_add_ps(this->v,v.v);
455  #elif defined CU_MATH_VECTOR_NEON64
456  this->v = vaddq_f32(this->v,v.v);
457  #else
458  x += v.x; y += v.y; z += v.z; w += v.w;
459  #endif
460  return *this;
461  }
462 
473  Vec4& add(float x, float y, float z, float w) {
474  #if defined CU_MATH_VECTOR_SSE
475  this->v = _mm_add_ps(this->v,_mm_set_ps(w, z, y, x));
476  #elif defined CU_MATH_VECTOR_NEON64
477  float32x4_t tmp = {x, y, z, w};
478  this->v = vaddq_f32(this->v,tmp);
479  #else
480  this->x += x; this->y += y; this->z += z; this->w += w;
481  #endif
482  return *this;
483  }
484 
492  Vec4& subtract(const Vec4& v) {
493  #if defined CU_MATH_VECTOR_SSE
494  this->v = _mm_sub_ps(this->v,v.v);
495  #elif defined CU_MATH_VECTOR_NEON64
496  this->v = vsubq_f32(this->v,v.v);
497  #else
498  x -= v.x; y -= v.y; z -= v.z; w -= v.w;
499  #endif
500  return *this;
501  }
502 
513  Vec4& subtract(float x, float y, float z, float w) {
514  #if defined CU_MATH_VECTOR_SSE
515  this->v = _mm_sub_ps(this->v,_mm_set_ps(w, z, y, x));
516  #elif defined CU_MATH_VECTOR_NEON64
517  float32x4_t tmp = {x, y, z, w};
518  this->v = vsubq_f32(this->v,tmp);
519  #else
520  this->x -= x; this->y -= y; this->z -= z; this->w -= w;
521  #endif
522  return *this;
523  }
524 
532  Vec4& scale(float s) {
533  #if defined CU_MATH_VECTOR_SSE
534  v = _mm_mul_ps(v,_mm_set1_ps(s));
535  #elif defined CU_MATH_VECTOR_NEON64
536  v = vmulq_n_f32(v,(float32_t)s);
537  #else
538  x *= s; y *= s; z *= s; w *= s;
539  #endif
540  return *this;
541  }
542 
553  Vec4& scale(float sx, float sy, float sz, float sw) {
554  #if defined CU_MATH_VECTOR_SSE
555  v = _mm_mul_ps(v,_mm_set_ps(sw, sz, sy, sx));
556  #elif defined CU_MATH_VECTOR_NEON64
557  float32x4_t tmp = {sx, sy, sz, sw};
558  v = vmulq_f32(v,tmp);
559  #else
560  x *= sx; y *= sy; z *= sz; w *= sw;
561  #endif
562  return *this;
563  }
564 
572  Vec4& scale(const Vec4& v) {
573  #if defined CU_MATH_VECTOR_SSE
574  this->v = _mm_mul_ps(this->v,v.v);
575  #elif defined CU_MATH_VECTOR_NEON64
576  this->v = vmulq_f32(this->v,v.v);
577  #else
578  x *= v.x; y *= v.y; z *= v.z; w *= v.w;
579  #endif
580  return *this;
581  }
582 
590  Vec4& divide(float s);
591 
602  Vec4& divide(float sx, float sy, float sz, float sw);
603 
613  Vec4& divide(const Vec4& v);
614 
621  #if defined CU_MATH_VECTOR_SSE
622  v = _mm_sub_ps(_mm_setzero_ps(), v);
623  #elif defined CU_MATH_VECTOR_NEON64
624  v = vsubq_f32(vmovq_n_f32(0.0f), v);
625  #else
626  x = -x; y = -y; z = -z; w = -w;
627  #endif
628  return *this;
629  }
630 
640  Vec4& reciprocate();
641 
649  Vec4 getNegation() const {
650  Vec4 result(*this);
651  return result.negate();
652  }
653 
665  Vec4 getReciprocal() const {
666  Vec4 result(*this);
667  return result.reciprocate();
668  }
669 
680  Vec4& map(std::function<float(float)> func) {
681  x = func(x); y = func(y); z = func(z); w = func(w);
682  return *this;
683  }
684 
695  Vec4 getMap(std::function<float(float)> func) const {
696  return Vec4(func(x), func(y), func(z), func(w));
697  }
698 
699 
700 #pragma mark -
701 #pragma mark Operators
702 
709  Vec4& operator+=(const Vec4& v) {
710  return add(v);
711  }
712 
720  Vec4& operator-=(const Vec4& v) {
721  return subtract(v);
722  }
723 
731  Vec4& operator*=(float s) {
732  return scale(s);
733  }
734 
742  Vec4& operator*=(const Vec4& v) {
743  return scale(v);
744  }
745 
753  Vec4& operator/=(float s) {
754  return divide(s);
755  }
756 
766  Vec4& operator/=(const Vec4& v) {
767  return divide(v);
768  }
769 
779  const Vec4 operator+(const Vec4& v) const {
780  Vec4 result(*this);
781  return result.add(v);
782  }
783 
793  const Vec4 operator-(const Vec4& v) const {
794  Vec4 result(*this);
795  return result.subtract(v);
796  }
797 
805  const Vec4 operator-() const {
806  Vec4 result(*this);
807  return result.negate();
808  }
809 
819  const Vec4 operator*(float s) const {
820  Vec4 result(*this);
821  return result.scale(s);
822  }
823 
834  const Vec4 operator*(const Vec4& v) const {
835  Vec4 result(*this);
836  return result.scale(v);
837  }
838 
848  const Vec4 operator/(float s) const {
849  Vec4 result(*this);
850  return result.divide(s);
851  }
852 
863  const Vec4 operator/(const Vec4& v) const {
864  Vec4 result(*this);
865  return result.divide(v);
866  }
867 
868 
869 #pragma mark -
870 #pragma mark Comparisons
871 
882  bool operator<(const Vec4& v) const;
883 
895  bool operator<=(const Vec4& v) const;
896 
908  bool operator>(const Vec4& v) const;
909 
921  bool operator>=(const Vec4& v) const;
922 
933  bool operator==(const Vec4& v) const;
934 
945  bool operator!=(const Vec4& v) const;
946 
957  bool under(const Vec4& v) const;
958 
969  bool over(const Vec4& v) const;
970 
982  bool equals(const Vec4& v, float variance=CU_MATH_EPSILON) const;
983 
984 #pragma mark -
985 #pragma mark Linear Attributes
986 
991  bool isZero() const;
992 
1000  bool isNearZero(float variance=CU_MATH_EPSILON) const {
1001  return equals(ZERO);
1002  }
1003 
1009  bool isOne() const;
1010 
1016  bool isInvertible() const;
1017 
1025  bool isUnit(float variance=CU_MATH_EPSILON) const {
1026  float dot = length()-1.0f;
1027  return fabsf(dot) <= variance;
1028  }
1029 
1035  bool isHomogenous() const {
1036  return w == 1.0f;
1037  }
1038 
1049  float getAngle(const Vec4& other) const;
1050 
1060  float distance(const Vec4& v) const {
1061  return sqrt(distanceSquared(v));
1062  }
1063 
1078  float distanceSquared(const Vec4& v) const;
1079 
1087  float length() const {
1088  return sqrt(lengthSquared());
1089  }
1090 
1103  float lengthSquared() const {
1104  #if defined CU_MATH_VECTOR_SSE
1105  return _mm_dp_ps(v,v,0xF1)[0];
1106  #else
1107  return x*x+y*y+z*z+w*w;
1108  #endif
1109  }
1110 
1111 
1112 #pragma mark -
1113 #pragma mark Linear Algebra
1114 
1121  float dot(const Vec4& v) const {
1122  return Vec4::dot(*this,v);
1123  }
1124 
1135  Vec4 cross(const Vec4& v) {
1136  Vec4 result;
1137  Vec4::cross(*this,v,&result);
1138  return result;
1139  }
1140 
1151  Vec4& normalize();
1152 
1165  Vec4 result(*this);
1166  return result.normalize();
1167  }
1168 
1178  Vec4 getMidpoint(const Vec4& other) const {
1179  Vec4 result;
1180  midpoint(*this,other, &result);
1181  return result;
1182  }
1183 
1191  Vec4& project(const Vec4& other) {
1192  *this = getProjection(other);
1193  return *this;
1194  }
1195 
1205  Vec4 getProjection(const Vec4& other) const {
1206  return other * (dot(other)/other.dot(other));
1207  }
1208 
1218  float dw = (w == 0 ? 1 : 1/w);
1219  *this *= dw; w = 1;
1220  return *this;
1221  }
1222 
1234  Vec4 copy(*this);
1235  copy.homogenize();
1236  return copy;
1237  }
1238 
1251  Vec4& lerp(const Vec4& other, float alpha) {
1252  *this *= (1.f - alpha);
1253  return *this += other * alpha;
1254  }
1255 
1268  Vec4 getLerp(const Vec4& other, float alpha) {
1269  return *this * (1.f - alpha) + other * alpha;
1270  }
1271 
1284  void smooth(const Vec4& target, float elapsed, float response);
1285 
1286 
1287 #pragma mark -
1288 #pragma mark Static Linear Algebra
1289 
1297  static float dot(const Vec4& v1, const Vec4& v2);
1298 
1311  static Vec4* cross(const Vec4& v1, const Vec4& v2, Vec4* dst);
1312 
1324  static Vec4* normalize(const Vec4& v, Vec4* dst);
1325 
1337  static Vec4* homogenize(const Vec4& v, Vec4* dst);
1338 
1348  static Vec4* midpoint(const Vec4& v1, const Vec4& v2, Vec4* dst);
1349 
1359  static Vec4* project(const Vec4& v1, const Vec4& v2, Vec4* dst);
1360 
1375  static Vec4* lerp(const Vec4& v1, const Vec4& v2, float alpha, Vec4* dst);
1376 
1377 
1378 #pragma mark -
1379 #pragma mark Conversion Methods
1380 public:
1391  std::string toString(bool verbose = false) const;
1392 
1394  operator std::string() const { return toString(); }
1395 
1397  operator Color4() const;
1398 
1407  explicit Vec4(Color4 color);
1408 
1419  Vec4& operator= (Color4 color);
1420 
1422  operator Color4f() const;
1423 
1431  explicit Vec4(const Color4f& color);
1432 
1442  Vec4& operator= (const Color4f& color);
1443 
1450  operator Vec2() const;
1451 
1460  explicit Vec4(const Vec2& v);
1461 
1472  Vec4& operator= (const Vec2& size);
1473 
1480  operator Vec3() const;
1481 
1490  explicit Vec4(const Vec3& v);
1491 
1500  Vec4(const Vec3& v, float w);
1501 
1512  Vec4& operator= (const Vec3& v);
1513 
1524  Vec4& set(const Vec3& v, float w);
1525 };
1526 
1527 
1528 #pragma mark -
1529 #pragma mark Friend Operations
1530 
1538  inline const Vec4 operator*(float x, const Vec4& v) {
1539  Vec4 result(v);
1540  return result.scale(x);
1541  }
1542 
1543 }
1544 
1545 #endif /* __CU_VEC4_H__ */
cugl::Vec4::operator*=
Vec4 & operator*=(float s)
Definition: CUVec4.h:731
cugl::Vec4::isZero
bool isZero() const
cugl::Vec4::subtract
static Vec4 * subtract(const Vec4 &v1, const Vec4 &v2, Vec4 *dst)
cugl::Vec4::operator<
bool operator<(const Vec4 &v) const
cugl::Vec4::getLerp
Vec4 getLerp(const Vec4 &other, float alpha)
Definition: CUVec4.h:1268
cugl::Vec4::getProjection
Vec4 getProjection(const Vec4 &other) const
Definition: CUVec4.h:1205
cugl::Vec4::map
Vec4 & map(std::function< float(float)> func)
Definition: CUVec4.h:680
cugl::Vec4
Definition: CUVec4.h:64
cugl::Vec4::subtract
Vec4 & subtract(const Vec4 &v)
Definition: CUVec4.h:492
cugl::Vec4::HOMOG_ORIGIN
static const Vec4 HOMOG_ORIGIN
Definition: CUVec4.h:122
cugl::Vec4::operator>
bool operator>(const Vec4 &v) const
cugl::Vec4::z
float z
Definition: CUVec4.h:102
cugl::Vec4::over
bool over(const Vec4 &v) const
cugl::Vec4::under
bool under(const Vec4 &v) const
cugl::Vec4::scale
Vec4 & scale(float sx, float sy, float sz, float sw)
Definition: CUVec4.h:553
cugl::Vec4::operator>=
bool operator>=(const Vec4 &v) const
cugl::Vec4::lengthSquared
float lengthSquared() const
Definition: CUVec4.h:1103
cugl::Vec4::distance
float distance(const Vec4 &v) const
Definition: CUVec4.h:1060
cugl::Vec4::angle
static float angle(const Vec4 &v1, const Vec4 &v2)
cugl::Vec4::divide
static Vec4 * divide(const Vec4 &v, float s, Vec4 *dst)
cugl::Vec4::UNIT_X
static const Vec4 UNIT_X
Definition: CUVec4.h:112
cugl::Vec4::ONE
static const Vec4 ONE
Definition: CUVec4.h:110
cugl::Vec4::UNIT_Z
static const Vec4 UNIT_Z
Definition: CUVec4.h:116
cugl::Vec4::set
Vec4 & set(float x, float y, float z, float w)
Definition: CUVec4.h:209
cugl::Vec4::Vec4
Vec4(const Vec4 &p1, const Vec4 &p2)
Definition: CUVec4.h:173
cugl::Color4
Definition: CUColor4.h:1084
cugl::Vec4::reciprocate
static Vec4 * reciprocate(const Vec4 &v, Vec4 *dst)
cugl::Vec4::scale
static Vec4 * scale(const Vec4 &v, float s, Vec4 *dst)
cugl::Vec4::y
float y
Definition: CUVec4.h:100
cugl::Vec4::isHomogenous
bool isHomogenous() const
Definition: CUVec4.h:1035
cugl::Vec4::add
Vec4 & add(float x, float y, float z, float w)
Definition: CUVec4.h:473
cugl::Vec4::operator=
Vec4 & operator=(const float *array)
Definition: CUVec4.h:195
cugl::Vec4::dot
float dot(const Vec4 &v) const
Definition: CUVec4.h:1121
cugl::Vec4::operator*
const Vec4 operator*(float s) const
Definition: CUVec4.h:819
cugl::Vec4::getReciprocal
Vec4 getReciprocal() const
Definition: CUVec4.h:665
cugl::Vec4::getHomogenized
Vec4 getHomogenized()
Definition: CUVec4.h:1233
cugl::Vec4::operator*=
Vec4 & operator*=(const Vec4 &v)
Definition: CUVec4.h:742
cugl::Vec4::getMap
Vec4 getMap(std::function< float(float)> func) const
Definition: CUVec4.h:695
cugl::Vec4::setZero
Vec4 & setZero()
Definition: CUVec4.h:274
cugl::Vec4::UNIT_W
static const Vec4 UNIT_W
Definition: CUVec4.h:118
cugl::Vec4::operator/=
Vec4 & operator/=(const Vec4 &v)
Definition: CUVec4.h:766
cugl::Vec4::w
float w
Definition: CUVec4.h:104
cugl::Vec4::smooth
void smooth(const Vec4 &target, float elapsed, float response)
cugl::Vec4::getNegation
Vec4 getNegation() const
Definition: CUVec4.h:649
cugl::Vec4::getMidpoint
Vec4 getMidpoint(const Vec4 &other) const
Definition: CUVec4.h:1178
cugl::Vec4::operator!=
bool operator!=(const Vec4 &v) const
cugl::Vec4::isNearZero
bool isNearZero(float variance=CU_MATH_EPSILON) const
Definition: CUVec4.h:1000
cugl::Vec4::project
Vec4 & project(const Vec4 &other)
Definition: CUVec4.h:1191
cugl::Vec4::operator<=
bool operator<=(const Vec4 &v) const
cugl::Vec4::scale
Vec4 & scale(float s)
Definition: CUVec4.h:532
cugl::Vec4::ZERO
static const Vec4 ZERO
Definition: CUVec4.h:108
cugl::Vec4::normalize
Vec4 & normalize()
cugl::Vec4::Vec4
Vec4(float x, float y, float z, float w)
Definition: CUVec4.h:146
cugl::Color4f
Definition: CUColor4.h:73
cugl::Vec4::HOMOG_X
static const Vec4 HOMOG_X
Definition: CUVec4.h:124
cugl::Vec4::set
Vec4 & set(const float *array)
Definition: CUVec4.h:229
cugl::Vec2
Definition: CUVec2.h:61
cugl::Vec4::operator==
bool operator==(const Vec4 &v) const
cugl::Vec4::Vec4
Vec4(const float *array)
Definition: CUVec4.h:163
cugl::Vec4::set
Vec4 & set(const Vec4 &v)
Definition: CUVec4.h:241
cugl::Vec4::operator+=
Vec4 & operator+=(const Vec4 &v)
Definition: CUVec4.h:709
cugl::Vec4::getClamp
Vec4 getClamp(const Vec4 &min, const Vec4 &max) const
Definition: CUVec4.h:440
cugl::Vec4::operator-
const Vec4 operator-(const Vec4 &v) const
Definition: CUVec4.h:793
cugl::Vec4::isUnit
bool isUnit(float variance=CU_MATH_EPSILON) const
Definition: CUVec4.h:1025
cugl::Vec4::Vec4
Vec4()
Definition: CUVec4.h:136
cugl::Vec4::toString
std::string toString(bool verbose=false) const
cugl::Vec4::midpoint
static Vec4 * midpoint(const Vec4 &v1, const Vec4 &v2, Vec4 *dst)
cugl::Vec4::cross
Vec4 cross(const Vec4 &v)
Definition: CUVec4.h:1135
cugl::Vec4::HOMOG_Y
static const Vec4 HOMOG_Y
Definition: CUVec4.h:126
cugl::Vec4::add
Vec4 & add(const Vec4 &v)
Definition: CUVec4.h:452
cugl::Vec4::operator-
const Vec4 operator-() const
Definition: CUVec4.h:805
cugl::Vec4::add
static Vec4 * add(const Vec4 &v1, const Vec4 &v2, Vec4 *dst)
cugl::Vec4::scale
Vec4 & scale(const Vec4 &v)
Definition: CUVec4.h:572
cugl::Vec4::operator/=
Vec4 & operator/=(float s)
Definition: CUVec4.h:753
cugl::Vec4::negate
Vec4 & negate()
Definition: CUVec4.h:620
cugl::Vec4::homogenize
Vec4 & homogenize()
Definition: CUVec4.h:1217
cugl::Vec4::UNIT_Y
static const Vec4 UNIT_Y
Definition: CUVec4.h:114
cugl::Vec4::length
float length() const
Definition: CUVec4.h:1087
cugl::Vec4::reciprocate
Vec4 & reciprocate()
cugl::Vec4::set
Vec4 & set(const Vec4 &p1, const Vec4 &p2)
Definition: CUVec4.h:258
cugl::Vec4::isInvertible
bool isInvertible() const
cugl::Vec4::operator/
const Vec4 operator/(float s) const
Definition: CUVec4.h:848
cugl::Vec4::operator-=
Vec4 & operator-=(const Vec4 &v)
Definition: CUVec4.h:720
cugl::Vec4::getAngle
float getAngle(const Vec4 &other) const
cugl::Vec4::operator+
const Vec4 operator+(const Vec4 &v) const
Definition: CUVec4.h:779
cugl::Vec4::clamp
static Vec4 * clamp(const Vec4 &v, const Vec4 &min, const Vec4 &max, Vec4 *dst)
cugl::Vec3
Definition: CUVec3.h:61
cugl::Vec4::x
float x
Definition: CUVec4.h:98
cugl::Vec4::isOne
bool isOne() const
cugl::Vec4::equals
bool equals(const Vec4 &v, float variance=CU_MATH_EPSILON) const
cugl::Vec4::operator/
const Vec4 operator/(const Vec4 &v) const
Definition: CUVec4.h:863
cugl::Vec4::negate
static Vec4 * negate(const Vec4 &v, Vec4 *dst)
cugl::Vec4::HOMOG_Z
static const Vec4 HOMOG_Z
Definition: CUVec4.h:128
cugl::Vec4::subtract
Vec4 & subtract(float x, float y, float z, float w)
Definition: CUVec4.h:513
cugl::Vec4::getNormalization
Vec4 getNormalization() const
Definition: CUVec4.h:1164
cugl::Vec4::lerp
Vec4 & lerp(const Vec4 &other, float alpha)
Definition: CUVec4.h:1251
cugl::Vec4::distanceSquared
float distanceSquared(const Vec4 &v) const
cugl::Vec4::operator*
const Vec4 operator*(const Vec4 &v) const
Definition: CUVec4.h:834