CUGL
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
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 zlib 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 // Vectorizaton support
41 #ifdef CU_MATH_VECTOR_APPLE
42  // Need this hack, because Apple dumps Size/Rect into empty namespace
43  #define VIMAGE_H
44  #include <Accelerate/Accelerate.h>
45 #endif
46 #ifdef CU_MATH_VECTOR_SSE
47  #include <xmmintrin.h>
48 #endif
49 
50 #include <math.h>
51 #include <functional>
52 #include "CUMathBase.h"
53 #include "CURect.h"
54 
55 namespace cugl {
56 
57 // Forward reference for conversions
58 class Color4;
59 class Color4f;
60 class Vec2;
61 class Vec3;
62 
73 class Vec4 {
74 
75 #pragma mark Values
76 public:
77 #if defined CU_MATH_VECTOR_APPLE
78  union {
79  struct {
81  float x;
83  float y;
85  float z;
87  float w;
88  };
89  vFloat v;
90  };
91 #elif defined CU_MATH_VECTOR_SSE
92  __declspec(align(32)) union {
93  struct {
95  float x;
97  float y;
99  float z;
101  float w;
102  };
103  __m128 v;
104  };
105 #else
106 
107  float x;
109  float y;
111  float z;
113  float w;
114 #endif
115 
117  static const Vec4 ZERO;
119  static const Vec4 ONE;
121  static const Vec4 UNIT_X;
123  static const Vec4 UNIT_Y;
125  static const Vec4 UNIT_Z;
127  static const Vec4 UNIT_W;
128 
129  // Homogenous constants
131  static const Vec4 HOMOG_ORIGIN;
133  static const Vec4 HOMOG_X;
135  static const Vec4 HOMOG_Y;
137  static const Vec4 HOMOG_Z;
138 
139 #pragma mark -
140 #pragma mark Constructors
141 public:
145  Vec4() : x(0), y(0), z(0), w(0) {}
146 
155  Vec4(float x, float y, float z, float w) {
156  this->x = x; this->y = y; this->z = z; this->w = w;
157  }
158 
166  Vec4(const float* array) {
167 #if defined CU_MATH_VECTOR_APPLE
168  v = *((vFloat*)array);
169 #else
170  x = array[0]; y = array[1]; z = array[2]; w = array[3];
171 #endif
172  }
173 
180  Vec4(const Vec4& p1, const Vec4& p2) {
181 #if defined CU_MATH_VECTOR_APPLE
182  v = p2.v-p1.v;
183 #else
184  x = p2.x-p1.x; y = p2.y-p1.y; z = p2.z-p1.z; w = p2.w-p1.w;
185 #endif
186  }
187 
193  Vec4(const Vec4& copy) {
194 #if defined CU_MATH_VECTOR_APPLE
195  v = copy.v;
196 #else
197  x = copy.x; y = copy.y; z = copy.z; w = copy.w;
198 #endif
199  }
200 
204  ~Vec4() {}
205 
206 #pragma mark -
207 #pragma mark Setters
208 
215  Vec4& operator=(const Vec4& v) {
216  return set(v);
217  }
218 
228  Vec4& operator=(const float* array) {
229  return set(array);
230  }
231 
242  Vec4& set(float x, float y, float z, float w) {
243  this->x = x; this->y = y; this->z = z; this->w = w;
244  return *this;
245  }
246 
256  Vec4& set(const float* array) {
257 #if defined CU_MATH_VECTOR_APPLE
258  v = *((vFloat*)array);
259 #else
260  x = array[0]; y = array[1]; z = array[2]; w = array[3];
261 #endif
262  return *this;
263  }
264 
272  Vec4& set(const Vec4& v) {
273 #if defined CU_MATH_VECTOR_APPLE
274  this->v = v.v;
275 #else
276  x = v.x; y = v.y; z = v.z; w = v.w;
277 #endif
278  return *this;
279  }
280 
289  Vec4& set(const Vec4& p1, const Vec4& p2) {
290 #if defined CU_MATH_VECTOR_APPLE
291  v = p2.v-p1.v;
292 #else
293  x = p2.x-p1.x; y = p2.y-p1.y; z = p2.z-p1.z; w = p2.w-p1.w;
294 #endif
295  return *this;
296  }
297 
304  x = y = z = w = 0;
305  return *this;
306  }
307 
308 
309 #pragma mark -
310 #pragma mark Static Arithmetic
311 
321  static Vec4* clamp(const Vec4& v, const Vec4& min, const Vec4& max, Vec4* dst);
322 
338  static float angle(const Vec4& v1, const Vec4& v2);
339 
349  static Vec4* add(const Vec4& v1, const Vec4& v2, Vec4* dst);
350 
362  static Vec4* subtract(const Vec4& v1, const Vec4& v2, Vec4* dst);
363 
375  static Vec4* scale(const Vec4& v, float s, Vec4* dst);
376 
388  static Vec4* scale(const Vec4& v1, const Vec4& v2, Vec4* dst);
389 
401  static Vec4* divide(const Vec4& v, float s, Vec4* dst);
402 
414  static Vec4* divide(const Vec4& v1, const Vec4& v2, Vec4* dst);
415 
428  static Vec4* reciprocate(const Vec4& v, Vec4* dst);
429 
438  static Vec4* negate(const Vec4& v, Vec4* dst);
439 
440 
441 #pragma mark -
442 #pragma mark Arithmetic
443 
451  Vec4& clamp(const Vec4& min, const Vec4& max);
452 
463  Vec4 getClamp(const Vec4& min, const Vec4& max) const {
464  return Vec4(clampf(x,min.x,max.x), clampf(y,min.y,max.y),
465  clampf(z,min.z,max.z), clampf(w,min.w,max.w));
466  }
467 
475  Vec4& add(const Vec4& v) {
476 #if defined CU_MATH_VECTOR_APPLE
477  this->v += v.v;
478 #else
479  x += v.x; y += v.y; z += v.z; w += v.w;
480 #endif
481  return *this;
482  }
483 
494  Vec4& add(float x, float y, float z, float w) {
495  this->x += x; this->y += y; this->z += z; this->w += w;
496  return *this;
497  }
498 
506  Vec4& subtract(const Vec4& v) {
507 #if defined CU_MATH_VECTOR_APPLE
508  this->v -= v.v;
509 #else
510  x -= v.x; y -= v.y; z -= v.z; w -= v.w;
511 #endif
512  return *this;
513  }
514 
525  Vec4& subtract(float x, float y, float z, float w) {
526  this->x -= x; this->y -= y; this->z -= z; this->w -= w;
527  return *this;
528  }
529 
537  Vec4& scale(float s) {
538 #if defined CU_MATH_VECTOR_APPLE
539  vSscal(4, s, &v);
540 #else
541  x *= s; y *= s; z *= s; w *= s;
542 #endif
543  return *this;
544  }
545 
556  Vec4& scale(float sx, float sy, float sz, float sw) {
557  x *= sx; y *= sy; z *= sz; w *= sw;
558  return *this;
559  }
560 
568  Vec4& scale(const Vec4& v) {
569 #if defined CU_MATH_VECTOR_APPLE
570  this->v *= v.v;
571 #else
572  x *= v.x; y *= v.y; z *= v.z; w *= v.w;
573 #endif
574  return *this;
575  }
576 
584  Vec4& divide(float s);
585 
596  Vec4& divide(float sx, float sy, float sz, float sw);
597 
607  Vec4& divide(const Vec4& v);
608 
615  x = -x; y = -y; z = -z; w = -w;
616  return *this;
617  }
618 
629  x = 1.0f/x; y = 1.0f/y; z = 1.0f/z; w = 1.0f/w;
630  return *this;
631  }
632 
640  Vec4 getNegation() const {
641  Vec4 result(*this);
642  return result.negate();
643  }
644 
656  Vec4 getReciprocal() const {
657  Vec4 result(*this);
658  return result.reciprocate();
659  }
660 
671  Vec4& map(std::function<float(float)> func) {
672  x = func(x); y = func(y); z = func(z); w = func(w);
673  return *this;
674  }
675 
686  Vec4 getMap(std::function<float(float)> func) const {
687  return Vec4(func(x), func(y), func(z), func(w));
688  }
689 
690 
691 #pragma mark -
692 #pragma mark Operators
693 
700  Vec4& operator+=(const Vec4& v) {
701  return add(v);
702  }
703 
711  Vec4& operator-=(const Vec4& v) {
712  return subtract(v);
713  }
714 
722  Vec4& operator*=(float s) {
723  return scale(s);
724  }
725 
733  Vec4& operator*=(const Vec4& v) {
734  return scale(v);
735  }
736 
744  Vec4& operator/=(float s) {
745  return divide(s);
746  }
747 
757  Vec4& operator/=(const Vec4& v) {
758  return divide(v);
759  }
760 
770  const Vec4 operator+(const Vec4& v) const {
771  Vec4 result(*this);
772  return result.add(v);
773  }
774 
784  const Vec4 operator-(const Vec4& v) const {
785  Vec4 result(*this);
786  return result.subtract(v);
787  }
788 
796  const Vec4 operator-() const {
797  Vec4 result(*this);
798  return result.negate();
799  }
800 
810  const Vec4 operator*(float s) const {
811  Vec4 result(*this);
812  return result.scale(s);
813  }
814 
825  const Vec4 operator*(const Vec4& v) const {
826  Vec4 result(*this);
827  return result.scale(v);
828  }
829 
839  const Vec4 operator/(float s) const {
840  Vec4 result(*this);
841  return result.divide(s);
842  }
843 
854  const Vec4 operator/(const Vec4& v) const {
855  Vec4 result(*this);
856  return result.divide(v);
857  }
858 
859 
860 #pragma mark -
861 #pragma mark Comparisons
862 
873  bool operator<(const Vec4& v) const {
874  return (x == v.x ? (y == v.y ? (z == v.z ? w < v.w : z < v.z) : y < v.y) : x < v.x);
875  }
876 
888  bool operator<=(const Vec4& v) const {
889  return (x == v.x ? (y == v.y ? (z == v.z ? w <= v.w : z <= v.z) : y <= v.y) : x <= v.x);
890  }
891 
903  bool operator>(const Vec4& v) const {
904  return (x == v.x ? (y == v.y ? (z == v.z ? w > v.w : z > v.z) : y > v.y) : x > v.x);
905  }
906 
918  bool operator>=(const Vec4& v) const {
919  return (x == v.x ? (y == v.y ? (z == v.z ? w >= v.w : z >= v.z) : y >= v.y) : x >= v.x);
920  }
921 
932  bool operator==(const Vec4& v) const {
933  return x == v.x && y == v.y && z == v.z && w == v.w;
934  }
935 
946  bool operator!=(const Vec4& v) const {
947  return x != v.x || y != v.y || z != v.z || w != v.w;
948  }
949 
960  bool under(const Vec4& v) const {
961  return x <= v.x && y <= v.y && z <= v.z && w <= v.w;
962  }
963 
974  bool over(const Vec4& v) const {
975  return x >= v.x && y >= v.y && z >= v.z && w >= v.w;
976  }
977 
989  bool equals(const Vec4& v, float variance=CU_MATH_EPSILON) const {
990  return distanceSquared(v) <= variance*variance;
991  }
992 
993 
994 #pragma mark -
995 #pragma mark Linear Attributes
996 
1001  bool isZero() const {
1002  return x == 0.0f && y == 0.0f && z == 0.0f && w == 0.0f;
1003  }
1004 
1012  bool isNearZero(float variance=CU_MATH_EPSILON) const {
1013  return lengthSquared() <= variance*variance;
1014  }
1015 
1021  bool isOne() const {
1022  return x == 1.0f && y == 1.0f && z == 1.0f && w == 1.0f;
1023  }
1024 
1030  bool isInvertible() const {
1031  return x != 0.0f && y != 0.0f && z != 0.0f && w != 0.0f;
1032  }
1033 
1041  bool isUnit(float variance=CU_MATH_EPSILON) const {
1042  float dot = length()-1.0f;
1043  return dot <= variance && dot >= -variance;
1044  }
1045 
1051  bool isHomogenous() const {
1052  return w == 1.0f;
1053  }
1054 
1065  float getAngle(const Vec4& other) const;
1066 
1076  float distance(const Vec4& v) const {
1077 #if defined CU_MATH_VECTOR_APPLE
1078  vFloat nv = this->v-v.v;
1079  return vSnorm2(4, &nv);
1080 #else
1081  return sqrt(distanceSquared(v));
1082 #endif
1083  }
1084 
1099  float distanceSquared(const Vec4& v) const {
1100 #if defined CU_MATH_VECTOR_APPLE
1101  vFloat nv = this->v-v.v;
1102  return vSdot(4, &nv, &nv);
1103 #else
1104  return (x-v.x)*(x-v.x)+(y-v.y)*(y-v.y)+(z-v.z)*(z-v.z)+(w-v.w)*(w-v.w);
1105 #endif
1106  }
1107 
1115  float length() const {
1116 #if defined CU_MATH_VECTOR_APPLE
1117  return vSnorm2(4, &v);
1118 #else
1119  return sqrt(lengthSquared());
1120 #endif
1121  }
1122 
1135  float lengthSquared() const {
1136 #if defined CU_MATH_VECTOR_APPLE
1137  return vSdot(4, &v, &v);
1138 #else
1139  return x*x+y*y+z*z+w*w;
1140 #endif
1141  }
1142 
1143 
1144 #pragma mark -
1145 #pragma mark Linear Algebra
1146 
1153  float dot(const Vec4& v) const {
1154 #if defined CU_MATH_VECTOR_APPLE
1155  return vSdot(4, &(this->v), &(v.v));
1156 #else
1157  return (x * v.x + y * v.y + z * v.z + w * v.w);
1158 #endif
1159  }
1160 
1171  Vec4& normalize();
1172 
1185  Vec4 result(*this);
1186  return result.normalize();
1187  }
1188 
1198  Vec4 getMidpoint(const Vec4& other) const {
1199  Vec4 result;
1200  midpoint(*this,other, &result);
1201  return result;
1202  }
1203 
1211  Vec4& project(const Vec4& other) {
1212  *this = getProjection(other);
1213  return *this;
1214  }
1215 
1225  Vec4 getProjection(const Vec4& other) const {
1226  return other * (dot(other)/other.dot(other));
1227  }
1228 
1238  float dw = (w == 0 ? 1 : 1/w);
1239  *this *= dw; w = 1;
1240  return *this;
1241  }
1242 
1254  Vec4 copy(*this);
1255  copy.homogenize();
1256  return copy;
1257  }
1258 
1271  Vec4& lerp(const Vec4& other, float alpha) {
1272  *this *= (1.f - alpha);
1273  return *this += other * alpha;
1274  }
1275 
1288  Vec4 getLerp(const Vec4& other, float alpha) {
1289  return *this * (1.f - alpha) + other * alpha;
1290  }
1291 
1304  void smooth(const Vec4& target, float elapsed, float response);
1305 
1306 
1307 #pragma mark -
1308 #pragma mark Static Linear Algebra
1309 
1317  static float dot(const Vec4& v1, const Vec4& v2);
1318 
1330  static Vec4* normalize(const Vec4& v, Vec4* dst);
1331 
1343  static Vec4* homogenize(const Vec4& v, Vec4* dst);
1344 
1354  static Vec4* midpoint(const Vec4& v1, const Vec4& v2, Vec4* dst);
1355 
1365  static Vec4* project(const Vec4& v1, const Vec4& v2, Vec4* dst);
1366 
1381  static Vec4* lerp(const Vec4& v1, const Vec4& v2, float alpha, Vec4* dst);
1382 
1383 #pragma mark -
1384 #pragma mark Conversion Methods
1385 public:
1396  std::string toString(bool verbose = false) const;
1397 
1399  operator std::string() const { return toString(); }
1400 
1402  operator Color4() const;
1403 
1412  explicit Vec4(Color4 color);
1413 
1424  Vec4& operator= (Color4 color);
1425 
1427  operator Color4f() const;
1428 
1436  explicit Vec4(const Color4f& color);
1437 
1447  Vec4& operator= (const Color4f& color);
1448 
1455  operator Vec2() const;
1456 
1465  explicit Vec4(const Vec2& v);
1466 
1477  Vec4& operator= (const Vec2& size);
1478 
1485  operator Vec3() const;
1486 
1495  explicit Vec4(const Vec3& v);
1496 
1505  Vec4(const Vec3& v, float w);
1506 
1517  Vec4& operator= (const Vec3& v);
1518 
1529  Vec4& set(const Vec3& v, float w);
1530 };
1531 
1532 
1533 #pragma mark -
1534 #pragma mark Friend Operations
1535 
1543  inline const Vec4 operator*(float x, const Vec4& v) {
1544  Vec4 result(v);
1545  return result.scale(x);
1546  }
1547 
1548 }
1549 
1550 #endif /* __CU_VEC4_H__ */
Vec4(const Vec4 &copy)
Definition: CUVec4.h:193
bool isZero() const
Definition: CUVec4.h:1001
Vec4 & set(const Vec4 &v)
Definition: CUVec4.h:272
static const Vec4 ZERO
Definition: CUVec4.h:117
Vec4(const Vec4 &p1, const Vec4 &p2)
Definition: CUVec4.h:180
Vec4 & add(float x, float y, float z, float w)
Definition: CUVec4.h:494
bool isNearZero(float variance=CU_MATH_EPSILON) const
Definition: CUVec4.h:1012
static Vec4 * negate(const Vec4 &v, Vec4 *dst)
static Vec4 * subtract(const Vec4 &v1, const Vec4 &v2, Vec4 *dst)
static const Vec4 ONE
Definition: CUVec4.h:119
static const Vec4 UNIT_W
Definition: CUVec4.h:127
Vec4(float x, float y, float z, float w)
Definition: CUVec4.h:155
Vec4 & add(const Vec4 &v)
Definition: CUVec4.h:475
Definition: CUVec2.h:61
const Vec4 operator-() const
Definition: CUVec4.h:796
float dot(const Vec4 &v) const
Definition: CUVec4.h:1153
bool isHomogenous() const
Definition: CUVec4.h:1051
Vec4 & subtract(const Vec4 &v)
Definition: CUVec4.h:506
Vec4 & operator*=(const Vec4 &v)
Definition: CUVec4.h:733
float z
Definition: CUVec4.h:111
static const Vec4 HOMOG_Y
Definition: CUVec4.h:135
Vec4 & operator*=(float s)
Definition: CUVec4.h:722
static Vec4 * scale(const Vec4 &v, float s, Vec4 *dst)
const Vec4 operator*(const Vec4 &v) const
Definition: CUVec4.h:825
static const Vec4 HOMOG_X
Definition: CUVec4.h:133
Vec4 & operator/=(float s)
Definition: CUVec4.h:744
Vec4 getHomogenized()
Definition: CUVec4.h:1253
Vec4 & setZero()
Definition: CUVec4.h:303
static const Vec4 HOMOG_ORIGIN
Definition: CUVec4.h:131
const Vec4 operator*(float s) const
Definition: CUVec4.h:810
bool operator<=(const Vec4 &v) const
Definition: CUVec4.h:888
Vec4 & scale(float s)
Definition: CUVec4.h:537
Vec4 & negate()
Definition: CUVec4.h:614
bool operator<(const Vec4 &v) const
Definition: CUVec4.h:873
Vec4(const float *array)
Definition: CUVec4.h:166
Vec4 getNegation() const
Definition: CUVec4.h:640
Definition: CUColor4.h:73
Vec4 getLerp(const Vec4 &other, float alpha)
Definition: CUVec4.h:1288
Vec4 & set(const Vec4 &p1, const Vec4 &p2)
Definition: CUVec4.h:289
static const Vec4 UNIT_X
Definition: CUVec4.h:121
const Vec4 operator/(float s) const
Definition: CUVec4.h:839
float lengthSquared() const
Definition: CUVec4.h:1135
static const Vec4 UNIT_Y
Definition: CUVec4.h:123
bool over(const Vec4 &v) const
Definition: CUVec4.h:974
void smooth(const Vec4 &target, float elapsed, float response)
float y
Definition: CUVec4.h:109
Vec4 getReciprocal() const
Definition: CUVec4.h:656
bool operator>(const Vec4 &v) const
Definition: CUVec4.h:903
static const Vec4 UNIT_Z
Definition: CUVec4.h:125
const Vec4 operator-(const Vec4 &v) const
Definition: CUVec4.h:784
static const Vec4 HOMOG_Z
Definition: CUVec4.h:137
Vec4 & map(std::function< float(float)> func)
Definition: CUVec4.h:671
Vec4 & operator/=(const Vec4 &v)
Definition: CUVec4.h:757
bool operator>=(const Vec4 &v) const
Definition: CUVec4.h:918
Vec4()
Definition: CUVec4.h:145
static Vec4 * midpoint(const Vec4 &v1, const Vec4 &v2, Vec4 *dst)
static float angle(const Vec4 &v1, const Vec4 &v2)
float distanceSquared(const Vec4 &v) const
Definition: CUVec4.h:1099
bool under(const Vec4 &v) const
Definition: CUVec4.h:960
float distance(const Vec4 &v) const
Definition: CUVec4.h:1076
Definition: CUVec4.h:73
Vec4 & reciprocate()
Definition: CUVec4.h:628
~Vec4()
Definition: CUVec4.h:204
bool isInvertible() const
Definition: CUVec4.h:1030
Vec4 getMidpoint(const Vec4 &other) const
Definition: CUVec4.h:1198
Vec4 & normalize()
const Vec4 operator+(const Vec4 &v) const
Definition: CUVec4.h:770
Vec4 & lerp(const Vec4 &other, float alpha)
Definition: CUVec4.h:1271
std::string toString(bool verbose=false) const
static Vec4 * clamp(const Vec4 &v, const Vec4 &min, const Vec4 &max, Vec4 *dst)
static Vec4 * reciprocate(const Vec4 &v, Vec4 *dst)
float getAngle(const Vec4 &other) const
Vec4 & operator-=(const Vec4 &v)
Definition: CUVec4.h:711
Vec4 & set(const float *array)
Definition: CUVec4.h:256
bool equals(const Vec4 &v, float variance=CU_MATH_EPSILON) const
Definition: CUVec4.h:989
Vec4 getNormalization() const
Definition: CUVec4.h:1184
float length() const
Definition: CUVec4.h:1115
int operator*(Font::Style value)
Definition: CUFont.h:1503
bool operator==(const Vec4 &v) const
Definition: CUVec4.h:932
Vec4 & scale(const Vec4 &v)
Definition: CUVec4.h:568
Definition: CUVec3.h:61
Vec4 & set(float x, float y, float z, float w)
Definition: CUVec4.h:242
Vec4 getMap(std::function< float(float)> func) const
Definition: CUVec4.h:686
float x
Definition: CUVec4.h:107
Vec4 & operator+=(const Vec4 &v)
Definition: CUVec4.h:700
Vec4 & project(const Vec4 &other)
Definition: CUVec4.h:1211
bool operator!=(const Vec4 &v) const
Definition: CUVec4.h:946
Definition: CUColor4.h:1104
Vec4 & operator=(const Vec4 &v)
Definition: CUVec4.h:215
Vec4 getClamp(const Vec4 &min, const Vec4 &max) const
Definition: CUVec4.h:463
Vec4 & operator=(const float *array)
Definition: CUVec4.h:228
Definition: CUAnimationNode.h:52
Vec4 getProjection(const Vec4 &other) const
Definition: CUVec4.h:1225
const Vec4 operator/(const Vec4 &v) const
Definition: CUVec4.h:854
bool isOne() const
Definition: CUVec4.h:1021
float w
Definition: CUVec4.h:113
Vec4 & homogenize()
Definition: CUVec4.h:1237
static Vec4 * divide(const Vec4 &v, float s, Vec4 *dst)
Vec4 & subtract(float x, float y, float z, float w)
Definition: CUVec4.h:525
Vec4 & scale(float sx, float sy, float sz, float sw)
Definition: CUVec4.h:556
bool isUnit(float variance=CU_MATH_EPSILON) const
Definition: CUVec4.h:1041
static Vec4 * add(const Vec4 &v1, const Vec4 &v2, Vec4 *dst)