Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SbVec.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2018 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23#ifndef _SB_VEC_
24#define _SB_VEC_
25
26#include <Inventor/SbBase.h>
27#include <Inventor/SbMathHelper.h>
28#include <Inventor/STL/iostream>
29#include <string.h>
30
31class SbVec2d;
32class SbVec3d;
33class SbVec3s;
34class SbVec4d;
35class SbPlane;
36
38//
39// Class: SbVec2f
40//
41// 2D vector used to represent points or directions. Each component of
42// the vector is a float.
43//
45
76class SbVec2f {
77public:
78
82 SbVec2f() { memset(vec, 0, sizeof(vec)); }
83
87 explicit SbVec2f(const float v[2]) { setValue(v); }
88
92 SbVec2f(float x, float y) { setValue(x, y); }
93
97 SbVec2f(float val) { setValue(val,val); }
98
102 inline float dot(const SbVec2f &v) const
103 { return vec[0] * v.vec[0] + vec[1] * v.vec[1]; }
104
108 const float *getValue() const { return vec; }
109
113 void getValue(float &x, float &y) const;
114
118 float length() const;
119
124 inline float lengthSquared() const
125 { return vec[0] * vec[0] + vec[1] * vec[1]; }
126
130 void negate();
131
135 float normalize();
136
140 SbVec2f &setValue(const float v[2]);
141
145 SbVec2f &setValue(float x, float y);
146
159 SbVec2f &setValue(const SbVec2d &vec2d);
160
162
165 float & operator [](int i) { return (vec[i]); }
166 const float & operator [](int i) const { return (vec[i]); }
168
173
177 inline SbVec2f operator *(const SbVec2f &v) const
178 {
179 return SbVec2f(vec[0]*v.vec[0],
180 vec[1]*v.vec[1]);
181 }
182
186 inline SbVec2f& operator *=(const SbVec2f &v)
187 {
188 *this = (*this)*v;
189 return *this;
190 }
191
196
205
210
214 friend SbVec2f operator *(const SbVec2f &v, float d);
218 friend SbVec2f operator *(float d, const SbVec2f &v)
219 { return v * d; }
223 friend SbVec2f operator /(const SbVec2f &v, float d);
224
228 friend SbVec2f operator +(const SbVec2f &v1, const SbVec2f &v2);
229
233 friend SbVec2f operator -(const SbVec2f &v1, const SbVec2f &v2);
234
238 friend int operator ==(const SbVec2f &v1, const SbVec2f &v2);
242 friend int operator !=(const SbVec2f &v1, const SbVec2f &v2)
243 { return !(v1 == v2); }
244
248 friend inline std::ostream& operator << (std::ostream& os, const SbVec2f& v);
249
254 SbBool equals(const SbVec2f& v, float tolerance) const;
255
259 template<typename T>
260 explicit SbVec2f(const T& v)
261 {
262 // Uses operator[](int) to get the required field and float() to convert it.
263 vec[0] = float(v[0]);
264 vec[1] = float(v[1]);
265 }
266
267private:
268 float vec[2]; // Storage for vector components
269
270};
271
273//
274// Class: SbVec2d
275//
276// 2D vector used to represet points or directions. Each component of
277// the vector is a double float.
278//
280
314class SbVec2d {
315public:
316
320 SbVec2d() { memset(vec, 0, sizeof(vec)); }
321
325 explicit SbVec2d(const double v[2]) { setValue(v); }
326
330 SbVec2d(double x, double y) { setValue(x, y); }
331
335 inline double dot(const SbVec2d &v) const
336 { return vec[0] * v.vec[0] + vec[1] * v.vec[1]; }
337
341 const double *getValue() const { return vec; }
342
346 void getValue(double &x, double &y) const;
347
351 double length() const;
352
357 inline double lengthSquared() const
358 { return vec[0] * vec[0] + vec[1] * vec[1]; }
359
363 void negate();
364
368 double normalize();
369
373 SbVec2d &setValue(const double v[2]);
374
378 SbVec2d &setValue(double x, double y);
379
383 SbVec2d &setValue(const SbVec2f &vec2f)
384 { vec[0] = vec2f[0] ; vec[1] = vec2f[1] ; return (*this) ; }
385
387
390 double & operator [](int i) { return (vec[i]); }
391 const double & operator [](int i) const { return (vec[i]); }
393
397 SbVec2d & operator *=(double d);
398
402 SbVec2d & operator /=(double d);
403
412
417
421 friend SbVec2d operator *(const SbVec2d &v, double d);
425 friend SbVec2d operator *(double d, const SbVec2d &v)
426 { return v * d; }
430 friend SbVec2d operator /(const SbVec2d &v, double d);
431
435 friend SbVec2d operator +(const SbVec2d &v1, const SbVec2d &v2);
436
440 friend SbVec2d operator -(const SbVec2d &v1, const SbVec2d &v2);
441
445 friend int operator ==(const SbVec2d &v1, const SbVec2d &v2);
449 friend int operator !=(const SbVec2d &v1, const SbVec2d &v2)
450 { return !(v1 == v2); }
451
456 SbBool equals(const SbVec2d& v, double tolerance) const;
457
461 friend inline std::ostream& operator << (std::ostream& os, const SbVec2d& v);
462
466 template<typename T>
467 explicit SbVec2d(const T& v)
468 {
469 // Uses operator[](int) to get the required field and double() to convert it.
470 vec[0] = double(v[0]);
471 vec[1] = double(v[1]);
472 }
473
474private:
475 double vec[2]; // Storage for vector components
476
477};
478
480//
481// Class: SbVec2i32
482//
483// 2D vector used to represent points or directions. Each component of
484// the vector is a (int32_t) integer.
485//
487
518public:
522 SbVec2i32() { memset(vec, 0, sizeof(vec)); }
526 explicit SbVec2i32(const int32_t v[2]) { setValue(v); }
530 SbVec2i32(int32_t x, int32_t y) { setValue(x, y); }
534 inline int32_t dot(const SbVec2i32 &v) const
535 { return vec[0] * v.vec[0] + vec[1] * v.vec[1]; }
539 const int32_t *getValue() const { return vec; }
543 void getValue(int32_t &x, int32_t &y) const;
547 void negate();
551 SbVec2i32 &setValue(const int32_t v[2]);
555 SbVec2i32 &setValue(int32_t x, int32_t y);
559 int32_t & operator [](int i) { return (vec[i]); }
563 const int32_t & operator [](int i) const { return (vec[i]); }
572
581 { return *this *= (1.0 / d); }
597 friend SbVec2i32 operator *(const SbVec2i32 &v, int d);
601 friend SbVec2i32 operator *(const SbVec2i32 &v, double d);
605 friend SbVec2i32 operator *(int d, const SbVec2i32 &v)
606 { return v * d; }
610 friend SbVec2i32 operator *(double d, const SbVec2i32 &v)
611 { return v * d; }
615 friend SbVec2i32 operator /(const SbVec2i32 &v, int d);
619 friend SbVec2i32 operator /(const SbVec2i32 &v, double d)
620 { return v * (1.0 / d); }
624 friend SbVec2i32 operator +(const SbVec2i32 &v1, const SbVec2i32 &v2);
628 friend SbVec2i32 operator -(const SbVec2i32 &v1, const SbVec2i32 &v2);
632 friend int operator ==(const SbVec2i32 &v1, const SbVec2i32 &v2);
636 friend int operator !=(const SbVec2i32 &v1, const SbVec2i32 &v2)
637 { return !(v1 == v2); }
638
642 friend inline std::ostream& operator << (std::ostream& os, const SbVec2i32& v);
643
647 template<typename T>
648 explicit SbVec2i32(const T& v)
649 {
650 // Uses operator[](int) to get the required field and int32_t() to convert it.
651 vec[0] = int32_t(v[0]);
652 vec[1] = int32_t(v[1]);
653 }
654
655
656
657private:
658 int32_t vec[2]; // Storage for vector components
659};
660
662//
663// Class: SbVec2s
664//
665// 2D vector used to represet points or directions. Each component of
666// the vector is a (short) integer.
667//
669
700class SbVec2s {
701public:
702
706 SbVec2s() { memset(vec, 0, sizeof(vec)); }
707
711 explicit SbVec2s(const short v[2]) { setValue(v); }
712
716 SbVec2s(short x, short y) { setValue(x, y); }
717
721#ifndef OIV_DO_NOT_ALLOW_I32_TO_I16_AUTO_CAST
722 explicit SbVec2s(const SbVec2i32 &v);
723#endif
724
728 inline int32_t dot(const SbVec2s &v) const
729 { return vec[0] * v.vec[0] + vec[1] * v.vec[1]; }
730
734 const short *getValue() const { return vec; }
735
739 void getValue(short &x, short &y) const;
740
744 void negate();
745
749 SbVec2s &setValue(const short v[2]);
750
754 SbVec2s &setValue(short x, short y);
755
757
760 short & operator [](int i) { return (vec[i]); }
761 const short & operator [](int i) const { return (vec[i]); }
763
771 SbVec2s & operator *=(double d);
772
781 { return *this *= (1.0 / d); }
782
791
796
800#ifndef OIV_DO_NOT_ALLOW_I32_TO_I16_AUTO_CAST
802#endif
803
807 friend SbVec2s operator *(const SbVec2s &v, int d);
811 friend SbVec2s operator *(const SbVec2s &v, double d);
815 friend SbVec2s operator *(int d, const SbVec2s &v)
816 { return v * d; }
820 friend SbVec2s operator *(double d, const SbVec2s &v)
821 { return v * d; }
825 friend SbVec2s operator /(const SbVec2s &v, int d);
829 friend SbVec2s operator /(const SbVec2s &v, double d)
830 { return v * (1.0 / d); }
831
835 friend SbVec2s operator +(const SbVec2s &v1, const SbVec2s &v2);
836
840 friend SbVec2s operator -(const SbVec2s &v1, const SbVec2s &v2);
841
845 friend int operator ==(const SbVec2s &v1, const SbVec2s &v2);
849 friend int operator !=(const SbVec2s &v1, const SbVec2s &v2)
850 { return !(v1 == v2); }
851
855 friend inline std::ostream& operator << (std::ostream& os, const SbVec2s& v);
856
860 template<typename T>
861 explicit SbVec2s(const T& v)
862 {
863 // Uses operator[](int) to get the required field and short() to convert it.
864 vec[0] = short(v[0]);
865 vec[1] = short(v[1]);
866 }
867
868private:
869 short vec[2]; // Storage for vector components
870
871};
872
874//
875// Class: SbVec3f
876//
877// 3D vector used to represent points or directions. Each component of
878// the vector is a floating-point number.
879//
880// WARNING!!!!! Transcription of arrays of this class assume that the
881// only data stored in this class are three consecutive values.
882// Do not add any extra data members!!!
883//
884// Internal note:
885// It would be convenient to have a conversion constructor that takes an SbVec3d
886// (instead of having to create an SbVec3d and then call setValue). But...
887// This is not possible because given an expression like: "aVec3d * 1.2f"
888// The compiler can't decide if it should convert the vector to SbVec3f or
889// convert the constant to double.
890//
892
932class SbVec3f {
933public:
937 SbVec3f() { memset(vec, 0, sizeof(vec)); }
938
942 explicit SbVec3f(const float v[3])
943 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; }
944
948 SbVec3f(float x, float y, float z)
949 { vec[0] = x; vec[1] = y; vec[2] = z; }
950
955
959 inline SbVec3f cross(const SbVec3f &v) const
960 {
961 return SbVec3f(
962 vec[1] * v.vec[2] - vec[2] * v.vec[1],
963 vec[2] * v.vec[0] - vec[0] * v.vec[2],
964 vec[0] * v.vec[1] - vec[1] * v.vec[0]
965 );
966 }
967
971 float dot(const SbVec3f &v) const
972 { return (vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2]); }
973
977 inline const float *getValue() const
978 { return vec; }
979
983 void getValue(float &x, float &y, float &z) const;
984
988 float length() const;
989
994 inline float lengthSquared() const
995 { return vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]; }
996
1000 float normalize();
1001
1005 void negate();
1006
1010 inline SbVec3f &setValue(const float v[3])
1011 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; return *this; }
1012
1016 inline SbVec3f &setValue(float x, float y, float z)
1017 { vec[0] = x; vec[1] = y; vec[2] = z; return *this; }
1018
1022 SbVec3f &setValue(const SbVec3f &barycentic, const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2);
1023
1027 SbVec3f &setValue(const SbVec3d &vec3d);
1028
1030
1033 float & operator [](int i) { return (vec[i]); }
1034 const float & operator [](int i) const { return (vec[i]); }
1036
1041
1046
1050 inline SbVec3f & operator +=(const SbVec3f &v)
1051 {
1052 vec[0] += v.vec[0];
1053 vec[1] += v.vec[1];
1054 vec[2] += v.vec[2];
1055
1056 return *this;
1057 }
1058
1063
1067 inline SbVec3f operator -() const
1068 { return SbVec3f(-vec[0], -vec[1], -vec[2]); }
1069
1073 inline SbVec3f operator *(const SbVec3f &v) const
1074 { return SbVec3f(vec[0]*v.vec[0], vec[1]*v.vec[1], vec[2]*v.vec[2]); }
1075
1079 inline SbVec3f& operator *=(const SbVec3f &v)
1080 {
1081 *this = (*this)*v;
1082 return *this;
1083 }
1084
1088 friend inline SbVec3f operator *(const SbVec3f &v, float d)
1089 { return SbVec3f(v.vec[0] * d, v.vec[1] * d, v.vec[2] * d); }
1090
1094 friend inline SbVec3f operator *(float d, const SbVec3f &v)
1095 { return v * d; }
1096
1100 friend inline SbVec3f operator /(const SbVec3f &v, float d)
1101 { return SbVec3f(v.vec[0] / d, v.vec[1] / d, v.vec[2] / d); }
1102
1106 friend inline SbVec3f operator +(const SbVec3f &v1, const SbVec3f &v2)
1107 { return SbVec3f(v1.vec[0] + v2.vec[0], v1.vec[1] + v2.vec[1], v1.vec[2] + v2.vec[2]); }
1108
1112 friend inline SbVec3f operator -(const SbVec3f &v1, const SbVec3f &v2)
1113 { return SbVec3f(v1.vec[0] - v2.vec[0], v1.vec[1] - v2.vec[1], v1.vec[2] - v2.vec[2]); }
1114
1118 friend inline int operator ==(const SbVec3f &v1, const SbVec3f &v2)
1119 { return (v1.vec[0] == v2.vec[0] && v1.vec[1] == v2.vec[1] && v1.vec[2] == v2.vec[2]); }
1120
1124 friend inline int operator !=(const SbVec3f &v1, const SbVec3f &v2)
1125 { return !(v1 == v2); }
1126
1130 friend inline std::ostream& operator << (std::ostream& os, const SbVec3f& v);
1131
1136 SbBool equals(const SbVec3f& v, float tolerance) const;
1137
1143
1147 template<typename T>
1148 explicit SbVec3f(const T& v)
1149 {
1150 // Uses operator[](int) to get the required field and float() to convert it.
1151 vec[0] = float(v[0]);
1152 vec[1] = float(v[1]);
1153 vec[2] = float(v[2]);
1154 }
1155
1156private:
1157 float vec[3]; // Storage for vector components
1158
1159};
1160
1162//
1163// Class: SbVec3d
1164//
1165// 3D vector used to represent points or directions. Each component of
1166// the vector is a double precision floating-point number.
1167//
1168// WARNING!!!!! Transcription of arrays of this class assume that the
1169// only data stored in this class are three consecutive values.
1170// Do not add any extra data members!!!
1171//
1172// Internal note:
1173// It would be convenient to have a conversion constructor that takes an SbVec3d
1174// (instead of having to create an SbVec3d and then call setValue). But...
1175// This is not possible because given an expression like: "aVec3d * 1.2f"
1176// The compiler can't decide if it should convert the vector to SbVec3f or
1177// convert the constant to double.
1178//
1180
1214class SbVec3d {
1215public:
1219 SbVec3d() { memset(vec, 0, sizeof(vec)); }
1220
1224 explicit SbVec3d(const double v[3])
1225 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; }
1226
1230 inline SbVec3d(double x, double y, double z)
1231 { vec[0] = x; vec[1] = y; vec[2] = z; }
1232
1237
1241 inline SbVec3d cross(const SbVec3d &v) const
1242 {
1243 return SbVec3d(
1244 vec[1] * v.vec[2] - vec[2] * v.vec[1],
1245 vec[2] * v.vec[0] - vec[0] * v.vec[2],
1246 vec[0] * v.vec[1] - vec[1] * v.vec[0]
1247 );
1248 }
1249
1253 inline double dot(const SbVec3d &v) const
1254 { return (vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2]); }
1255
1259 inline const double *getValue() const
1260 { return vec; }
1261
1265 void getValue(double &x, double &y, double &z) const;
1266
1270 double length() const;
1271
1276 inline double lengthSquared() const
1277 { return vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]; }
1278
1282 double normalize();
1283
1287 void negate();
1288
1292 SbVec3d &setValue(const double v[3])
1293 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; return *this; }
1294
1298 SbVec3d &setValue(double x, double y, double z)
1299 { vec[0] = x; vec[1] = y; vec[2] = z; return *this; }
1300
1304 SbVec3d &setValue(const SbVec3d &barycentic,
1305 const SbVec3d &v0,
1306 const SbVec3d &v1,
1307 const SbVec3d &v2);
1308
1312 inline SbVec3d &setValue(const SbVec3f &vec3f)
1313 { vec[0] = vec3f[0] ; vec[1] = vec3f[1] ; vec[2] = vec3f[2] ; return (*this) ; }
1314
1316
1319 double & operator [](int i) { return (vec[i]); }
1320 const double & operator [](int i) const { return (vec[i]); }
1322
1326 inline SbVec3d & operator *=(double d)
1327 {
1328 vec[0] *= d;
1329 vec[1] *= d;
1330 vec[2] *= d;
1331
1332 return *this;
1333 }
1334
1338 inline SbVec3d & operator /=(double d)
1339 {
1340 vec[0] /= d;
1341 vec[1] /= d;
1342 vec[2] /= d;
1343
1344 return *this;
1345 }
1346
1350 inline SbVec3d & operator +=(const SbVec3d &v)
1351 {
1352 vec[0] += v.vec[0];
1353 vec[1] += v.vec[1];
1354 vec[2] += v.vec[2];
1355
1356 return *this;
1357 }
1358
1362 inline SbVec3d & operator -=(const SbVec3d &v)
1363 {
1364 vec[0] -= v.vec[0];
1365 vec[1] -= v.vec[1];
1366 vec[2] -= v.vec[2];
1367
1368 return *this;
1369 }
1370
1371
1375 inline SbVec3d operator -() const
1376 { return SbVec3d(-vec[0], -vec[1], -vec[2]); }
1377
1381 inline SbVec3d operator *(const SbVec3d &v) const
1382 { return SbVec3d(vec[0]*v.vec[0], vec[1]*v.vec[1], vec[2]*v.vec[2]); }
1383
1387 inline SbVec3d& operator *=(const SbVec3d &v)
1388 {
1389 *this = (*this)*v;
1390 return *this;
1391 }
1392
1396 friend inline SbVec3d operator *(const SbVec3d &v, double d)
1397 { return SbVec3d(v.vec[0] * d, v.vec[1] * d, v.vec[2] * d); }
1398
1402 friend inline SbVec3d operator *(double d, const SbVec3d &v)
1403 { return v * d; }
1404
1408 friend inline SbVec3d operator /(const SbVec3d &v, double d)
1409 { return SbVec3d(v.vec[0] / d, v.vec[1] / d, v.vec[2] / d); }
1410
1414 friend inline SbVec3d operator +(const SbVec3d &v1, const SbVec3d &v2)
1415 { return SbVec3d(v1.vec[0] + v2.vec[0], v1.vec[1] + v2.vec[1], v1.vec[2] + v2.vec[2]); }
1416
1420 friend inline SbVec3d operator -(const SbVec3d &v1, const SbVec3d &v2)
1421 { return SbVec3d(v1.vec[0] - v2.vec[0], v1.vec[1] - v2.vec[1], v1.vec[2] - v2.vec[2]); }
1422
1426 friend inline int operator ==(const SbVec3d &v1, const SbVec3d &v2)
1427 { return (v1.vec[0] == v2.vec[0] && v1.vec[1] == v2.vec[1] && v1.vec[2] == v2.vec[2]); }
1428
1432 friend int operator !=(const SbVec3d &v1, const SbVec3d &v2)
1433 { return !(v1 == v2); }
1434
1439 SbBool equals(const SbVec3d& v, double tolerance) const;
1440
1444 friend inline std::ostream& operator << (std::ostream& os, const SbVec3d& v);
1445
1451
1455 template<typename T>
1456 explicit SbVec3d(const T& v)
1457 {
1458 // Uses operator[](int) to get the required field and double() to convert it.
1459 vec[0] = double(v[0]);
1460 vec[1] = double(v[1]);
1461 vec[2] = double(v[2]);
1462 }
1463
1464private:
1465 double vec[3]; // Storage for vector components
1466
1467};
1468
1469// Note: This implementation must appear after the declaration of SbVec3d!
1470
1471inline SbVec3f &SbVec3f::setValue(const SbVec3d &vec3d)
1472{
1473 vec[0] = static_cast<float>(vec3d[0]);
1474 vec[1] = static_cast<float>(vec3d[1]);
1475 vec[2] = static_cast<float>(vec3d[2]);
1476 return (*this);
1477}
1478
1480//
1481// Class: SbVec3i32
1482//
1483// 3D vector used to represet points or directions or dimensions. Each
1484// component of the vector is a (int32_t) integer.
1485//
1487
1518public:
1522 SbVec3i32() { memset(vec, 0, sizeof(vec)); }
1526 explicit SbVec3i32(const int32_t v[3]) { setValue(v); }
1530 SbVec3i32(int32_t x, int32_t y, int32_t z) { setValue(x, y, z); }
1534 SbVec3i32( const SbVec3s &vec );
1538 inline int32_t dot(const SbVec3i32 &v) const
1539 {
1540 return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2];
1541 }
1542
1546 const int32_t *getValue() const { return vec; }
1550 void getValue(int32_t &x, int32_t &y, int32_t &z) const;
1554 void negate();
1558 inline SbVec3i32 &setValue(const int32_t v[3])
1559 {
1560 vec[0] = v[0];
1561 vec[1] = v[1];
1562 vec[2] = v[2];
1563
1564 return (*this);
1565 }
1566
1570 inline SbVec3i32 &setValue(int32_t x, int32_t y, int32_t z)
1571 {
1572 vec[0] = x;
1573 vec[1] = y;
1574 vec[2] = z;
1575
1576 return (*this);
1577 }
1578
1590 int32_t & operator [](int i) { return (vec[i]); }
1594 const int32_t & operator [](int i) const { return (vec[i]); }
1603
1612 { return *this *= (1.0 / d); }
1617 {
1618 vec[0] += u.vec[0];
1619 vec[1] += u.vec[1];
1620 vec[2] += u.vec[2];
1621
1622 return *this;
1623 }
1628 {
1629 vec[0] /= u.vec[0];
1630 vec[1] /= u.vec[1];
1631 vec[2] /= u.vec[2];
1632
1633 return *this;
1634 }
1646 inline SbVec3i32 operator *(int d) const
1647 {
1648 return SbVec3i32(vec[0] * d, vec[1] * d, vec[2] * d);
1649 }
1650
1654 inline SbVec3i32 operator *(const SbVec3i32 &v) const
1655 {
1656 return SbVec3i32(vec[0]*v.vec[0],
1657 vec[1]*v.vec[1],
1658 vec[2]*v.vec[2]);
1659 }
1660
1665 {
1666 *this = (*this)*v;
1667 return *this;
1668 }
1669
1673 friend SbVec3i32 operator *(const SbVec3i32 &v, double d);
1677 friend SbVec3i32 operator *(int d, const SbVec3i32 &v)
1678 { return v * d; }
1682 friend SbVec3i32 operator *(double d, const SbVec3i32 &v)
1683 { return v * d; }
1687 friend SbVec3i32 operator /(const SbVec3i32 &v, int d);
1691 friend SbVec3i32 operator /(const SbVec3i32 &v, double d)
1692 { return v * (1.0 / d); }
1696 inline SbVec3i32 operator +(const SbVec3i32 &v) const
1697 {
1698 return SbVec3i32(vec[0] + v.vec[0],
1699 vec[1] + v.vec[1],
1700 vec[2] + v.vec[2]);
1701 }
1702
1707 friend SbVec3i32 operator -(const SbVec3i32 &v1, const SbVec3i32 &v2)
1708 {
1709 return SbVec3i32(v1.vec[0] - v2.vec[0],
1710 v1.vec[1] - v2.vec[1],
1711 v1.vec[2] - v2.vec[2]);
1712 }
1713
1717 friend int operator ==(const SbVec3i32 &v1, const SbVec3i32 &v2);
1721 friend int operator !=(const SbVec3i32 &v1, const SbVec3i32 &v2)
1722 { return !(v1 == v2); }
1723
1727 friend inline std::ostream& operator << (std::ostream& os, const SbVec3i32& v);
1728
1732 template<typename T>
1733 explicit SbVec3i32(const T& v)
1734 {
1735 // Uses operator[](int) to get the required field and int32_t() to convert it.
1736 vec[0] = int32_t(v[0]);
1737 vec[1] = int32_t(v[1]);
1738 vec[2] = int32_t(v[2]);
1739 }
1740
1744 inline int32_t getMaxComponent() const;
1745
1746private:
1747 int32_t vec[3]; // Storage for vector components
1748};
1749
1750int32_t
1752{
1753 return SbMathHelper::Max(SbMathHelper::Max(vec[0], vec[1]), vec[2]);
1754}
1755
1757//
1758// Class: SbVec3s
1759//
1760// 3D vector used to represet points or directions or dimensions. Each
1761// component of the vector is a (short) integer.
1762//
1764
1765
1766
1797class SbVec3s {
1798public:
1799
1803 SbVec3s() { memset(vec, 0, sizeof(vec)); }
1804
1808 explicit SbVec3s(const short v[3]) { setValue(v); }
1809
1813 SbVec3s(short x, short y, short z) { setValue(x, y, z); }
1814
1819#ifndef OIV_DO_NOT_ALLOW_I32_TO_I16_AUTO_CAST
1821#endif
1822
1826 inline int32_t dot(const SbVec3s &v) const
1827 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2]; }
1828
1832 const short *getValue() const { return vec; }
1833
1837 void getValue(short &x, short &y, short &z) const;
1838
1842 void negate();
1843
1847 SbVec3s &setValue(const short v[3]);
1848
1852 SbVec3s &setValue(short x, short y, short z);
1853
1855
1858 short & operator [](int i) { return (vec[i]); }
1859 const short & operator [](int i) const { return (vec[i]); }
1861
1870
1879 { return *this *= (1.0 / d); }
1880
1889
1894
1899#ifndef OIV_DO_NOT_ALLOW_I32_TO_I16_AUTO_CAST
1901#endif
1902
1906 friend SbVec3s operator *(const SbVec3s &v, int d);
1910 friend SbVec3s operator *(const SbVec3s &v, double d);
1914 friend SbVec3s operator *(int d, const SbVec3s &v)
1915 { return v * d; }
1919 friend SbVec3s operator *(double d, const SbVec3s &v)
1920 { return v * d; }
1924 friend SbVec3s operator /(const SbVec3s &v, int d);
1928 friend SbVec3s operator /(const SbVec3s &v, double d)
1929 { return v * (1.0 / d); }
1930
1934 friend SbVec3s operator +(const SbVec3s &v1, const SbVec3s &v2);
1935
1939 friend SbVec3s operator -(const SbVec3s &v1, const SbVec3s &v2);
1940
1944 friend int operator ==(const SbVec3s &v1, const SbVec3s &v2);
1948 friend int operator !=(const SbVec3s &v1, const SbVec3s &v2)
1949 { return !(v1 == v2); }
1950
1954 friend inline std::ostream& operator << (std::ostream& os, const SbVec3s& v);
1955
1959 template<typename T>
1960 explicit SbVec3s(const T& v)
1961 {
1962 // Uses operator[](int) to get the required field and short() to convert it.
1963 vec[0] = short(v[0]);
1964 vec[1] = short(v[1]);
1965 vec[2] = short(v[2]);
1966 }
1967
1968
1969private:
1970 short vec[3]; // Storage for vector components
1971
1972};
1973
1975//
1976// Class: SbVec4b
1977//
1978// 4D vector. Each component of the vector is a (byte) integer.
1979//
1981
1982
1983
2014class SbVec4b {
2015public:
2016
2020 SbVec4b() { memset(vec, 0, sizeof(vec)); }
2021
2025 explicit SbVec4b(const char v[4]) { setValue(v); }
2026
2030 SbVec4b(char x, char y, char z, char w) { setValue(x, y, z, w); }
2031
2035 inline int32_t dot(const SbVec4b &v) const
2036 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
2037
2042 const char *getValue() const { return vec; }
2043
2047 void getValue(char &x, char &y, char &z, char &w) const;
2048
2052 void negate();
2053
2057 SbVec4b &setValue(const char v[4]);
2058
2062 SbVec4b &setValue(char x, char y, char z, char w);
2063
2065
2068 char & operator [](int i) { return (vec[i]); }
2069 const char & operator [](int i) const { return (vec[i]); }
2071
2080
2089 { return *this *= (1.0 / d); }
2090
2099
2104
2108 friend SbVec4b operator *(const SbVec4b &v, int d);
2112 friend SbVec4b operator *(const SbVec4b &v, double d);
2116 friend SbVec4b operator *(int d, const SbVec4b &v)
2117 { return v * d; }
2121 friend SbVec4b operator *(double d, const SbVec4b &v)
2122 { return v * d; }
2126 friend SbVec4b operator /(const SbVec4b &v, int d);
2130 friend SbVec4b operator /(const SbVec4b &v, double d)
2131 { return v * (1.0 / d); }
2132
2136 friend SbVec4b operator +(const SbVec4b &v1, const SbVec4b &v2);
2137
2141 friend SbVec4b operator -(const SbVec4b &v1, const SbVec4b &v2);
2142
2146 friend int operator ==(const SbVec4b &v1, const SbVec4b &v2);
2150 friend int operator !=(const SbVec4b &v1, const SbVec4b &v2)
2151 { return !(v1 == v2); }
2152
2156 friend inline std::ostream& operator << (std::ostream& os, const SbVec4b& v);
2157
2161 template<typename T>
2162 explicit SbVec4b(const T& v)
2163 {
2164 // Uses operator[](int) to get the required field and char() to convert it.
2165 vec[0] = char(v[0]);
2166 vec[1] = char(v[1]);
2167 vec[2] = char(v[2]);
2168 vec[3] = char(v[3]);
2169 }
2170private:
2171 char vec[4]; // Storage for vector components
2172
2173};
2174
2176//
2177// Class: SbVec4f
2178//
2179// 4D vector used to represet rational points or directions. Each component of
2180// the vector is a float.
2181//
2183
2214class SbVec4f {
2215public:
2216
2220 SbVec4f() { memset(vec, 0, sizeof(vec)); }
2221
2225 explicit SbVec4f(const float v[4]) { setValue(v); }
2226
2230 SbVec4f(float x, float y, float z, float w) { setValue(x, y, z, w); }
2231
2235 inline float dot(const SbVec4f &v) const
2236 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3] ; }
2237
2241 void getReal(SbVec3f &v) const;
2242
2246 const float *getValue() const { return vec; }
2247
2251 void getValue(float &x, float &y, float &z, float &w) const;
2252
2256 float length() const;
2257
2262 inline float lengthSquared() const
2263 { return vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] + vec[3] * vec[3]; }
2264
2268 void negate();
2269
2273 float normalize();
2274
2278 SbVec4f &setValue(const float v[4]);
2279
2283 SbVec4f &setValue(float x, float y, float z, float w);
2284
2288 SbVec4f &setValue(const SbVec4d &vec4d);
2289
2291
2294 float & operator [](int i) { return (vec[i]); }
2295 const float & operator [](int i) const { return (vec[i]); }
2297
2302
2307
2316
2321
2325 friend SbVec4f operator *(const SbVec4f &v, float d);
2329 friend SbVec4f operator *(float d, const SbVec4f &v)
2330 { return v * d; }
2334 friend SbVec4f operator /(const SbVec4f &v, float d);
2335
2339 friend SbVec4f operator +(const SbVec4f &v1, const SbVec4f &v2);
2340
2344 friend SbVec4f operator -(const SbVec4f &v1, const SbVec4f &v2);
2345
2349 friend int operator ==(const SbVec4f &v1, const SbVec4f &v2);
2353 friend int operator !=(const SbVec4f &v1, const SbVec4f &v2)
2354 { return !(v1 == v2); }
2355
2359 friend inline std::ostream& operator << (std::ostream& os, const SbVec4f& v);
2360
2365 SbBool equals(const SbVec4f& v, float tolerance) const;
2366
2370 template<typename T>
2371 explicit SbVec4f(const T& v)
2372 {
2373 // Uses operator[](int) to get the required field and float() to convert it.
2374 vec[0] = float(v[0]);
2375 vec[1] = float(v[1]);
2376 vec[2] = float(v[2]);
2377 vec[3] = float(v[3]);
2378 }
2379
2380private:
2381 float vec[4]; // Storage for vector components
2382
2383};
2384
2386//
2387// Class: SbVec4d
2388//
2389// 4D vector used to represet rational points or directions. Each component of
2390// the vector is a double float.
2391//
2393
2427class SbVec4d {
2428public:
2429
2433 SbVec4d() { memset(vec, 0, sizeof(vec)); }
2434
2438 explicit SbVec4d(const double v[4]) { setValue(v); }
2439
2443 SbVec4d(double x, double y, double z, double w) { setValue(x, y, z, w); }
2444
2448 inline double dot(const SbVec4d &v) const
2449 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3] ; }
2450
2454 void getReal(SbVec3d &v) const;
2455
2459 const double *getValue() const { return vec; }
2460
2464 void getValue(double &x, double &y, double &z, double &w) const;
2465
2469 double length() const;
2470
2475 inline double lengthSquared() const
2476 { return vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] + vec[3] * vec[3]; }
2477
2481 void negate();
2482
2486 double normalize();
2487
2491 SbVec4d &setValue(const double v[4]);
2492
2496 SbVec4d &setValue(double x, double y, double z, double w);
2497
2501 SbVec4d &setValue(const SbVec4f &vec4f)
2502 { vec[0] = vec4f[0] ; vec[1] = vec4f[1] ; vec[2] = vec4f[2] ;
2503 vec[3] = vec4f[3] ; return (*this) ;}
2504
2506
2509 double & operator [](int i) { return (vec[i]); }
2510 const double & operator [](int i) const { return (vec[i]); }
2512
2517
2522
2531
2536
2540 friend SbVec4d operator *(const SbVec4d &v, double d);
2544 friend SbVec4d operator *(double d, const SbVec4d &v)
2545 { return v * d; }
2549 friend SbVec4d operator /(const SbVec4d &v, double d);
2550
2554 friend SbVec4d operator +(const SbVec4d &v1, const SbVec4d &v2);
2555
2559 friend SbVec4d operator -(const SbVec4d &v1, const SbVec4d &v2);
2560
2564 friend int operator ==(const SbVec4d &v1, const SbVec4d &v2);
2568 friend int operator !=(const SbVec4d &v1, const SbVec4d &v2)
2569 { return !(v1 == v2); }
2570
2574 friend inline std::ostream& operator << (std::ostream& os, const SbVec4d& v);
2575
2580 SbBool equals(const SbVec4d& v, double tolerance) const;
2581
2585 template<typename T>
2586 explicit SbVec4d(const T& v)
2587 {
2588 // Uses operator[](int) to get the required field and double() to convert it.
2589 vec[0] = double(v[0]);
2590 vec[1] = double(v[1]);
2591 vec[2] = double(v[2]);
2592 vec[3] = double(v[3]);
2593 }
2594
2595
2596private:
2597 double vec[4]; // Storage for vector components
2598
2599};
2600
2602//
2603// Class: SbVec4i32
2604//
2605// 4D vector used to represet rational points or directions. Each
2606// component of the vector is a (int32_t) integer.
2607//
2609
2640public:
2644 SbVec4i32() { memset(vec, 0, sizeof(vec)); }
2648 explicit SbVec4i32(const int32_t v[4]) { setValue(v); }
2652 SbVec4i32(int32_t x, int32_t y, int32_t z, int32_t w) { setValue(x, y, z, w); }
2656 inline int32_t dot(const SbVec4i32 &v) const
2657 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
2661 const int32_t *getValue() const { return vec; }
2665 void getValue(int32_t &x, int32_t &y, int32_t &z, int32_t &w) const;
2669 void negate();
2673 SbVec4i32 &setValue(const int32_t v[4]);
2677 SbVec4i32 &setValue(int32_t x, int32_t y, int32_t z, int32_t w);
2681 int32_t & operator [](int i) { return (vec[i]); }
2685 const int32_t & operator [](int i) const { return (vec[i]); }
2694
2703 { return *this *= (1.0 / d); }
2719 friend SbVec4i32 operator *(const SbVec4i32 &v, int d);
2723 friend SbVec4i32 operator *(const SbVec4i32 &v, double d);
2727 friend SbVec4i32 operator *(int d, const SbVec4i32 &v)
2728 { return v * d; }
2732 friend SbVec4i32 operator *(double d, const SbVec4i32 &v)
2733 { return v * d; }
2737 friend SbVec4i32 operator /(const SbVec4i32 &v, int d);
2741 friend SbVec4i32 operator /(const SbVec4i32 &v, double d)
2742 { return v * (1.0 / d); }
2746 friend SbVec4i32 operator +(const SbVec4i32 &v1, const SbVec4i32 &v2);
2751 friend SbVec4i32 operator -(const SbVec4i32 &v1, const SbVec4i32 &v2);
2755 friend int operator ==(const SbVec4i32 &v1, const SbVec4i32 &v2);
2759 friend int operator !=(const SbVec4i32 &v1, const SbVec4i32 &v2)
2760 { return !(v1 == v2); }
2761
2765 friend inline std::ostream& operator << (std::ostream& os, const SbVec4i32& v);
2766
2770 template<typename T>
2771 explicit SbVec4i32(const T& v)
2772 {
2773 // Uses operator[](int) to get the required field and int32_t() to convert it.
2774 vec[0] = int32_t(v[0]);
2775 vec[1] = int32_t(v[1]);
2776 vec[2] = int32_t(v[2]);
2777 vec[3] = int32_t(v[3]);
2778 }
2779
2780private:
2781 int32_t vec[4]; // Storage for vector components
2782};
2783
2785//
2786// Class: SbVec4s
2787//
2788// 4D vector. Each component of the vector is a (short) integer.
2789//
2791
2792
2793
2824class SbVec4s {
2825public:
2826
2830 SbVec4s() { memset(vec, 0, sizeof(vec)); }
2831
2835 explicit SbVec4s(const short v[4]) { setValue(v); }
2836
2840 SbVec4s(short x, short y, short z, short w) { setValue(x, y, z, w); }
2841
2845 inline int32_t dot(const SbVec4s &v) const
2846 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
2847
2851 const short *getValue() const { return vec; }
2852
2856 void getValue(short &x, short &y, short &z, short &w) const;
2857
2861 void negate();
2862
2866 SbVec4s &setValue(const short v[4]);
2867
2871 SbVec4s &setValue(short x, short y, short z, short w);
2872
2874
2877 short & operator [](int i) { return (vec[i]); }
2878 const short & operator [](int i) const { return (vec[i]); }
2880
2889
2898 { return *this *= (1.0 / d); }
2899
2908
2913
2917 friend SbVec4s operator *(const SbVec4s &v, int d);
2921 friend SbVec4s operator *(const SbVec4s &v, double d);
2925 friend SbVec4s operator *(int d, const SbVec4s &v)
2926 { return v * d; }
2930 friend SbVec4s operator *(double d, const SbVec4s &v)
2931 { return v * d; }
2935 friend SbVec4s operator /(const SbVec4s &v, int d);
2939 friend SbVec4s operator /(const SbVec4s &v, double d)
2940 { return v * (1.0 / d); }
2941
2945 friend SbVec4s operator +(const SbVec4s &v1, const SbVec4s &v2);
2946
2950 friend SbVec4s operator -(const SbVec4s &v1, const SbVec4s &v2);
2951
2955 friend int operator ==(const SbVec4s &v1, const SbVec4s &v2);
2959 friend int operator !=(const SbVec4s &v1, const SbVec4s &v2)
2960 { return !(v1 == v2); }
2961
2965 friend inline std::ostream& operator << (std::ostream& os, const SbVec4s& v);
2966
2970 template<typename T>
2971 explicit SbVec4s(const T& v)
2972 {
2973 // Uses operator[](int) to get the required field and short() to convert it.
2974 vec[0] = short(v[0]);
2975 vec[1] = short(v[1]);
2976 vec[2] = short(v[2]);
2977 vec[3] = short(v[3]);
2978 }
2979
2980
2981
2982private:
2983 short vec[4]; // Storage for vector components
2984
2985};
2986
2988//
2989// Class: SbVec4ui32
2990//
2991// 4D vector. Each component of the vector is an (uint32_t) integer.
2992//
2994
2995
2996
3028public:
3029
3033 SbVec4ui32() { memset(vec, 0, sizeof(vec)); }
3034
3038 explicit SbVec4ui32(const uint32_t v[4]) { setValue(v); }
3039
3043 SbVec4ui32(uint32_t x, uint32_t y, uint32_t z, uint32_t w)
3044 { setValue(x, y, z, w); }
3045
3049 inline int32_t dot(const SbVec4ui32 &v) const
3050 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
3051
3055 const uint32_t *getValue() const { return vec; }
3056
3060 void getValue(uint32_t &x, uint32_t &y,
3061 uint32_t &z, uint32_t &w) const;
3062
3066 SbVec4ui32 &setValue(const uint32_t v[4]);
3067
3071 SbVec4ui32 &setValue(uint32_t x, uint32_t y,
3072 uint32_t z, uint32_t w);
3073
3075
3078 uint32_t & operator [](int i) { return (vec[i]); }
3079 const uint32_t & operator [](int i) const { return (vec[i]); }
3081
3090
3099 { return *this *= (1.0 / d); }
3100
3112 friend SbVec4ui32 operator *(const SbVec4ui32 &v, int d);
3116 friend SbVec4ui32 operator *(const SbVec4ui32 &v, double d);
3120 friend SbVec4ui32 operator *(int d, const SbVec4ui32 &v)
3121 { return v * d; }
3125 friend SbVec4ui32 operator *(double d, const SbVec4ui32 &v)
3126 { return v * d; }
3130 friend SbVec4ui32 operator /(const SbVec4ui32 &v, int d);
3134 friend SbVec4ui32 operator /(const SbVec4ui32 &v, double d)
3135 { return v * (1.0 / d); }
3136
3140 friend SbVec4ui32 operator +(const SbVec4ui32 &v1, const SbVec4ui32 &v2);
3141
3145 friend SbVec4ui32 operator -(const SbVec4ui32 &v1, const SbVec4ui32 &v2);
3146
3150 friend int operator ==(const SbVec4ui32 &v1, const SbVec4ui32 &v2);
3154 friend int operator !=(const SbVec4ui32 &v1, const SbVec4ui32 &v2)
3155 { return !(v1 == v2); }
3156
3160 friend inline std::ostream& operator << (std::ostream& os, const SbVec4ui32& v);
3161
3165 template<typename T>
3166 explicit SbVec4ui32(const T& v)
3167 {
3168 // Uses operator[](int) to get the required field and uint32_t() to convert it.
3169 vec[0] = uint32_t(v[0]);
3170 vec[1] = uint32_t(v[1]);
3171 vec[2] = uint32_t(v[2]);
3172 vec[3] = uint32_t(v[3]);
3173 }
3174private:
3175 uint32_t vec[4]; // Storage for vector components
3176
3177};
3178
3180//
3181// Class: SbVec4us
3182//
3183// 4D vector. Each component of the vector is an (unsigned short) integer.
3184//
3186
3187
3188
3220public:
3221
3225 SbVec4us() { memset(vec, 0, sizeof(vec)); }
3226
3230 explicit SbVec4us(const unsigned short v[4]) { setValue(v); }
3231
3235 SbVec4us(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
3236 { setValue(x, y, z, w); }
3237
3241 inline int32_t dot(const SbVec4us &v) const
3242 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
3243
3247 const unsigned short *getValue() const { return vec; }
3248
3252 void getValue(unsigned short &x, unsigned short &y, unsigned short &z, unsigned short &w) const;
3253
3257 void negate();
3258
3262 SbVec4us &setValue(const unsigned short v[4]);
3263
3267 SbVec4us &setValue(unsigned short x, unsigned short y, unsigned short z, unsigned short w);
3268
3270
3273 unsigned short & operator [](int i) { return (vec[i]); }
3274 const unsigned short & operator [](int i) const { return (vec[i]); }
3276
3285
3294 { return *this *= (1.0 / d); }
3295
3304
3309
3313 friend SbVec4us operator *(const SbVec4us &v, int d);
3317 friend SbVec4us operator *(const SbVec4us &v, double d);
3321 friend SbVec4us operator *(int d, const SbVec4us &v)
3322 { return v * d; }
3326 friend SbVec4us operator *(double d, const SbVec4us &v)
3327 { return v * d; }
3331 friend SbVec4us operator /(const SbVec4us &v, int d);
3335 friend SbVec4us operator /(const SbVec4us &v, double d)
3336 { return v * (1.0 / d); }
3337
3341 friend SbVec4us operator +(const SbVec4us &v1, const SbVec4us &v2);
3342
3346 friend SbVec4us operator -(const SbVec4us &v1, const SbVec4us &v2);
3347
3351 friend int operator ==(const SbVec4us &v1, const SbVec4us &v2);
3355 friend int operator !=(const SbVec4us &v1, const SbVec4us &v2)
3356 { return !(v1 == v2); }
3357
3361 friend inline std::ostream& operator << (std::ostream& os, const SbVec4us& v);
3362
3366 template<typename T>
3367 explicit SbVec4us(const T& v)
3368 {
3369 // Uses operator[](int) to get the required field and unsigned short() to convert it.
3370 vec[0] = static_cast<unsigned short>(v[0]);
3371 vec[1] = static_cast<unsigned short>(v[1]);
3372 vec[2] = static_cast<unsigned short>(v[2]);
3373 vec[3] = static_cast<unsigned short>(v[3]);
3374 }
3375private:
3376 unsigned short vec[4]; // Storage for vector components
3377
3378};
3379
3380
3382//
3383// Class: SbVec4ub
3384//
3385// 4D vector. Each component of the vector is an (unsigned byte) integer.
3386//
3388
3389
3390
3422public:
3423
3427 SbVec4ub() { memset(vec, 0, sizeof(vec)); }
3428
3432 explicit SbVec4ub(const unsigned char v[4]) { setValue(v); }
3433
3437 SbVec4ub(unsigned char x, unsigned char y, unsigned char z, unsigned char w)
3438 { setValue(x, y, z, w); }
3439
3443 inline int32_t dot(const SbVec4ub &v) const
3444 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
3445
3449 const unsigned char *getValue() const { return vec; }
3450
3454 void getValue(unsigned char &x, unsigned char &y, unsigned char &z, unsigned char &w) const;
3455
3459 void negate();
3460
3464 SbVec4ub &setValue(const unsigned char v[4]);
3465
3469 SbVec4ub &setValue(unsigned char x, unsigned char y, unsigned char z, unsigned char w);
3470
3472
3475 unsigned char & operator [](int i) { return (vec[i]); }
3476 const unsigned char & operator [](int i) const { return (vec[i]); }
3478
3487
3496 { return *this *= (1.0 / d); }
3497
3506
3511
3515 friend SbVec4ub operator *(const SbVec4ub &v, int d);
3519 friend SbVec4ub operator *(const SbVec4ub &v, double d);
3523 friend SbVec4ub operator *(int d, const SbVec4ub &v)
3524 { return v * d; }
3528 friend SbVec4ub operator *(double d, const SbVec4ub &v)
3529 { return v * d; }
3533 friend SbVec4ub operator /(const SbVec4ub &v, int d);
3537 friend SbVec4ub operator /(const SbVec4ub &v, double d)
3538 { return v * (1.0 / d); }
3539
3543 friend SbVec4ub operator +(const SbVec4ub &v1, const SbVec4ub &v2);
3544
3548 friend SbVec4ub operator -(const SbVec4ub &v1, const SbVec4ub &v2);
3549
3553 friend int operator ==(const SbVec4ub &v1, const SbVec4ub &v2);
3557 friend int operator !=(const SbVec4ub &v1, const SbVec4ub &v2)
3558 { return !(v1 == v2); }
3559
3563 friend inline std::ostream& operator << (std::ostream& os, const SbVec4ub& v);
3564
3568 template<typename T>
3569 explicit SbVec4ub(const T& v)
3570 {
3571 // Uses operator[](int) to get the required field and unsigned char() to convert it.
3572 vec[0] = static_cast<unsigned char>(v[0]);
3573 vec[1] = static_cast<unsigned char>(v[1]);
3574 vec[2] = static_cast<unsigned char>(v[2]);
3575 vec[3] = static_cast<unsigned char>(v[3]);
3576 }
3577
3581 inline void clamp(unsigned char a, unsigned char b)
3582 {
3583 vec[0] = SbMathHelper::Clamp(vec[0], a, b);
3584 vec[1] = SbMathHelper::Clamp(vec[1], a, b);
3585 vec[2] = SbMathHelper::Clamp(vec[2], a, b);
3586 vec[3] = SbMathHelper::Clamp(vec[3], a, b);
3587 }
3588private:
3589 unsigned char vec[4]; // Storage for vector components
3590
3591};
3592
3596inline std::ostream& operator << (std::ostream& os, const SbVec2s& v)
3597{
3598 return os << "(" << v[0] << ", " << v[1] << ")";
3599}
3600
3604inline std::ostream& operator << (std::ostream& os, const SbVec2i32& v)
3605{
3606 return os << "(" << v[0] << ", " << v[1] << ")";
3607}
3608
3612inline std::ostream& operator << (std::ostream& os, const SbVec2f& v)
3613{
3614 return os << "(" << v[0] << ", " << v[1] << ")";
3615}
3616
3620inline std::ostream& operator << (std::ostream& os, const SbVec2d& v)
3621{
3622 return os << "(" << v[0] << ", " << v[1] << ")";
3623}
3624
3628inline std::ostream& operator << (std::ostream& os, const SbVec3s& v)
3629{
3630 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ")";
3631}
3632
3636inline std::ostream& operator << (std::ostream& os, const SbVec3i32& v)
3637{
3638 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ")";
3639}
3640
3644inline std::ostream& operator << (std::ostream& os, const SbVec3d& v)
3645{
3646 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ")";
3647}
3648
3652inline std::ostream& operator << (std::ostream& os, const SbVec3f& v)
3653{
3654 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ")";
3655}
3656
3657
3661inline std::ostream& operator << (std::ostream& os, const SbVec4b& v)
3662{
3663 return os << "(" << static_cast<int>(v[0]) << ", " << static_cast<int>(v[1]) << ", " << static_cast<int>(v[2]) << ", " << static_cast<int>(v[3]) << ")";
3664}
3665
3669inline std::ostream& operator << (std::ostream& os, const SbVec4d& v)
3670{
3671 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
3672}
3673
3677inline std::ostream& operator << (std::ostream& os, const SbVec4f& v)
3678{
3679 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
3680}
3681
3685inline std::ostream& operator << (std::ostream& os, const SbVec4i32& v)
3686{
3687 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
3688}
3689
3693inline std::ostream& operator << (std::ostream& os, const SbVec4s& v)
3694{
3695 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
3696}
3697
3701inline std::ostream& operator << (std::ostream& os, const SbVec4ub& v)
3702{
3703 return os << "(" << static_cast<unsigned int>(v[0]) << ", " << static_cast<unsigned int>(v[1]) << ", " << static_cast<unsigned int>(v[2]) << ", " << static_cast<unsigned int>(v[3]) << ")";
3704}
3705
3709inline std::ostream& operator << (std::ostream& os, const SbVec4ui32& v)
3710{
3711 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
3712}
3713
3717inline std::ostream& operator << (std::ostream& os, const SbVec4us& v)
3718{
3719 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
3720}
3721
3722
3723#endif /* _SB_VEC_ */
3724
3725
Oriented plane in 3D.
Definition SbPlane.h:64
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 2D vector class ...
Definition SbVec.h:314
friend int operator!=(const SbVec2d &v1, const SbVec2d &v2)
Inequality comparison operator.
Definition SbVec.h:449
friend std::ostream & operator<<(std::ostream &os, const SbVec2d &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3620
SbVec2d & setValue(const SbVec2f &vec2f)
Sets value of vector from a single precision vector.
Definition SbVec.h:383
friend SbVec2d operator/(const SbVec2d &v, double d)
Component-wise binary scalar division operator.
double dot(const SbVec2d &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:335
SbVec2d & operator*=(double d)
Component-wise scalar multiplication operator.
double length() const
Returns geometric length of vector.
double & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:390
SbVec2d & setValue(const double v[2])
Sets the vector components.
SbVec2d(double x, double y)
Constructor given vector components.
Definition SbVec.h:330
SbVec2d(const T &v)
Constructor that converts an arbitrary SbVec2 to an SbVec2d.
Definition SbVec.h:467
double normalize()
Changes vector to be unit length.
void negate()
Negates each component of vector in place.
SbVec2d & operator/=(double d)
Component-wise scalar division operator.
SbVec2d operator-() const
Nondestructive unary negation - returns a new vector.
friend SbVec2d operator*(const SbVec2d &v, double d)
Component-wise binary scalar multiplication operator.
SbVec2d(const double v[2])
Constructor given vector components.
Definition SbVec.h:325
const double * getValue() const
Returns vector components.
Definition SbVec.h:341
SbVec2d()
Default constructor.
Definition SbVec.h:320
SbVec2d & setValue(double x, double y)
Sets the vector components.
void getValue(double &x, double &y) const
Returns vector components.
SbVec2d & operator+=(const SbVec2d &u)
Component-wise vector addition operator.
SbVec2d & operator-=(const SbVec2d &u)
Component-wise vector subtraction operator.
friend int operator==(const SbVec2d &v1, const SbVec2d &v2)
Equality comparison operator.
friend SbVec2d operator+(const SbVec2d &v1, const SbVec2d &v2)
Component-wise binary vector addition operator.
SbBool equals(const SbVec2d &v, double tolerance) const
Equality comparison within given tolerance - the square of the length of the maximum distance between...
double lengthSquared() const
Returns square length of vector.
Definition SbVec.h:357
2D vector class.
Definition SbVec.h:76
SbVec2f & operator-=(const SbVec2f &u)
Component-wise vector subtraction operator.
float & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:165
SbVec2f & setValue(float x, float y)
Sets the vector components.
float normalize()
Changes vector to be unit length.
SbVec2f & setValue(const SbVec2d &vec2d)
Sets value of vector from a double precision vector.
SbVec2f & operator*=(float d)
Component-wise scalar multiplication operator.
SbVec2f & operator+=(const SbVec2f &u)
Component-wise vector addition operator.
SbVec2f & operator/=(float d)
Component-wise scalar division operator.
friend int operator!=(const SbVec2f &v1, const SbVec2f &v2)
Inequality comparison operator.
Definition SbVec.h:242
SbBool equals(const SbVec2f &v, float tolerance) const
Equality comparison within given tolerance - the square of the length of the maximum distance between...
const float * getValue() const
Returns vector components.
Definition SbVec.h:108
SbVec2f()
Default constructor.
Definition SbVec.h:82
SbVec2f(float val)
Constructor that sets all components to the same value.
Definition SbVec.h:97
void negate()
Negates each component of vector in place.
friend SbVec2f operator+(const SbVec2f &v1, const SbVec2f &v2)
Component-wise binary vector addition operator.
void getValue(float &x, float &y) const
Returns vector components.
float lengthSquared() const
Returns square length of vector.
Definition SbVec.h:124
SbVec2f & setValue(const float v[2])
Sets the vector components.
SbVec2f operator-() const
Nondestructive unary negation - returns a new vector.
friend std::ostream & operator<<(std::ostream &os, const SbVec2f &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3612
SbVec2f(float x, float y)
Constructor given vector components.
Definition SbVec.h:92
float dot(const SbVec2f &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:102
SbVec2f(const T &v)
Constructor that converts an arbitrary SbVec2 to an SbVec2f.
Definition SbVec.h:260
float length() const
Returns geometric length of vector.
friend SbVec2f operator/(const SbVec2f &v, float d)
Component-wise binary scalar division operator.
SbVec2f(const float v[2])
Constructor given vector components.
Definition SbVec.h:87
friend SbVec2f operator*(const SbVec2f &v, float d)
Component-wise binary scalar multiplication operator.
friend int operator==(const SbVec2f &v1, const SbVec2f &v2)
Equality comparison operator.
2D vector class.
Definition SbVec.h:517
int32_t & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:559
friend std::ostream & operator<<(std::ostream &os, const SbVec2i32 &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3604
void getValue(int32_t &x, int32_t &y) const
Returns 2 individual components.
SbVec2i32 & operator+=(const SbVec2i32 &u)
Component-wise vector addition operator.
void negate()
Negates each component of vector in place.
SbVec2i32 & operator/=(int d)
Component-wise scalar division operator.
SbVec2i32()
Default constructor.
Definition SbVec.h:522
SbVec2i32(int32_t x, int32_t y)
Constructor given 2 individual components.
Definition SbVec.h:530
SbVec2i32 & operator*=(int d)
Component-wise scalar multiplication operator.
SbVec2i32 operator-() const
Nondestructive unary negation - returns a new vector.
SbVec2i32(const T &v)
Constructor that converts an arbitrary SbVec2 to an SbVec2i32.
Definition SbVec.h:648
int32_t dot(const SbVec2i32 &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:534
SbVec2i32 & setValue(const int32_t v[2])
Sets value of vector from array of 2 components.
friend int operator!=(const SbVec2i32 &v1, const SbVec2i32 &v2)
Inequality comparison operator.
Definition SbVec.h:636
SbVec2i32 & operator-=(const SbVec2i32 &u)
Component-wise vector subtraction operator.
friend int operator==(const SbVec2i32 &v1, const SbVec2i32 &v2)
Equality comparison operator.
friend SbVec2i32 operator+(const SbVec2i32 &v1, const SbVec2i32 &v2)
Component-wise binary vector addition operator.
friend SbVec2i32 operator/(const SbVec2i32 &v, int d)
Component-wise binary scalar division operator.
SbVec2i32 & setValue(int32_t x, int32_t y)
Sets value of vector from 2 individual components.
SbVec2i32(const int32_t v[2])
Constructor given an array of 2 components.
Definition SbVec.h:526
const int32_t * getValue() const
Returns pointer to array of 2 components.
Definition SbVec.h:539
friend SbVec2i32 operator*(const SbVec2i32 &v, int d)
Component-wise binary scalar multiplication operator.
2D vector class.
Definition SbVec.h:700
friend SbVec2s operator/(const SbVec2s &v, int d)
Component-wise binary scalar division operator.
SbVec2s(short x, short y)
Constructor given 2 components.
Definition SbVec.h:716
friend int operator!=(const SbVec2s &v1, const SbVec2s &v2)
Inequality comparison operator.
Definition SbVec.h:849
void getValue(short &x, short &y) const
Returns vector components.
friend SbVec2s operator*(const SbVec2s &v, int d)
Component-wise binary scalar multiplication operator.
SbVec2s(const SbVec2i32 &v)
Constructor given an SbVec2i32.
friend int operator==(const SbVec2s &v1, const SbVec2s &v2)
Equality comparison operator.
SbVec2s()
Default constructor.
Definition SbVec.h:706
SbVec2s & operator-=(const SbVec2s &u)
Component-wise vector subtraction operator.
SbVec2s & setValue(const short v[2])
Sets vector components.
SbVec2s & setValue(short x, short y)
Sets vector components.
SbVec2s(const short v[2])
Constructor given 2 components.
Definition SbVec.h:711
SbVec2s & operator+=(const SbVec2s &u)
Component-wise vector addition operator.
void negate()
Negates each component of vector in place.
SbVec2s(const T &v)
Constructor that converts an arbitrary SbVec2 to an SbVec2s.
Definition SbVec.h:861
friend SbVec2s operator+(const SbVec2s &v1, const SbVec2s &v2)
Component-wise binary vector addition operator.
friend std::ostream & operator<<(std::ostream &os, const SbVec2s &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3596
const short * getValue() const
Returns vector components.
Definition SbVec.h:734
int32_t dot(const SbVec2s &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:728
SbVec2s & operator/=(int d)
Component-wise scalar division operator.
SbVec2s operator=(const SbVec2i32 &v)
Component-wise set operator.
SbVec2s & operator*=(int d)
Component-wise scalar multiplication operator.
short & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:760
SbVec2s operator-() const
Nondestructive unary negation - returns a new vector.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D vector class ...
Definition SbVec.h:1214
SbBool equals(const SbVec3d &v, double tolerance) const
Equality comparison within given tolerance - the square of the length of the maximum distance between...
SbVec3d(SbPlane &p0, SbPlane &p1, SbPlane &p2)
Constructor given 3 planes.
double dot(const SbVec3d &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:1253
SbVec3d(const T &v)
Constructor that converts an arbitrary SbVec3 to an SbVec3d.
Definition SbVec.h:1456
double lengthSquared() const
Returns square length of vector.
Definition SbVec.h:1276
SbVec3d & operator+=(const SbVec3d &v)
Component-wise vector addition operator.
Definition SbVec.h:1350
friend int operator!=(const SbVec3d &v1, const SbVec3d &v2)
Inequality comparison operator.
Definition SbVec.h:1432
SbVec3d & setValue(const double v[3])
Sets the vector components.
Definition SbVec.h:1292
SbVec3d(double x, double y, double z)
Constructor given vector components.
Definition SbVec.h:1230
SbVec3d & setValue(const SbVec3f &vec3f)
Sets value of vector from a single precision vector.
Definition SbVec.h:1312
double length() const
Returns geometric length of vector.
SbVec3d & operator*=(double d)
Component-wise scalar multiplication operator.
Definition SbVec.h:1326
friend int operator==(const SbVec3d &v1, const SbVec3d &v2)
Equality comparison operator.
Definition SbVec.h:1426
double & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:1319
SbVec3d(const double v[3])
Constructor given vector components.
Definition SbVec.h:1224
SbVec3d cross(const SbVec3d &v) const
Returns right-handed cross product of vector and another vector.
Definition SbVec.h:1241
SbVec3d getClosestAxis() const
Returns principal axis that is closest (based on maximum dot product) to this vector.
void negate()
Negates each component of vector in place.
void getValue(double &x, double &y, double &z) const
Returns vector components.
SbVec3d operator-() const
Nondestructive unary negation - returns a new vector.
Definition SbVec.h:1375
friend SbVec3d operator*(const SbVec3d &v, double d)
Component-wise binary scalar multiplication operator.
Definition SbVec.h:1396
friend std::ostream & operator<<(std::ostream &os, const SbVec3d &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3644
const double * getValue() const
Returns vector components.
Definition SbVec.h:1259
SbVec3d()
Default constructor.
Definition SbVec.h:1219
double normalize()
Changes vector to be unit length, returning the length before normalization.
friend SbVec3d operator+(const SbVec3d &v1, const SbVec3d &v2)
Component-wise binary vector addition operator.
Definition SbVec.h:1414
SbVec3d & operator-=(const SbVec3d &v)
Component-wise vector subtraction operator.
Definition SbVec.h:1362
SbVec3d & setValue(double x, double y, double z)
Sets the vector components.
Definition SbVec.h:1298
friend SbVec3d operator/(const SbVec3d &v, double d)
Component-wise binary scalar division operator.
Definition SbVec.h:1408
SbVec3d & operator/=(double d)
Component-wise scalar division operator.
Definition SbVec.h:1338
SbVec3d & setValue(const SbVec3d &barycentic, const SbVec3d &v0, const SbVec3d &v1, const SbVec3d &v2)
Sets value of vector as the weighted average of 3 other vectors.
3D vector class.
Definition SbVec.h:932
SbVec3f cross(const SbVec3f &v) const
Returns right-handed cross product of vector and another vector.
Definition SbVec.h:959
SbVec3f & operator+=(const SbVec3f &v)
Component-wise vector addition operator.
Definition SbVec.h:1050
float length() const
Returns geometric length of vector.
float normalize()
Changes vector to be unit length, returning the length before normalization.
SbVec3f & setValue(const SbVec3f &barycentic, const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2)
Sets value of vector as the weighted average of 3 other vectors.
SbVec3f & operator/=(float d)
Component-wise scalar division operator.
SbVec3f & setValue(const float v[3])
Sets the vector components.
Definition SbVec.h:1010
friend SbVec3f operator+(const SbVec3f &v1, const SbVec3f &v2)
Component-wise binary vector addition operator.
Definition SbVec.h:1106
void getValue(float &x, float &y, float &z) const
Returns vector components.
SbVec3f(const float v[3])
Constructor given vector components.
Definition SbVec.h:942
SbVec3f(SbPlane &p0, SbPlane &p1, SbPlane &p2)
Constructor given 3 planes.
friend int operator!=(const SbVec3f &v1, const SbVec3f &v2)
Inequality comparison operator.
Definition SbVec.h:1124
float lengthSquared() const
Returns square length of vector.
Definition SbVec.h:994
SbVec3f operator-() const
Nondestructive unary negation - returns a new vector.
Definition SbVec.h:1067
friend int operator==(const SbVec3f &v1, const SbVec3f &v2)
Equality comparison operator.
Definition SbVec.h:1118
float dot(const SbVec3f &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:971
friend SbVec3f operator*(const SbVec3f &v, float d)
Component-wise binary scalar multiplication operator.
Definition SbVec.h:1088
SbBool equals(const SbVec3f &v, float tolerance) const
Equality comparison within given tolerance - the square of the length of the maximum distance between...
SbVec3f & operator-=(const SbVec3f &v)
Component-wise vector subtraction operator.
void negate()
Negates each component of vector in place.
SbVec3f(float x, float y, float z)
Constructor given vector components.
Definition SbVec.h:948
const float * getValue() const
Returns vector components.
Definition SbVec.h:977
friend SbVec3f operator/(const SbVec3f &v, float d)
Component-wise binary scalar division operator.
Definition SbVec.h:1100
SbVec3f & setValue(float x, float y, float z)
Sets the vector components.
Definition SbVec.h:1016
SbVec3f(const T &v)
Constructor that converts an arbitrary SbVec3 to an SbVec3f.
Definition SbVec.h:1148
SbVec3f()
Default constructor.
Definition SbVec.h:937
SbVec3f getClosestAxis() const
Returns principal axis that is closest (based on maximum dot product) to this vector.
friend std::ostream & operator<<(std::ostream &os, const SbVec3f &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3652
float & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:1033
SbVec3f & operator*=(float d)
Component-wise scalar multiplication operator.
3D vector class.
Definition SbVec.h:1517
const int32_t * getValue() const
Returns pointer to array of 3 components.
Definition SbVec.h:1546
int32_t & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:1590
SbVec3i32 & setValue(const int32_t v[3])
Sets value of vector from array of 3 components.
Definition SbVec.h:1558
SbVec3i32 operator+(const SbVec3i32 &v) const
Component-wise binary vector addition operator.
Definition SbVec.h:1696
SbVec3i32(const T &v)
Constructor that converts an arbitrary SbVec3 to an SbVec3i32.
Definition SbVec.h:1733
SbVec3i32 & setValue(int32_t x, int32_t y, int32_t z)
Sets value of vector from 3 individual components.
Definition SbVec.h:1570
SbVec3i32 operator-() const
Nondestructive unary negation - returns a new vector.
SbVec3i32(int32_t x, int32_t y, int32_t z)
Constructor given 3 individual components.
Definition SbVec.h:1530
SbVec3i32()
Default constructor.
Definition SbVec.h:1522
void getValue(int32_t &x, int32_t &y, int32_t &z) const
Returns 3 individual components.
SbVec3i32(const SbVec3s &vec)
Constructor given an SbVec3s (adapter).
SbVec3i32 & operator/=(int d)
Component-wise scalar division operator.
SbVec3i32 & operator-=(const SbVec3i32 &u)
Component-wise vector subtraction operator.
friend int operator==(const SbVec3i32 &v1, const SbVec3i32 &v2)
Equality comparison operator.
friend SbVec3i32 operator/(const SbVec3i32 &v, int d)
Component-wise binary scalar division operator.
SbVec3i32 & operator+=(const SbVec3i32 &u)
Component-wise vector addition operator.
Definition SbVec.h:1616
SbVec3i32 & setValue(const SbVec3s &v)
Sets value of vector from an SbVec3s (adapter).
friend std::ostream & operator<<(std::ostream &os, const SbVec3i32 &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3636
friend SbVec3i32 operator*(const SbVec3i32 &v, double d)
Component-wise binary scalar multiplication operator.
void negate()
Negates each component of vector in place.
int32_t dot(const SbVec3i32 &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:1538
SbVec3i32 & operator*=(int d)
Component-wise scalar multiplication operator.
friend int operator!=(const SbVec3i32 &v1, const SbVec3i32 &v2)
Inequality comparison operator.
Definition SbVec.h:1721
SbVec3i32 operator=(const SbVec3s &v)
Assignment operator given an SbVec3s (adapter).
SbVec3i32(const int32_t v[3])
Constructor given an array of 3 components.
Definition SbVec.h:1526
int32_t getMaxComponent() const
Returns max(x, y, z)
Definition SbVec.h:1751
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D vector class.
Definition SbVec.h:1797
friend SbVec3s operator/(const SbVec3s &v, int d)
Component-wise binary scalar division operator.
SbVec3s operator=(const SbVec3i32 &v)
Assignment operator given SbVec3i32 (adapter).
friend SbVec3s operator+(const SbVec3s &v1, const SbVec3s &v2)
Component-wise binary vector addition operator.
friend SbVec3s operator*(const SbVec3s &v, int d)
Component-wise binary scalar multiplication operator.
SbVec3s & setValue(const short v[3])
Sets vector components.
friend int operator==(const SbVec3s &v1, const SbVec3s &v2)
Equality comparison operator.
SbVec3s(const short v[3])
Constructor given 3 components.
Definition SbVec.h:1808
friend int operator!=(const SbVec3s &v1, const SbVec3s &v2)
Inequality comparison operator.
Definition SbVec.h:1948
void getValue(short &x, short &y, short &z) const
Returns vector components.
SbVec3s & operator/=(int d)
Component-wise scalar division operator.
SbVec3s operator-() const
Nondestructive unary negation - returns a new vector.
SbVec3s & operator-=(const SbVec3s &u)
Component-wise vector subtraction operator.
void negate()
Negates each component of vector in place.
SbVec3s & operator*=(int d)
Component-wise scalar multiplication operator.
SbVec3s(const T &v)
Constructor that converts an arbitrary SbVec3 to an SbVec3s.
Definition SbVec.h:1960
const short * getValue() const
Returns vector components.
Definition SbVec.h:1832
int32_t dot(const SbVec3s &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:1826
SbVec3s()
Default constructor.
Definition SbVec.h:1803
short & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:1858
SbVec3s & operator+=(const SbVec3s &u)
Component-wise vector addition operator.
friend std::ostream & operator<<(std::ostream &os, const SbVec3s &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3628
SbVec3s(short x, short y, short z)
Constructor given 3 components.
Definition SbVec.h:1813
SbVec3s(const SbVec3i32 &v)
Constructor given an SbVec3i32 (adapter).
SbVec3s & setValue(short x, short y, short z)
Sets vector components.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 4D vector class.
Definition SbVec.h:2014
SbVec4b & setValue(char x, char y, char z, char w)
Sets vector components.
char & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:2068
friend int operator==(const SbVec4b &v1, const SbVec4b &v2)
Equality comparison operator.
void negate()
Negates each component of vector in place.
friend SbVec4b operator/(const SbVec4b &v, int d)
Component-wise binary scalar division operator.
int32_t dot(const SbVec4b &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:2035
SbVec4b & operator*=(int d)
Component-wise scalar multiplication operator.
SbVec4b(const T &v)
Constructor that converts an arbitrary SbVec4 to an SbVec4b.
Definition SbVec.h:2162
friend SbVec4b operator+(const SbVec4b &v1, const SbVec4b &v2)
Component-wise binary vector addition operator.
SbVec4b & operator/=(int d)
Component-wise scalar division operator.
const char * getValue() const
Returns vector components.
Definition SbVec.h:2042
SbVec4b & operator+=(const SbVec4b &u)
Component-wise vector addition operator.
friend SbVec4b operator*(const SbVec4b &v, int d)
Component-wise binary scalar multiplication operator.
SbVec4b & operator-=(const SbVec4b &u)
Component-wise vector subtraction operator.
friend int operator!=(const SbVec4b &v1, const SbVec4b &v2)
Inequality comparison operator.
Definition SbVec.h:2150
SbVec4b & setValue(const char v[4])
Sets vector components.
void getValue(char &x, char &y, char &z, char &w) const
Returns vector components.
friend std::ostream & operator<<(std::ostream &os, const SbVec4b &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3661
SbVec4b()
Default constructor.
Definition SbVec.h:2020
SbVec4b operator-() const
Nondestructive unary negation - returns a new vector.
SbVec4b(const char v[4])
Constructor given 4 components.
Definition SbVec.h:2025
SbVec4b(char x, char y, char z, char w)
Constructor given 4 components.
Definition SbVec.h:2030
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 4D vector class ...
Definition SbVec.h:2427
void getValue(double &x, double &y, double &z, double &w) const
Returns vector components.
SbVec4d(double x, double y, double z, double w)
Constructor given vector components.
Definition SbVec.h:2443
friend std::ostream & operator<<(std::ostream &os, const SbVec4d &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3669
SbVec4d(const T &v)
Constructor that converts an arbitrary SbVec4 to an SbVec4d.
Definition SbVec.h:2586
double & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:2509
void getReal(SbVec3d &v) const
Returns the real portion of the vector by dividing by the fourth value.
friend int operator==(const SbVec4d &v1, const SbVec4d &v2)
Equality comparison operator.
SbVec4d & setValue(const double v[4])
Sets the vector components.
double length() const
Returns geometric length of vector.
SbVec4d(const double v[4])
Constructor given vector components.
Definition SbVec.h:2438
void negate()
Negates each component of vector in place.
SbVec4d & setValue(const SbVec4f &vec4f)
Sets value of vector from a single precision vector.
Definition SbVec.h:2501
double normalize()
Changes vector to be unit length.
friend int operator!=(const SbVec4d &v1, const SbVec4d &v2)
Inequality comparison operator.
Definition SbVec.h:2568
double dot(const SbVec4d &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:2448
SbVec4d & operator-=(const SbVec4d &u)
Component-wise vector subtraction operator.
friend SbVec4d operator+(const SbVec4d &v1, const SbVec4d &v2)
Component-wise binary vector addition operator.
SbVec4d & operator*=(double d)
Component-wise scalar multiplication operator.
SbVec4d operator-() const
Nondestructive unary negation - returns a new vector.
SbBool equals(const SbVec4d &v, double tolerance) const
Equality comparison within given tolerance - the square of the length of the maximum distance between...
friend SbVec4d operator*(const SbVec4d &v, double d)
Component-wise binary scalar multiplication operator.
double lengthSquared() const
Returns square length of vector.
Definition SbVec.h:2475
SbVec4d & operator/=(double d)
Component-wise scalar division operator.
const double * getValue() const
Returns vector components.
Definition SbVec.h:2459
SbVec4d & setValue(double x, double y, double z, double w)
Sets the vector components.
friend SbVec4d operator/(const SbVec4d &v, double d)
Component-wise binary scalar division operator.
SbVec4d & operator+=(const SbVec4d &u)
Component-wise vector addition operator.
SbVec4d()
Default constructor.
Definition SbVec.h:2433
4D vector class.
Definition SbVec.h:2214
float lengthSquared() const
Returns square length of vector.
Definition SbVec.h:2262
float length() const
Returns geometric length of vector.
SbVec4f(const T &v)
Constructor that converts an arbitrary SbVec4 to an SbVec4f.
Definition SbVec.h:2371
void negate()
Negates each component of vector in place.
float normalize()
Changes vector to be unit length.
SbVec4f & operator/=(float d)
Component-wise scalar division operator.
SbVec4f & operator+=(const SbVec4f &u)
Component-wise vector addition operator.
SbVec4f & setValue(const float v[4])
Sets the vector components.
SbVec4f operator-() const
Nondestructive unary negation - returns a new vector.
friend int operator!=(const SbVec4f &v1, const SbVec4f &v2)
Inequality comparison operator.
Definition SbVec.h:2353
SbVec4f & operator*=(float d)
Component-wise scalar multiplication operator.
void getReal(SbVec3f &v) const
Returns the real portion of the vector by dividing by the fourth value.
const float * getValue() const
Returns vector components.
Definition SbVec.h:2246
SbVec4f & operator-=(const SbVec4f &u)
Component-wise vector subtraction operator.
SbBool equals(const SbVec4f &v, float tolerance) const
Equality comparison within given tolerance - the square of the length of the maximum distance between...
friend SbVec4f operator*(const SbVec4f &v, float d)
Component-wise binary scalar multiplication operator.
SbVec4f & setValue(float x, float y, float z, float w)
Sets the vector components.
friend int operator==(const SbVec4f &v1, const SbVec4f &v2)
Equality comparison operator.
void getValue(float &x, float &y, float &z, float &w) const
Returns vector components.
friend SbVec4f operator+(const SbVec4f &v1, const SbVec4f &v2)
Component-wise binary vector addition operator.
SbVec4f & setValue(const SbVec4d &vec4d)
Sets value of vector from a double precision vector.
SbVec4f(const float v[4])
Constructor given vector components.
Definition SbVec.h:2225
SbVec4f()
Default constructor.
Definition SbVec.h:2220
SbVec4f(float x, float y, float z, float w)
Constructor given vector components.
Definition SbVec.h:2230
friend std::ostream & operator<<(std::ostream &os, const SbVec4f &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3677
float dot(const SbVec4f &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:2235
float & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:2294
friend SbVec4f operator/(const SbVec4f &v, float d)
Component-wise binary scalar division operator.
4D vector class.
Definition SbVec.h:2639
friend SbVec4i32 operator/(const SbVec4i32 &v, int d)
Component-wise binary scalar division operator.
SbVec4i32(const T &v)
Constructor that converts an arbitrary SbVec4 to an SbVec4i32.
Definition SbVec.h:2771
SbVec4i32(int32_t x, int32_t y, int32_t z, int32_t w)
Constructor given 4 individual components.
Definition SbVec.h:2652
const int32_t * getValue() const
Returns pointer to array of 4 components.
Definition SbVec.h:2661
friend SbVec4i32 operator+(const SbVec4i32 &v1, const SbVec4i32 &v2)
Component-wise binary vector addition operator.
friend int operator!=(const SbVec4i32 &v1, const SbVec4i32 &v2)
Inequality comparison operator.
Definition SbVec.h:2759
SbVec4i32 & operator-=(const SbVec4i32 &u)
Component-wise vector subtraction operator.
friend int operator==(const SbVec4i32 &v1, const SbVec4i32 &v2)
Equality comparison operator.
friend SbVec4i32 operator*(const SbVec4i32 &v, int d)
Component-wise binary scalar multiplication operator.
SbVec4i32()
Default constructor.
Definition SbVec.h:2644
friend std::ostream & operator<<(std::ostream &os, const SbVec4i32 &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3685
SbVec4i32 & operator+=(const SbVec4i32 &u)
Component-wise vector addition operator.
SbVec4i32 & operator*=(int d)
Component-wise scalar multiplication operator.
SbVec4i32 & setValue(const int32_t v[4])
Sets value of vector from array of 4 components.
void getValue(int32_t &x, int32_t &y, int32_t &z, int32_t &w) const
Returns 4 individual components.
SbVec4i32(const int32_t v[4])
Constructor given an array of 4 components.
Definition SbVec.h:2648
void negate()
Negates each component of vector in place.
SbVec4i32 operator-() const
Nondestructive unary negation - returns a new vector.
int32_t & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:2681
SbVec4i32 & setValue(int32_t x, int32_t y, int32_t z, int32_t w)
Sets value of vector from 4 individual components.
int32_t dot(const SbVec4i32 &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:2656
SbVec4i32 & operator/=(int d)
Component-wise scalar division operator.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 4D vector class.
Definition SbVec.h:2824
void negate()
Negates each component of vector in place.
SbVec4s(const short v[4])
Constructor given 4 components.
Definition SbVec.h:2835
friend int operator!=(const SbVec4s &v1, const SbVec4s &v2)
Inequality comparison operator.
Definition SbVec.h:2959
short & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:2877
int32_t dot(const SbVec4s &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:2845
const short * getValue() const
Returns vector components.
Definition SbVec.h:2851
friend SbVec4s operator/(const SbVec4s &v, int d)
Component-wise binary scalar division operator.
SbVec4s operator-() const
Nondestructive unary negation - returns a new vector.
SbVec4s & operator+=(const SbVec4s &u)
Component-wise vector addition operator.
SbVec4s & operator/=(int d)
Component-wise scalar division operator.
friend SbVec4s operator*(const SbVec4s &v, int d)
Component-wise binary scalar multiplication operator.
void getValue(short &x, short &y, short &z, short &w) const
Returns vector components.
friend std::ostream & operator<<(std::ostream &os, const SbVec4s &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3693
SbVec4s & setValue(short x, short y, short z, short w)
Sets vector components.
SbVec4s(const T &v)
Constructor that converts an arbitrary SbVec4 to an SbVec4s.
Definition SbVec.h:2971
SbVec4s & operator*=(int d)
Component-wise scalar multiplication operator.
friend int operator==(const SbVec4s &v1, const SbVec4s &v2)
Equality comparison operator.
SbVec4s & operator-=(const SbVec4s &u)
Component-wise vector subtraction operator.
SbVec4s & setValue(const short v[4])
Sets vector components.
SbVec4s(short x, short y, short z, short w)
Constructor given 4 components.
Definition SbVec.h:2840
friend SbVec4s operator+(const SbVec4s &v1, const SbVec4s &v2)
Component-wise binary vector addition operator.
SbVec4s()
Default constructor.
Definition SbVec.h:2830
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 4D vector class.
Definition SbVec.h:3421
void negate()
Negates each component of vector in place.
friend SbVec4ub operator*(const SbVec4ub &v, int d)
Component-wise binary scalar multiplication operator.
int32_t dot(const SbVec4ub &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:3443
SbVec4ub & operator-=(const SbVec4ub &u)
Component-wise vector subtraction operator.
SbVec4ub & setValue(unsigned char x, unsigned char y, unsigned char z, unsigned char w)
Sets vector components.
SbVec4ub operator-() const
Nondestructive unary negation - returns a new vector.
SbVec4ub(const unsigned char v[4])
Constructor given 4 components.
Definition SbVec.h:3432
SbVec4ub & operator/=(int d)
Component-wise scalar division operator.
friend SbVec4ub operator/(const SbVec4ub &v, int d)
Component-wise binary scalar division operator.
SbVec4ub & setValue(const unsigned char v[4])
Sets vector components.
void clamp(unsigned char a, unsigned char b)
Clamp each component between a and b.
Definition SbVec.h:3581
void getValue(unsigned char &x, unsigned char &y, unsigned char &z, unsigned char &w) const
Returns vector components.
friend int operator!=(const SbVec4ub &v1, const SbVec4ub &v2)
Inequality comparison operator.
Definition SbVec.h:3557
unsigned char & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:3475
SbVec4ub & operator*=(int d)
Component-wise scalar multiplication operator.
const unsigned char * getValue() const
Returns vector components.
Definition SbVec.h:3449
friend SbVec4ub operator+(const SbVec4ub &v1, const SbVec4ub &v2)
Component-wise binary vector addition operator.
SbVec4ub & operator+=(const SbVec4ub &u)
Component-wise vector addition operator.
SbVec4ub()
Default constructor.
Definition SbVec.h:3427
friend std::ostream & operator<<(std::ostream &os, const SbVec4ub &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3701
SbVec4ub(const T &v)
Constructor that converts an arbitrary SbVec4 to an SbVec4ub.
Definition SbVec.h:3569
friend int operator==(const SbVec4ub &v1, const SbVec4ub &v2)
Equality comparison operator.
SbVec4ub(unsigned char x, unsigned char y, unsigned char z, unsigned char w)
Constructor given 4 components.
Definition SbVec.h:3437
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 4D vector class.
Definition SbVec.h:3027
int32_t dot(const SbVec4ui32 &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:3049
friend std::ostream & operator<<(std::ostream &os, const SbVec4ui32 &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3709
uint32_t & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:3078
SbVec4ui32 & setValue(uint32_t x, uint32_t y, uint32_t z, uint32_t w)
Sets vector components.
SbVec4ui32 & setValue(const uint32_t v[4])
Sets vector components.
void getValue(uint32_t &x, uint32_t &y, uint32_t &z, uint32_t &w) const
Returns vector components.
SbVec4ui32 & operator*=(int d)
Component-wise scalar multiplication operator.
friend SbVec4ui32 operator*(const SbVec4ui32 &v, int d)
Component-wise binary scalar multiplication operator.
SbVec4ui32(const T &v)
Constructor that converts an arbitrary SbVec4 to an SbVec4ui32.
Definition SbVec.h:3166
SbVec4ui32 & operator-=(const SbVec4ui32 &u)
Component-wise vector subtraction operator.
SbVec4ui32()
Default constructor.
Definition SbVec.h:3033
friend SbVec4ui32 operator+(const SbVec4ui32 &v1, const SbVec4ui32 &v2)
Component-wise binary vector addition operator.
friend int operator!=(const SbVec4ui32 &v1, const SbVec4ui32 &v2)
Inequality comparison operator.
Definition SbVec.h:3154
const uint32_t * getValue() const
Returns vector components.
Definition SbVec.h:3055
SbVec4ui32 & operator+=(const SbVec4ui32 &u)
Component-wise vector addition operator.
SbVec4ui32(uint32_t x, uint32_t y, uint32_t z, uint32_t w)
Constructor given 4 components.
Definition SbVec.h:3043
friend SbVec4ui32 operator/(const SbVec4ui32 &v, int d)
Component-wise binary scalar division operator.
SbVec4ui32(const uint32_t v[4])
Constructor given 4 components.
Definition SbVec.h:3038
friend SbVec4ui32 operator-(const SbVec4ui32 &v1, const SbVec4ui32 &v2)
Component-wise binary vector subtraction operator.
friend int operator==(const SbVec4ui32 &v1, const SbVec4ui32 &v2)
Equality comparison operator.
SbVec4ui32 & operator/=(int d)
Component-wise scalar division operator.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 4D vector class.
Definition SbVec.h:3219
SbVec4us & operator+=(const SbVec4us &u)
Component-wise vector addition operator.
friend std::ostream & operator<<(std::ostream &os, const SbVec4us &v)
Writes the vector to the specified output stream.
Definition SbVec.h:3717
friend int operator!=(const SbVec4us &v1, const SbVec4us &v2)
Inequality comparison operator.
Definition SbVec.h:3355
SbVec4us & operator-=(const SbVec4us &u)
Component-wise vector subtraction operator.
SbVec4us & setValue(const unsigned short v[4])
Sets vector components.
friend int operator==(const SbVec4us &v1, const SbVec4us &v2)
Equality comparison operator.
SbVec4us & operator*=(int d)
Component-wise scalar multiplication operator.
SbVec4us & setValue(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
Sets vector components.
SbVec4us(const unsigned short v[4])
Constructor given 4 components.
Definition SbVec.h:3230
SbVec4us()
Default constructor.
Definition SbVec.h:3225
void negate()
Negates each component of vector in place.
friend SbVec4us operator/(const SbVec4us &v, int d)
Component-wise binary scalar division operator.
unsigned short & operator[](int i)
Accesses indexed component of vector.
Definition SbVec.h:3273
SbVec4us operator-() const
Nondestructive unary negation - returns a new vector.
SbVec4us(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
Constructor given 4 components.
Definition SbVec.h:3235
friend SbVec4us operator*(const SbVec4us &v, int d)
Component-wise binary scalar multiplication operator.
const unsigned short * getValue() const
Returns vector components.
Definition SbVec.h:3247
int32_t dot(const SbVec4us &v) const
Returns dot (inner) product of vector and another vector.
Definition SbVec.h:3241
void getValue(unsigned short &x, unsigned short &y, unsigned short &z, unsigned short &w) const
Returns vector components.
friend SbVec4us operator+(const SbVec4us &v1, const SbVec4us &v2)
Component-wise binary vector addition operator.
SbVec4us(const T &v)
Constructor that converts an arbitrary SbVec4 to an SbVec4us.
Definition SbVec.h:3367
SbVec4us & operator/=(int d)
Component-wise scalar division operator.
int SbBool
Boolean type.
Definition SbBase.h:87
T Clamp(T a, T minV, T maxV)
Clamps value to given range [minV, maxV].
T Max(T a, T b)