00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SB_VEC_
00024 #define _SB_VEC_
00025
00026 #include <Inventor/SbBase.h>
00027 #include <Inventor/SbMathHelper.h>
00028 #include <Inventor/STL/iostream>
00029
00030 class SbVec2d;
00031 class SbVec3d;
00032 class SbVec3s;
00033 class SbVec4d;
00034 class SbPlane;
00035
00037
00038
00039
00040
00041
00042
00044
00076 class SbVec2f {
00077 public:
00078
00082 SbVec2f() { }
00083
00087 SbVec2f(const float v[2]) { setValue(v); }
00088
00092 SbVec2f(float x, float y) { setValue(x, y); }
00093
00097 SbVec2f(float val) { setValue(val,val); }
00098
00102 inline float dot(const SbVec2f &v) const
00103 { return vec[0] * v.vec[0] + vec[1] * v.vec[1]; }
00104
00108 const float *getValue() const { return vec; }
00109
00113 void getValue(float &x, float &y) const;
00114
00118 float length() const;
00119
00124 inline float lengthSquared() const
00125 { return vec[0] * vec[0] + vec[1] * vec[1]; }
00126
00130 void negate();
00131
00135 float normalize();
00136
00140 SbVec2f &setValue(const float v[2]);
00141
00145 SbVec2f &setValue(float x, float y);
00146
00159 SbVec2f &setValue(const SbVec2d &vec2d);
00160
00162
00165 float & operator [](int i) { return (vec[i]); }
00166 const float & operator [](int i) const { return (vec[i]); }
00168
00172 SbVec2f & operator *=(float d);
00173
00177 inline SbVec2f operator *(const SbVec2f &v) const
00178 {
00179 return SbVec2f(vec[0]*v.vec[0],
00180 vec[1]*v.vec[1]);
00181 }
00182
00186 inline SbVec2f& operator *=(const SbVec2f &v)
00187 {
00188 *this = (*this)*v;
00189 return *this;
00190 }
00191
00195 SbVec2f & operator /=(float d);
00196
00200 SbVec2f & operator +=(const SbVec2f &u);
00204 SbVec2f & operator -=(const SbVec2f &u);
00205
00209 SbVec2f operator -() const;
00210
00214 friend SbVec2f operator *(const SbVec2f &v, float d);
00218 friend SbVec2f operator *(float d, const SbVec2f &v)
00219 { return v * d; }
00223 friend SbVec2f operator /(const SbVec2f &v, float d);
00224
00228 friend SbVec2f operator +(const SbVec2f &v1, const SbVec2f &v2);
00229
00233 friend SbVec2f operator -(const SbVec2f &v1, const SbVec2f &v2);
00234
00238 friend int operator ==(const SbVec2f &v1, const SbVec2f &v2);
00242 friend int operator !=(const SbVec2f &v1, const SbVec2f &v2)
00243 { return !(v1 == v2); }
00244
00248 friend inline std::ostream& operator << (std::ostream& os, const SbVec2f& v);
00249
00254 SbBool equals(const SbVec2f& v, float tolerance) const;
00255
00259 template<typename T>
00260 explicit SbVec2f(const T& v)
00261 {
00262
00263 vec[0] = float(v[0]);
00264 vec[1] = float(v[1]);
00265 }
00266
00267 private:
00268 float vec[2];
00269
00270 };
00271
00273
00274
00275
00276
00277
00278
00280
00315 class SbVec2d {
00316 public:
00317
00321 SbVec2d() { }
00322
00326 SbVec2d(const double v[2]) { setValue(v); }
00327
00331 SbVec2d(double x, double y) { setValue(x, y); }
00332
00336 inline double dot(const SbVec2d &v) const
00337 { return vec[0] * v.vec[0] + vec[1] * v.vec[1]; }
00338
00342 const double *getValue() const { return vec; }
00343
00347 void getValue(double &x, double &y) const;
00348
00352 double length() const;
00353
00358 inline double lengthSquared() const
00359 { return vec[0] * vec[0] + vec[1] * vec[1]; }
00360
00364 void negate();
00365
00369 double normalize();
00370
00374 SbVec2d &setValue(const double v[2]);
00375
00379 SbVec2d &setValue(double x, double y);
00380
00384 SbVec2d &setValue(const SbVec2f &vec2f)
00385 { vec[0] = vec2f[0] ; vec[1] = vec2f[1] ; return (*this) ; }
00386
00388
00391 double & operator [](int i) { return (vec[i]); }
00392 const double & operator [](int i) const { return (vec[i]); }
00394
00398 SbVec2d & operator *=(double d);
00399
00403 SbVec2d & operator /=(double d);
00404
00408 SbVec2d & operator +=(const SbVec2d &u);
00412 SbVec2d & operator -=(const SbVec2d &u);
00413
00417 SbVec2d operator -() const;
00418
00422 friend SbVec2d operator *(const SbVec2d &v, double d);
00426 friend SbVec2d operator *(double d, const SbVec2d &v)
00427 { return v * d; }
00431 friend SbVec2d operator /(const SbVec2d &v, double d);
00432
00436 friend SbVec2d operator +(const SbVec2d &v1, const SbVec2d &v2);
00437
00441 friend SbVec2d operator -(const SbVec2d &v1, const SbVec2d &v2);
00442
00446 friend int operator ==(const SbVec2d &v1, const SbVec2d &v2);
00450 friend int operator !=(const SbVec2d &v1, const SbVec2d &v2)
00451 { return !(v1 == v2); }
00452
00457 SbBool equals(const SbVec2d& v, double tolerance) const;
00458
00462 friend inline std::ostream& operator << (std::ostream& os, const SbVec2d& v);
00463
00467 template<typename T>
00468 explicit SbVec2d(const T& v)
00469 {
00470
00471 vec[0] = double(v[0]);
00472 vec[1] = double(v[1]);
00473 }
00474
00475 private:
00476 double vec[2];
00477
00478 };
00479
00481
00482
00483
00484
00485
00486
00488
00518 class SbVec2i32 {
00519 public:
00523 SbVec2i32() { }
00527 SbVec2i32(const int32_t v[2]) { setValue(v); }
00531 SbVec2i32(int32_t x, int32_t y) { setValue(x, y); }
00535 inline int32_t dot(const SbVec2i32 &v) const
00536 { return vec[0] * v.vec[0] + vec[1] * v.vec[1]; }
00540 const int32_t *getValue() const { return vec; }
00544 void getValue(int32_t &x, int32_t &y) const;
00548 void negate();
00552 SbVec2i32 &setValue(const int32_t v[2]);
00556 SbVec2i32 &setValue(int32_t x, int32_t y);
00560 int32_t & operator [](int i) { return (vec[i]); }
00564 const int32_t & operator [](int i) const { return (vec[i]); }
00568 SbVec2i32 & operator *=(int d);
00572 SbVec2i32 & operator *=(double d);
00573
00577 SbVec2i32 & operator /=(int d);
00581 SbVec2i32 & operator /=(double d)
00582 { return *this *= (1.0 / d); }
00586 SbVec2i32 & operator +=(const SbVec2i32 &u);
00590 SbVec2i32 & operator -=(const SbVec2i32 &u);
00594 SbVec2i32 operator -() const;
00598 friend SbVec2i32 operator *(const SbVec2i32 &v, int d);
00602 friend SbVec2i32 operator *(const SbVec2i32 &v, double d);
00606 friend SbVec2i32 operator *(int d, const SbVec2i32 &v)
00607 { return v * d; }
00611 friend SbVec2i32 operator *(double d, const SbVec2i32 &v)
00612 { return v * d; }
00616 friend SbVec2i32 operator /(const SbVec2i32 &v, int d);
00620 friend SbVec2i32 operator /(const SbVec2i32 &v, double d)
00621 { return v * (1.0 / d); }
00625 friend SbVec2i32 operator +(const SbVec2i32 &v1, const SbVec2i32 &v2);
00629 friend SbVec2i32 operator -(const SbVec2i32 &v1, const SbVec2i32 &v2);
00633 friend int operator ==(const SbVec2i32 &v1, const SbVec2i32 &v2);
00637 friend int operator !=(const SbVec2i32 &v1, const SbVec2i32 &v2)
00638 { return !(v1 == v2); }
00639
00643 friend inline std::ostream& operator << (std::ostream& os, const SbVec2i32& v);
00644
00648 template<typename T>
00649 explicit SbVec2i32(const T& v)
00650 {
00651
00652 vec[0] = int32_t(v[0]);
00653 vec[1] = int32_t(v[1]);
00654 }
00655
00656
00657
00658 private:
00659 int32_t vec[2];
00660 };
00661
00663
00664
00665
00666
00667
00668
00670
00702 class SbVec2s {
00703 public:
00704
00708 SbVec2s() { }
00709
00713 SbVec2s(const short v[2]) { setValue(v); }
00714
00718 SbVec2s(short x, short y) { setValue(x, y); }
00719
00723 #ifndef OIV_DO_NOT_ALLOW_I32_TO_I16_AUTO_CAST
00724 explicit SbVec2s(const SbVec2i32 &v);
00725 #endif
00726
00730 inline int32_t dot(const SbVec2s &v) const
00731 { return vec[0] * v.vec[0] + vec[1] * v.vec[1]; }
00732
00736 const short *getValue() const { return vec; }
00737
00741 void getValue(short &x, short &y) const;
00742
00746 void negate();
00747
00751 SbVec2s &setValue(const short v[2]);
00752
00756 SbVec2s &setValue(short x, short y);
00757
00759
00762 short & operator [](int i) { return (vec[i]); }
00763 const short & operator [](int i) const { return (vec[i]); }
00765
00769 SbVec2s & operator *=(int d);
00773 SbVec2s & operator *=(double d);
00774
00778 SbVec2s & operator /=(int d);
00782 SbVec2s & operator /=(double d)
00783 { return *this *= (1.0 / d); }
00784
00788 SbVec2s & operator +=(const SbVec2s &u);
00792 SbVec2s & operator -=(const SbVec2s &u);
00793
00797 SbVec2s operator -() const;
00798
00802 #ifndef OIV_DO_NOT_ALLOW_I32_TO_I16_AUTO_CAST
00803 SbVec2s operator = (const SbVec2i32 &v);
00804 #endif
00805
00809 friend SbVec2s operator *(const SbVec2s &v, int d);
00813 friend SbVec2s operator *(const SbVec2s &v, double d);
00817 friend SbVec2s operator *(int d, const SbVec2s &v)
00818 { return v * d; }
00822 friend SbVec2s operator *(double d, const SbVec2s &v)
00823 { return v * d; }
00827 friend SbVec2s operator /(const SbVec2s &v, int d);
00831 friend SbVec2s operator /(const SbVec2s &v, double d)
00832 { return v * (1.0 / d); }
00833
00837 friend SbVec2s operator +(const SbVec2s &v1, const SbVec2s &v2);
00838
00842 friend SbVec2s operator -(const SbVec2s &v1, const SbVec2s &v2);
00843
00847 friend int operator ==(const SbVec2s &v1, const SbVec2s &v2);
00851 friend int operator !=(const SbVec2s &v1, const SbVec2s &v2)
00852 { return !(v1 == v2); }
00853
00857 friend inline std::ostream& operator << (std::ostream& os, const SbVec2s& v);
00858
00862 template<typename T>
00863 explicit SbVec2s(const T& v)
00864 {
00865
00866 vec[0] = short(v[0]);
00867 vec[1] = short(v[1]);
00868 }
00869
00870 private:
00871 short vec[2];
00872
00873 };
00874
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00894
00935 class SbVec3f {
00936 public:
00940 SbVec3f()
00941 { }
00942
00946 SbVec3f(const float v[3])
00947 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; }
00948
00952 SbVec3f(float x, float y, float z)
00953 { vec[0] = x; vec[1] = y; vec[2] = z; }
00954
00958 SbVec3f(SbPlane &p0, SbPlane &p1, SbPlane &p2);
00959
00963 inline SbVec3f cross(const SbVec3f &v) const
00964 {
00965 return SbVec3f(
00966 vec[1] * v.vec[2] - vec[2] * v.vec[1],
00967 vec[2] * v.vec[0] - vec[0] * v.vec[2],
00968 vec[0] * v.vec[1] - vec[1] * v.vec[0]
00969 );
00970 }
00971
00975 float dot(const SbVec3f &v) const
00976 { return (vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2]); }
00977
00981 inline const float *getValue() const
00982 { return vec; }
00983
00987 void getValue(float &x, float &y, float &z) const;
00988
00992 float length() const;
00993
00998 inline float lengthSquared() const
00999 { return vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]; }
01000
01004 float normalize();
01005
01009 void negate();
01010
01014 inline SbVec3f &setValue(const float v[3])
01015 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; return *this; }
01016
01020 inline SbVec3f &setValue(float x, float y, float z)
01021 { vec[0] = x; vec[1] = y; vec[2] = z; return *this; }
01022
01026 SbVec3f &setValue(const SbVec3f &barycentic, const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2);
01027
01031 SbVec3f &setValue(const SbVec3d &vec3d);
01032
01034
01037 float & operator [](int i) { return (vec[i]); }
01038 const float & operator [](int i) const { return (vec[i]); }
01040
01044 SbVec3f & operator *=(float d);
01045
01049 SbVec3f & operator /=(float d);
01050
01054 inline SbVec3f & operator +=(const SbVec3f &v)
01055 {
01056 vec[0] += v.vec[0];
01057 vec[1] += v.vec[1];
01058 vec[2] += v.vec[2];
01059
01060 return *this;
01061 }
01062
01066 SbVec3f & operator -=(const SbVec3f &v);
01067
01071 inline SbVec3f operator -() const
01072 { return SbVec3f(-vec[0], -vec[1], -vec[2]); }
01073
01077 inline SbVec3f operator *(const SbVec3f &v) const
01078 { return SbVec3f(vec[0]*v.vec[0], vec[1]*v.vec[1], vec[2]*v.vec[2]); }
01079
01083 inline SbVec3f& operator *=(const SbVec3f &v)
01084 {
01085 *this = (*this)*v;
01086 return *this;
01087 }
01088
01092 friend inline SbVec3f operator *(const SbVec3f &v, float d)
01093 { return SbVec3f(v.vec[0] * d, v.vec[1] * d, v.vec[2] * d); }
01094
01098 friend inline SbVec3f operator *(float d, const SbVec3f &v)
01099 { return v * d; }
01100
01104 friend inline SbVec3f operator /(const SbVec3f &v, float d)
01105 { return SbVec3f(v.vec[0] / d, v.vec[1] / d, v.vec[2] / d); }
01106
01110 friend inline SbVec3f operator +(const SbVec3f &v1, const SbVec3f &v2)
01111 { return SbVec3f(v1.vec[0] + v2.vec[0], v1.vec[1] + v2.vec[1], v1.vec[2] + v2.vec[2]); }
01112
01116 friend inline SbVec3f operator -(const SbVec3f &v1, const SbVec3f &v2)
01117 { return SbVec3f(v1.vec[0] - v2.vec[0], v1.vec[1] - v2.vec[1], v1.vec[2] - v2.vec[2]); }
01118
01122 friend inline int operator ==(const SbVec3f &v1, const SbVec3f &v2)
01123 { return (v1.vec[0] == v2.vec[0] && v1.vec[1] == v2.vec[1] && v1.vec[2] == v2.vec[2]); }
01124
01128 friend inline int operator !=(const SbVec3f &v1, const SbVec3f &v2)
01129 { return !(v1 == v2); }
01130
01134 friend inline std::ostream& operator << (std::ostream& os, const SbVec3f& v);
01135
01140 SbBool equals(const SbVec3f& v, float tolerance) const;
01141
01146 SbVec3f getClosestAxis() const;
01147
01151 template<typename T>
01152 explicit SbVec3f(const T& v)
01153 {
01154
01155 vec[0] = float(v[0]);
01156 vec[1] = float(v[1]);
01157 vec[2] = float(v[2]);
01158 }
01159
01160 private:
01161 float vec[3];
01162
01163 };
01164
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01184
01219 class SbVec3d {
01220 public:
01224 SbVec3d()
01225 { }
01226
01230 SbVec3d(const double v[3])
01231 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; }
01232
01236 inline SbVec3d(double x, double y, double z)
01237 { vec[0] = x; vec[1] = y; vec[2] = z; }
01238
01242 SbVec3d(SbPlane &p0, SbPlane &p1, SbPlane &p2);
01243
01247 inline SbVec3d cross(const SbVec3d &v) const
01248 {
01249 return SbVec3d(
01250 vec[1] * v.vec[2] - vec[2] * v.vec[1],
01251 vec[2] * v.vec[0] - vec[0] * v.vec[2],
01252 vec[0] * v.vec[1] - vec[1] * v.vec[0]
01253 );
01254 }
01255
01259 inline double dot(const SbVec3d &v) const
01260 { return (vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2]); }
01261
01265 inline const double *getValue() const
01266 { return vec; }
01267
01271 void getValue(double &x, double &y, double &z) const;
01272
01276 double length() const;
01277
01282 inline double lengthSquared() const
01283 { return vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]; }
01284
01288 double normalize();
01289
01293 void negate();
01294
01298 SbVec3d &setValue(const double v[3])
01299 { vec[0] = v[0]; vec[1] = v[1]; vec[2] = v[2]; return *this; }
01300
01304 SbVec3d &setValue(double x, double y, double z)
01305 { vec[0] = x; vec[1] = y; vec[2] = z; return *this; }
01306
01310 SbVec3d &setValue(const SbVec3d &barycentic,
01311 const SbVec3d &v0,
01312 const SbVec3d &v1,
01313 const SbVec3d &v2);
01314
01318 inline SbVec3d &setValue(const SbVec3f &vec3f)
01319 { vec[0] = vec3f[0] ; vec[1] = vec3f[1] ; vec[2] = vec3f[2] ; return (*this) ; }
01320
01322
01325 double & operator [](int i) { return (vec[i]); }
01326 const double & operator [](int i) const { return (vec[i]); }
01328
01332 inline SbVec3d & operator *=(double d)
01333 {
01334 vec[0] *= d;
01335 vec[1] *= d;
01336 vec[2] *= d;
01337
01338 return *this;
01339 }
01340
01344 inline SbVec3d & operator /=(double d)
01345 {
01346 vec[0] /= d;
01347 vec[1] /= d;
01348 vec[2] /= d;
01349
01350 return *this;
01351 }
01352
01356 inline SbVec3d & operator +=(const SbVec3d &v)
01357 {
01358 vec[0] += v.vec[0];
01359 vec[1] += v.vec[1];
01360 vec[2] += v.vec[2];
01361
01362 return *this;
01363 }
01364
01368 inline SbVec3d & operator -=(const SbVec3d &v)
01369 {
01370 vec[0] -= v.vec[0];
01371 vec[1] -= v.vec[1];
01372 vec[2] -= v.vec[2];
01373
01374 return *this;
01375 }
01376
01377
01381 inline SbVec3d operator -() const
01382 { return SbVec3d(-vec[0], -vec[1], -vec[2]); }
01383
01387 inline SbVec3d operator *(const SbVec3d &v) const
01388 { return SbVec3d(vec[0]*v.vec[0], vec[1]*v.vec[1], vec[2]*v.vec[2]); }
01389
01393 inline SbVec3d& operator *=(const SbVec3d &v)
01394 {
01395 *this = (*this)*v;
01396 return *this;
01397 }
01398
01402 friend inline SbVec3d operator *(const SbVec3d &v, double d)
01403 { return SbVec3d(v.vec[0] * d, v.vec[1] * d, v.vec[2] * d); }
01404
01408 friend inline SbVec3d operator *(double d, const SbVec3d &v)
01409 { return v * d; }
01410
01414 friend inline SbVec3d operator /(const SbVec3d &v, double d)
01415 { return SbVec3d(v.vec[0] / d, v.vec[1] / d, v.vec[2] / d); }
01416
01420 friend inline SbVec3d operator +(const SbVec3d &v1, const SbVec3d &v2)
01421 { return SbVec3d(v1.vec[0] + v2.vec[0], v1.vec[1] + v2.vec[1], v1.vec[2] + v2.vec[2]); }
01422
01426 friend inline SbVec3d operator -(const SbVec3d &v1, const SbVec3d &v2)
01427 { return SbVec3d(v1.vec[0] - v2.vec[0], v1.vec[1] - v2.vec[1], v1.vec[2] - v2.vec[2]); }
01428
01432 friend inline int operator ==(const SbVec3d &v1, const SbVec3d &v2)
01433 { return (v1.vec[0] == v2.vec[0] && v1.vec[1] == v2.vec[1] && v1.vec[2] == v2.vec[2]); }
01434
01438 friend int operator !=(const SbVec3d &v1, const SbVec3d &v2)
01439 { return !(v1 == v2); }
01440
01445 SbBool equals(const SbVec3d& v, double tolerance) const;
01446
01450 friend inline std::ostream& operator << (std::ostream& os, const SbVec3d& v);
01451
01456 SbVec3d getClosestAxis() const;
01457
01461 template<typename T>
01462 explicit SbVec3d(const T& v)
01463 {
01464
01465 vec[0] = double(v[0]);
01466 vec[1] = double(v[1]);
01467 vec[2] = double(v[2]);
01468 }
01469
01470 private:
01471 double vec[3];
01472
01473 };
01474
01475
01476
01477 inline SbVec3f &SbVec3f::setValue(const SbVec3d &vec3d)
01478 {
01479 vec[0] = static_cast<float>(vec3d[0]);
01480 vec[1] = static_cast<float>(vec3d[1]);
01481 vec[2] = static_cast<float>(vec3d[2]);
01482 return (*this);
01483 }
01484
01486
01487
01488
01489
01490
01491
01493
01523 class SbVec3i32 {
01524 public:
01528 SbVec3i32() { }
01532 SbVec3i32(const int32_t v[3]) { setValue(v); }
01536 SbVec3i32(int32_t x, int32_t y, int32_t z) { setValue(x, y, z); }
01540 SbVec3i32( const SbVec3s &vec );
01544 inline int32_t dot(const SbVec3i32 &v) const
01545 {
01546 return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2];
01547 }
01548
01552 const int32_t *getValue() const { return vec; }
01556 void getValue(int32_t &x, int32_t &y, int32_t &z) const;
01560 void negate();
01564 inline SbVec3i32 &setValue(const int32_t v[3])
01565 {
01566 vec[0] = v[0];
01567 vec[1] = v[1];
01568 vec[2] = v[2];
01569
01570 return (*this);
01571 }
01572
01576 inline SbVec3i32 &setValue(int32_t x, int32_t y, int32_t z)
01577 {
01578 vec[0] = x;
01579 vec[1] = y;
01580 vec[2] = z;
01581
01582 return (*this);
01583 }
01584
01588 SbVec3i32 &setValue(const SbVec3s &v);
01592 SbVec3i32 operator = (const SbVec3s &v);
01596 int32_t & operator [](int i) { return (vec[i]); }
01600 const int32_t & operator [](int i) const { return (vec[i]); }
01604 SbVec3i32 & operator *=(int d);
01608 SbVec3i32 & operator *=(double d);
01609
01613 SbVec3i32 & operator /=(int d);
01617 SbVec3i32 & operator /=(double d)
01618 { return *this *= (1.0 / d); }
01622 inline SbVec3i32 & operator +=(const SbVec3i32 &u)
01623 {
01624 vec[0] += u.vec[0];
01625 vec[1] += u.vec[1];
01626 vec[2] += u.vec[2];
01627
01628 return *this;
01629 }
01633 inline SbVec3i32 & operator /=(const SbVec3i32 &u)
01634 {
01635 vec[0] /= u.vec[0];
01636 vec[1] /= u.vec[1];
01637 vec[2] /= u.vec[2];
01638
01639 return *this;
01640 }
01644 SbVec3i32 & operator -=(const SbVec3i32 &u);
01648 SbVec3i32 operator -() const;
01652 inline SbVec3i32 operator *(int d) const
01653 {
01654 return SbVec3i32(vec[0] * d, vec[1] * d, vec[2] * d);
01655 }
01656
01660 inline SbVec3i32 operator *(const SbVec3i32 &v) const
01661 {
01662 return SbVec3i32(vec[0]*v.vec[0],
01663 vec[1]*v.vec[1],
01664 vec[2]*v.vec[2]);
01665 }
01666
01670 inline SbVec3i32& operator *=(const SbVec3i32 &v)
01671 {
01672 *this = (*this)*v;
01673 return *this;
01674 }
01675
01679 friend SbVec3i32 operator *(const SbVec3i32 &v, double d);
01683 friend SbVec3i32 operator *(int d, const SbVec3i32 &v)
01684 { return v * d; }
01688 friend SbVec3i32 operator *(double d, const SbVec3i32 &v)
01689 { return v * d; }
01693 friend SbVec3i32 operator /(const SbVec3i32 &v, int d);
01697 friend SbVec3i32 operator /(const SbVec3i32 &v, double d)
01698 { return v * (1.0 / d); }
01702 inline SbVec3i32 operator +(const SbVec3i32 &v) const
01703 {
01704 return SbVec3i32(vec[0] + v.vec[0],
01705 vec[1] + v.vec[1],
01706 vec[2] + v.vec[2]);
01707 }
01708
01713 friend SbVec3i32 operator -(const SbVec3i32 &v1, const SbVec3i32 &v2)
01714 {
01715 return SbVec3i32(v1.vec[0] - v2.vec[0],
01716 v1.vec[1] - v2.vec[1],
01717 v1.vec[2] - v2.vec[2]);
01718 }
01719
01723 friend int operator ==(const SbVec3i32 &v1, const SbVec3i32 &v2);
01727 friend int operator !=(const SbVec3i32 &v1, const SbVec3i32 &v2)
01728 { return !(v1 == v2); }
01729
01733 friend inline std::ostream& operator << (std::ostream& os, const SbVec3i32& v);
01734
01738 template<typename T>
01739 explicit SbVec3i32(const T& v)
01740 {
01741
01742 vec[0] = int32_t(v[0]);
01743 vec[1] = int32_t(v[1]);
01744 vec[2] = int32_t(v[2]);
01745 }
01746
01750 inline int32_t getMaxComponent() const;
01751
01752 private:
01753 int32_t vec[3];
01754 };
01755
01756 int32_t
01757 SbVec3i32::getMaxComponent() const
01758 {
01759 return SbMathHelper::Max(SbMathHelper::Max(vec[0], vec[1]), vec[2]);
01760 }
01761
01763
01764
01765
01766
01767
01768
01770
01771
01772
01804 class SbVec3s {
01805 public:
01806
01810 SbVec3s() { }
01811
01815 SbVec3s(const short v[3]) { setValue(v); }
01816
01820 SbVec3s(short x, short y, short z) { setValue(x, y, z); }
01821
01826 #ifndef OIV_DO_NOT_ALLOW_I32_TO_I16_AUTO_CAST
01827 SbVec3s(const SbVec3i32 &v);
01828 #endif
01829
01833 inline int32_t dot(const SbVec3s &v) const
01834 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2]; }
01835
01839 const short *getValue() const { return vec; }
01840
01844 void getValue(short &x, short &y, short &z) const;
01845
01849 void negate();
01850
01854 SbVec3s &setValue(const short v[3]);
01855
01859 SbVec3s &setValue(short x, short y, short z);
01860
01862
01865 short & operator [](int i) { return (vec[i]); }
01866 const short & operator [](int i) const { return (vec[i]); }
01868
01872 SbVec3s & operator *=(int d);
01876 SbVec3s & operator *=(double d);
01877
01881 SbVec3s & operator /=(int d);
01885 SbVec3s & operator /=(double d)
01886 { return *this *= (1.0 / d); }
01887
01891 SbVec3s & operator +=(const SbVec3s &u);
01895 SbVec3s & operator -=(const SbVec3s &u);
01896
01900 SbVec3s operator -() const;
01901
01906 #ifndef OIV_DO_NOT_ALLOW_I32_TO_I16_AUTO_CAST
01907 SbVec3s operator = (const SbVec3i32 &v);
01908 #endif
01909
01913 friend SbVec3s operator *(const SbVec3s &v, int d);
01917 friend SbVec3s operator *(const SbVec3s &v, double d);
01921 friend SbVec3s operator *(int d, const SbVec3s &v)
01922 { return v * d; }
01926 friend SbVec3s operator *(double d, const SbVec3s &v)
01927 { return v * d; }
01931 friend SbVec3s operator /(const SbVec3s &v, int d);
01935 friend SbVec3s operator /(const SbVec3s &v, double d)
01936 { return v * (1.0 / d); }
01937
01941 friend SbVec3s operator +(const SbVec3s &v1, const SbVec3s &v2);
01942
01946 friend SbVec3s operator -(const SbVec3s &v1, const SbVec3s &v2);
01947
01951 friend int operator ==(const SbVec3s &v1, const SbVec3s &v2);
01955 friend int operator !=(const SbVec3s &v1, const SbVec3s &v2)
01956 { return !(v1 == v2); }
01957
01961 friend inline std::ostream& operator << (std::ostream& os, const SbVec3s& v);
01962
01966 template<typename T>
01967 explicit SbVec3s(const T& v)
01968 {
01969
01970 vec[0] = short(v[0]);
01971 vec[1] = short(v[1]);
01972 vec[2] = short(v[2]);
01973 }
01974
01975
01976 private:
01977 short vec[3];
01978
01979 };
01980
01982
01983
01984
01985
01986
01988
01989
01990
02022 class SbVec4b {
02023 public:
02024
02028 SbVec4b() { }
02029
02033 SbVec4b(const char v[4]) { setValue(v); }
02034
02038 SbVec4b(char x, char y, char z, char w) { setValue(x, y, z, w); }
02039
02043 inline int32_t dot(const SbVec4b &v) const
02044 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
02045
02050 const char *getValue() const { return vec; }
02051
02055 void getValue(char &x, char &y, char &z, char &w) const;
02056
02060 void negate();
02061
02065 SbVec4b &setValue(const char v[4]);
02066
02070 SbVec4b &setValue(char x, char y, char z, char w);
02071
02073
02076 char & operator [](int i) { return (vec[i]); }
02077 const char & operator [](int i) const { return (vec[i]); }
02079
02083 SbVec4b & operator *=(int d);
02087 SbVec4b & operator *=(double d);
02088
02092 SbVec4b & operator /=(int d);
02096 SbVec4b & operator /=(double d)
02097 { return *this *= (1.0 / d); }
02098
02102 SbVec4b & operator +=(const SbVec4b &u);
02106 SbVec4b & operator -=(const SbVec4b &u);
02107
02111 SbVec4b operator -() const;
02112
02116 friend SbVec4b operator *(const SbVec4b &v, int d);
02120 friend SbVec4b operator *(const SbVec4b &v, double d);
02124 friend SbVec4b operator *(int d, const SbVec4b &v)
02125 { return v * d; }
02129 friend SbVec4b operator *(double d, const SbVec4b &v)
02130 { return v * d; }
02134 friend SbVec4b operator /(const SbVec4b &v, int d);
02138 friend SbVec4b operator /(const SbVec4b &v, double d)
02139 { return v * (1.0 / d); }
02140
02144 friend SbVec4b operator +(const SbVec4b &v1, const SbVec4b &v2);
02145
02149 friend SbVec4b operator -(const SbVec4b &v1, const SbVec4b &v2);
02150
02154 friend int operator ==(const SbVec4b &v1, const SbVec4b &v2);
02158 friend int operator !=(const SbVec4b &v1, const SbVec4b &v2)
02159 { return !(v1 == v2); }
02160
02164 friend inline std::ostream& operator << (std::ostream& os, const SbVec4b& v);
02165
02169 template<typename T>
02170 explicit SbVec4b(const T& v)
02171 {
02172
02173 vec[0] = char(v[0]);
02174 vec[1] = char(v[1]);
02175 vec[2] = char(v[2]);
02176 vec[3] = char(v[3]);
02177 }
02178 private:
02179 char vec[4];
02180
02181 };
02182
02184
02185
02186
02187
02188
02189
02191
02223 class SbVec4f {
02224 public:
02225
02229 SbVec4f() { }
02230
02234 SbVec4f(const float v[4]) { setValue(v); }
02235
02239 SbVec4f(float x, float y, float z, float w) { setValue(x, y, z, w); }
02240
02244 inline float dot(const SbVec4f &v) const
02245 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3] ; }
02246
02250 void getReal(SbVec3f &v) const;
02251
02255 const float *getValue() const { return vec; }
02256
02260 void getValue(float &x, float &y, float &z, float &w) const;
02261
02265 float length() const;
02266
02271 inline float lengthSquared() const
02272 { return vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] + vec[3] * vec[3]; }
02273
02277 void negate();
02278
02282 float normalize();
02283
02287 SbVec4f &setValue(const float v[4]);
02288
02292 SbVec4f &setValue(float x, float y, float z, float w);
02293
02297 SbVec4f &setValue(const SbVec4d &vec4d);
02298
02300
02303 float & operator [](int i) { return (vec[i]); }
02304 const float & operator [](int i) const { return (vec[i]); }
02306
02310 SbVec4f & operator *=(float d);
02311
02315 SbVec4f & operator /=(float d);
02316
02320 SbVec4f & operator +=(const SbVec4f &u);
02324 SbVec4f & operator -=(const SbVec4f &u);
02325
02329 SbVec4f operator -() const;
02330
02334 friend SbVec4f operator *(const SbVec4f &v, float d);
02338 friend SbVec4f operator *(float d, const SbVec4f &v)
02339 { return v * d; }
02343 friend SbVec4f operator /(const SbVec4f &v, float d);
02344
02348 friend SbVec4f operator +(const SbVec4f &v1, const SbVec4f &v2);
02349
02353 friend SbVec4f operator -(const SbVec4f &v1, const SbVec4f &v2);
02354
02358 friend int operator ==(const SbVec4f &v1, const SbVec4f &v2);
02362 friend int operator !=(const SbVec4f &v1, const SbVec4f &v2)
02363 { return !(v1 == v2); }
02364
02368 friend inline std::ostream& operator << (std::ostream& os, const SbVec4f& v);
02369
02374 SbBool equals(const SbVec4f& v, float tolerance) const;
02375
02379 template<typename T>
02380 explicit SbVec4f(const T& v)
02381 {
02382
02383 vec[0] = float(v[0]);
02384 vec[1] = float(v[1]);
02385 vec[2] = float(v[2]);
02386 vec[3] = float(v[3]);
02387 }
02388
02389 private:
02390 float vec[4];
02391
02392 };
02393
02395
02396
02397
02398
02399
02400
02402
02437 class SbVec4d {
02438 public:
02439
02443 SbVec4d() { }
02444
02448 SbVec4d(const double v[4]) { setValue(v); }
02449
02453 SbVec4d(double x, double y, double z, double w) { setValue(x, y, z, w); }
02454
02458 inline double dot(const SbVec4d &v) const
02459 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3] ; }
02460
02464 void getReal(SbVec3d &v) const;
02465
02469 const double *getValue() const { return vec; }
02470
02474 void getValue(double &x, double &y, double &z, double &w) const;
02475
02479 double length() const;
02480
02485 inline double lengthSquared() const
02486 { return vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] + vec[3] * vec[3]; }
02487
02491 void negate();
02492
02496 double normalize();
02497
02501 SbVec4d &setValue(const double v[4]);
02502
02506 SbVec4d &setValue(double x, double y, double z, double w);
02507
02511 SbVec4d &setValue(const SbVec4f &vec4f)
02512 { vec[0] = vec4f[0] ; vec[1] = vec4f[1] ; vec[2] = vec4f[2] ;
02513 vec[3] = vec4f[3] ; return (*this) ;}
02514
02516
02519 double & operator [](int i) { return (vec[i]); }
02520 const double & operator [](int i) const { return (vec[i]); }
02522
02526 SbVec4d & operator *=(double d);
02527
02531 SbVec4d & operator /=(double d);
02532
02536 SbVec4d & operator +=(const SbVec4d &u);
02540 SbVec4d & operator -=(const SbVec4d &u);
02541
02545 SbVec4d operator -() const;
02546
02550 friend SbVec4d operator *(const SbVec4d &v, double d);
02554 friend SbVec4d operator *(double d, const SbVec4d &v)
02555 { return v * d; }
02559 friend SbVec4d operator /(const SbVec4d &v, double d);
02560
02564 friend SbVec4d operator +(const SbVec4d &v1, const SbVec4d &v2);
02565
02569 friend SbVec4d operator -(const SbVec4d &v1, const SbVec4d &v2);
02570
02574 friend int operator ==(const SbVec4d &v1, const SbVec4d &v2);
02578 friend int operator !=(const SbVec4d &v1, const SbVec4d &v2)
02579 { return !(v1 == v2); }
02580
02584 friend inline std::ostream& operator << (std::ostream& os, const SbVec4d& v);
02585
02590 SbBool equals(const SbVec4d& v, double tolerance) const;
02591
02595 template<typename T>
02596 explicit SbVec4d(const T& v)
02597 {
02598
02599 vec[0] = double(v[0]);
02600 vec[1] = double(v[1]);
02601 vec[2] = double(v[2]);
02602 vec[3] = double(v[3]);
02603 }
02604
02605
02606 private:
02607 double vec[4];
02608
02609 };
02610
02612
02613
02614
02615
02616
02617
02619
02649 class SbVec4i32 {
02650 public:
02654 SbVec4i32() { }
02658 SbVec4i32(const int32_t v[4]) { setValue(v); }
02662 SbVec4i32(int32_t x, int32_t y, int32_t z, int32_t w) { setValue(x, y, z, w); }
02666 inline int32_t dot(const SbVec4i32 &v) const
02667 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
02671 const int32_t *getValue() const { return vec; }
02675 void getValue(int32_t &x, int32_t &y, int32_t &z, int32_t &w) const;
02679 void negate();
02683 SbVec4i32 &setValue(const int32_t v[4]);
02687 SbVec4i32 &setValue(int32_t x, int32_t y, int32_t z, int32_t w);
02691 int32_t & operator [](int i) { return (vec[i]); }
02695 const int32_t & operator [](int i) const { return (vec[i]); }
02699 SbVec4i32 & operator *=(int d);
02703 SbVec4i32 & operator *=(double d);
02704
02708 SbVec4i32 & operator /=(int d);
02712 SbVec4i32 & operator /=(double d)
02713 { return *this *= (1.0 / d); }
02717 SbVec4i32 & operator +=(const SbVec4i32 &u);
02721 SbVec4i32 & operator -=(const SbVec4i32 &u);
02725 SbVec4i32 operator -() const;
02729 friend SbVec4i32 operator *(const SbVec4i32 &v, int d);
02733 friend SbVec4i32 operator *(const SbVec4i32 &v, double d);
02737 friend SbVec4i32 operator *(int d, const SbVec4i32 &v)
02738 { return v * d; }
02742 friend SbVec4i32 operator *(double d, const SbVec4i32 &v)
02743 { return v * d; }
02747 friend SbVec4i32 operator /(const SbVec4i32 &v, int d);
02751 friend SbVec4i32 operator /(const SbVec4i32 &v, double d)
02752 { return v * (1.0 / d); }
02756 friend SbVec4i32 operator +(const SbVec4i32 &v1, const SbVec4i32 &v2);
02761 friend SbVec4i32 operator -(const SbVec4i32 &v1, const SbVec4i32 &v2);
02765 friend int operator ==(const SbVec4i32 &v1, const SbVec4i32 &v2);
02769 friend int operator !=(const SbVec4i32 &v1, const SbVec4i32 &v2)
02770 { return !(v1 == v2); }
02771
02775 friend inline std::ostream& operator << (std::ostream& os, const SbVec4i32& v);
02776
02780 template<typename T>
02781 explicit SbVec4i32(const T& v)
02782 {
02783
02784 vec[0] = int32_t(v[0]);
02785 vec[1] = int32_t(v[1]);
02786 vec[2] = int32_t(v[2]);
02787 vec[3] = int32_t(v[3]);
02788 }
02789
02790 private:
02791 int32_t vec[4];
02792 };
02793
02795
02796
02797
02798
02799
02801
02802
02803
02835 class SbVec4s {
02836 public:
02837
02841 SbVec4s() { }
02842
02846 SbVec4s(const short v[4]) { setValue(v); }
02847
02851 SbVec4s(short x, short y, short z, short w) { setValue(x, y, z, w); }
02852
02856 inline int32_t dot(const SbVec4s &v) const
02857 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
02858
02862 const short *getValue() const { return vec; }
02863
02867 void getValue(short &x, short &y, short &z, short &w) const;
02868
02872 void negate();
02873
02877 SbVec4s &setValue(const short v[4]);
02878
02882 SbVec4s &setValue(short x, short y, short z, short w);
02883
02885
02888 short & operator [](int i) { return (vec[i]); }
02889 const short & operator [](int i) const { return (vec[i]); }
02891
02895 SbVec4s & operator *=(int d);
02899 SbVec4s & operator *=(double d);
02900
02904 SbVec4s & operator /=(int d);
02908 SbVec4s & operator /=(double d)
02909 { return *this *= (1.0 / d); }
02910
02914 SbVec4s & operator +=(const SbVec4s &u);
02918 SbVec4s & operator -=(const SbVec4s &u);
02919
02923 SbVec4s operator -() const;
02924
02928 friend SbVec4s operator *(const SbVec4s &v, int d);
02932 friend SbVec4s operator *(const SbVec4s &v, double d);
02936 friend SbVec4s operator *(int d, const SbVec4s &v)
02937 { return v * d; }
02941 friend SbVec4s operator *(double d, const SbVec4s &v)
02942 { return v * d; }
02946 friend SbVec4s operator /(const SbVec4s &v, int d);
02950 friend SbVec4s operator /(const SbVec4s &v, double d)
02951 { return v * (1.0 / d); }
02952
02956 friend SbVec4s operator +(const SbVec4s &v1, const SbVec4s &v2);
02957
02961 friend SbVec4s operator -(const SbVec4s &v1, const SbVec4s &v2);
02962
02966 friend int operator ==(const SbVec4s &v1, const SbVec4s &v2);
02970 friend int operator !=(const SbVec4s &v1, const SbVec4s &v2)
02971 { return !(v1 == v2); }
02972
02976 friend inline std::ostream& operator << (std::ostream& os, const SbVec4s& v);
02977
02981 template<typename T>
02982 explicit SbVec4s(const T& v)
02983 {
02984
02985 vec[0] = short(v[0]);
02986 vec[1] = short(v[1]);
02987 vec[2] = short(v[2]);
02988 vec[3] = short(v[3]);
02989 }
02990
02991
02992
02993 private:
02994 short vec[4];
02995
02996 };
02997
02999
03000
03001
03002
03003
03005
03006
03007
03039 class SbVec4ui32 {
03040 public:
03041
03045 SbVec4ui32() { }
03046
03050 SbVec4ui32(const uint32_t v[4]) { setValue(v); }
03051
03055 SbVec4ui32(uint32_t x, uint32_t y, uint32_t z, uint32_t w)
03056 { setValue(x, y, z, w); }
03057
03061 inline int32_t dot(const SbVec4ui32 &v) const
03062 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
03063
03067 const uint32_t *getValue() const { return vec; }
03068
03072 void getValue(uint32_t &x, uint32_t &y,
03073 uint32_t &z, uint32_t &w) const;
03074
03078 SbVec4ui32 &setValue(const uint32_t v[4]);
03079
03083 SbVec4ui32 &setValue(uint32_t x, uint32_t y,
03084 uint32_t z, uint32_t w);
03085
03087
03090 uint32_t & operator [](int i) { return (vec[i]); }
03091 const uint32_t & operator [](int i) const { return (vec[i]); }
03093
03097 SbVec4ui32 & operator *=(int d);
03101 SbVec4ui32 & operator *=(double d);
03102
03106 SbVec4ui32 & operator /=(int d);
03110 SbVec4ui32 & operator /=(double d)
03111 { return *this *= (1.0 / d); }
03112
03116 SbVec4ui32 & operator +=(const SbVec4ui32 &u);
03120 SbVec4ui32 & operator -=(const SbVec4ui32 &u);
03124 friend SbVec4ui32 operator *(const SbVec4ui32 &v, int d);
03128 friend SbVec4ui32 operator *(const SbVec4ui32 &v, double d);
03132 friend SbVec4ui32 operator *(int d, const SbVec4ui32 &v)
03133 { return v * d; }
03137 friend SbVec4ui32 operator *(double d, const SbVec4ui32 &v)
03138 { return v * d; }
03142 friend SbVec4ui32 operator /(const SbVec4ui32 &v, int d);
03146 friend SbVec4ui32 operator /(const SbVec4ui32 &v, double d)
03147 { return v * (1.0 / d); }
03148
03152 friend SbVec4ui32 operator +(const SbVec4ui32 &v1, const SbVec4ui32 &v2);
03153
03157 friend SbVec4ui32 operator -(const SbVec4ui32 &v1, const SbVec4ui32 &v2);
03158
03162 friend int operator ==(const SbVec4ui32 &v1, const SbVec4ui32 &v2);
03166 friend int operator !=(const SbVec4ui32 &v1, const SbVec4ui32 &v2)
03167 { return !(v1 == v2); }
03168
03172 friend inline std::ostream& operator << (std::ostream& os, const SbVec4ui32& v);
03173
03177 template<typename T>
03178 explicit SbVec4ui32(const T& v)
03179 {
03180
03181 vec[0] = uint32_t(v[0]);
03182 vec[1] = uint32_t(v[1]);
03183 vec[2] = uint32_t(v[2]);
03184 vec[3] = uint32_t(v[3]);
03185 }
03186 private:
03187 uint32_t vec[4];
03188
03189 };
03190
03192
03193
03194
03195
03196
03198
03199
03200
03232 class SbVec4us {
03233 public:
03234
03238 SbVec4us() { }
03239
03243 SbVec4us(const unsigned short v[4]) { setValue(v); }
03244
03248 SbVec4us(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
03249 { setValue(x, y, z, w); }
03250
03254 inline int32_t dot(const SbVec4us &v) const
03255 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
03256
03260 const unsigned short *getValue() const { return vec; }
03261
03265 void getValue(unsigned short &x, unsigned short &y, unsigned short &z, unsigned short &w) const;
03266
03270 void negate();
03271
03275 SbVec4us &setValue(const unsigned short v[4]);
03276
03280 SbVec4us &setValue(unsigned short x, unsigned short y, unsigned short z, unsigned short w);
03281
03283
03286 unsigned short & operator [](int i) { return (vec[i]); }
03287 const unsigned short & operator [](int i) const { return (vec[i]); }
03289
03293 SbVec4us & operator *=(int d);
03297 SbVec4us & operator *=(double d);
03298
03302 SbVec4us & operator /=(int d);
03306 SbVec4us & operator /=(double d)
03307 { return *this *= (1.0 / d); }
03308
03312 SbVec4us & operator +=(const SbVec4us &u);
03316 SbVec4us & operator -=(const SbVec4us &u);
03317
03321 SbVec4us operator -() const;
03322
03326 friend SbVec4us operator *(const SbVec4us &v, int d);
03330 friend SbVec4us operator *(const SbVec4us &v, double d);
03334 friend SbVec4us operator *(int d, const SbVec4us &v)
03335 { return v * d; }
03339 friend SbVec4us operator *(double d, const SbVec4us &v)
03340 { return v * d; }
03344 friend SbVec4us operator /(const SbVec4us &v, int d);
03348 friend SbVec4us operator /(const SbVec4us &v, double d)
03349 { return v * (1.0 / d); }
03350
03354 friend SbVec4us operator +(const SbVec4us &v1, const SbVec4us &v2);
03355
03359 friend SbVec4us operator -(const SbVec4us &v1, const SbVec4us &v2);
03360
03364 friend int operator ==(const SbVec4us &v1, const SbVec4us &v2);
03368 friend int operator !=(const SbVec4us &v1, const SbVec4us &v2)
03369 { return !(v1 == v2); }
03370
03374 friend inline std::ostream& operator << (std::ostream& os, const SbVec4us& v);
03375
03379 template<typename T>
03380 explicit SbVec4us(const T& v)
03381 {
03382
03383 vec[0] = static_cast<unsigned short>(v[0]);
03384 vec[1] = static_cast<unsigned short>(v[1]);
03385 vec[2] = static_cast<unsigned short>(v[2]);
03386 vec[3] = static_cast<unsigned short>(v[3]);
03387 }
03388 private:
03389 unsigned short vec[4];
03390
03391 };
03392
03393
03395
03396
03397
03398
03399
03401
03402
03403
03435 class SbVec4ub {
03436 public:
03437
03441 SbVec4ub() { }
03442
03446 SbVec4ub(const unsigned char v[4]) { setValue(v); }
03447
03451 SbVec4ub(unsigned char x, unsigned char y, unsigned char z, unsigned char w)
03452 { setValue(x, y, z, w); }
03453
03457 inline int32_t dot(const SbVec4ub &v) const
03458 { return vec[0] * v.vec[0] + vec[1] * v.vec[1] + vec[2] * v.vec[2] + vec[3] * v.vec[3]; }
03459
03463 const unsigned char *getValue() const { return vec; }
03464
03468 void getValue(unsigned char &x, unsigned char &y, unsigned char &z, unsigned char &w) const;
03469
03473 void negate();
03474
03478 SbVec4ub &setValue(const unsigned char v[4]);
03479
03483 SbVec4ub &setValue(unsigned char x, unsigned char y, unsigned char z, unsigned char w);
03484
03486
03489 unsigned char & operator [](int i) { return (vec[i]); }
03490 const unsigned char & operator [](int i) const { return (vec[i]); }
03492
03496 SbVec4ub & operator *=(int d);
03500 SbVec4ub & operator *=(double d);
03501
03505 SbVec4ub & operator /=(int d);
03509 SbVec4ub & operator /=(double d)
03510 { return *this *= (1.0 / d); }
03511
03515 SbVec4ub & operator +=(const SbVec4ub &u);
03519 SbVec4ub & operator -=(const SbVec4ub &u);
03520
03524 SbVec4ub operator -() const;
03525
03529 friend SbVec4ub operator *(const SbVec4ub &v, int d);
03533 friend SbVec4ub operator *(const SbVec4ub &v, double d);
03537 friend SbVec4ub operator *(int d, const SbVec4ub &v)
03538 { return v * d; }
03542 friend SbVec4ub operator *(double d, const SbVec4ub &v)
03543 { return v * d; }
03547 friend SbVec4ub operator /(const SbVec4ub &v, int d);
03551 friend SbVec4ub operator /(const SbVec4ub &v, double d)
03552 { return v * (1.0 / d); }
03553
03557 friend SbVec4ub operator +(const SbVec4ub &v1, const SbVec4ub &v2);
03558
03562 friend SbVec4ub operator -(const SbVec4ub &v1, const SbVec4ub &v2);
03563
03567 friend int operator ==(const SbVec4ub &v1, const SbVec4ub &v2);
03571 friend int operator !=(const SbVec4ub &v1, const SbVec4ub &v2)
03572 { return !(v1 == v2); }
03573
03577 friend inline std::ostream& operator << (std::ostream& os, const SbVec4ub& v);
03578
03582 template<typename T>
03583 explicit SbVec4ub(const T& v)
03584 {
03585
03586 vec[0] = static_cast<unsigned char>(v[0]);
03587 vec[1] = static_cast<unsigned char>(v[1]);
03588 vec[2] = static_cast<unsigned char>(v[2]);
03589 vec[3] = static_cast<unsigned char>(v[3]);
03590 }
03591
03595 inline void clamp(unsigned char a, unsigned char b)
03596 {
03597 vec[0] = SbMathHelper::Clamp(vec[0], a, b);
03598 vec[1] = SbMathHelper::Clamp(vec[1], a, b);
03599 vec[2] = SbMathHelper::Clamp(vec[2], a, b);
03600 vec[3] = SbMathHelper::Clamp(vec[3], a, b);
03601 }
03602 private:
03603 unsigned char vec[4];
03604
03605 };
03606
03610 inline std::ostream& operator << (std::ostream& os, const SbVec2s& v)
03611 {
03612 return os << "(" << v[0] << ", " << v[1] << ")";
03613 }
03614
03618 inline std::ostream& operator << (std::ostream& os, const SbVec2i32& v)
03619 {
03620 return os << "(" << v[0] << ", " << v[1] << ")";
03621 }
03622
03626 inline std::ostream& operator << (std::ostream& os, const SbVec2f& v)
03627 {
03628 return os << "(" << v[0] << ", " << v[1] << ")";
03629 }
03630
03634 inline std::ostream& operator << (std::ostream& os, const SbVec2d& v)
03635 {
03636 return os << "(" << v[0] << ", " << v[1] << ")";
03637 }
03638
03642 inline std::ostream& operator << (std::ostream& os, const SbVec3s& v)
03643 {
03644 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ")";
03645 }
03646
03650 inline std::ostream& operator << (std::ostream& os, const SbVec3i32& v)
03651 {
03652 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ")";
03653 }
03654
03658 inline std::ostream& operator << (std::ostream& os, const SbVec3d& v)
03659 {
03660 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ")";
03661 }
03662
03666 inline std::ostream& operator << (std::ostream& os, const SbVec3f& v)
03667 {
03668 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ")";
03669 }
03670
03671
03675 inline std::ostream& operator << (std::ostream& os, const SbVec4b& v)
03676 {
03677 return os << "(" << static_cast<int>(v[0]) << ", " << static_cast<int>(v[1]) << ", " << static_cast<int>(v[2]) << ", " << static_cast<int>(v[3]) << ")";
03678 }
03679
03683 inline std::ostream& operator << (std::ostream& os, const SbVec4d& v)
03684 {
03685 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
03686 }
03687
03691 inline std::ostream& operator << (std::ostream& os, const SbVec4f& v)
03692 {
03693 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
03694 }
03695
03699 inline std::ostream& operator << (std::ostream& os, const SbVec4i32& v)
03700 {
03701 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
03702 }
03703
03707 inline std::ostream& operator << (std::ostream& os, const SbVec4s& v)
03708 {
03709 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
03710 }
03711
03715 inline std::ostream& operator << (std::ostream& os, const SbVec4ub& v)
03716 {
03717 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]) << ")";
03718 }
03719
03723 inline std::ostream& operator << (std::ostream& os, const SbVec4ui32& v)
03724 {
03725 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
03726 }
03727
03731 inline std::ostream& operator << (std::ostream& os, const SbVec4us& v)
03732 {
03733 return os << "(" << v[0] << ", " << v[1] << ", " << v[2] << ", " << v[3] << ")";
03734 }
03735
03736
03737 #endif
03738
03739
03740