41 Vec4d() { _v[0]=0.0; _v[1]=0.0; _v[2]=0.0; _v[3]=0.0; }
43 Vec4d(value_type
x, value_type
y, value_type
z, value_type
w)
59 inline Vec4d(
const Vec4f& vec) { _v[0]=vec.
_v[0]; _v[1]=vec.
_v[1]; _v[2]=vec.
_v[2]; _v[3]=vec.
_v[3];}
61 inline operator Vec4f()
const {
return Vec4f(static_cast<float>(_v[0]),static_cast<float>(_v[1]),static_cast<float>(_v[2]),static_cast<float>(_v[3]));}
64 inline bool operator == (
const Vec4d& v)
const {
return _v[0]==v.
_v[0] && _v[1]==v.
_v[1] && _v[2]==v.
_v[2] && _v[3]==v.
_v[3]; }
66 inline bool operator != (
const Vec4d& v)
const {
return _v[0]!=v.
_v[0] || _v[1]!=v.
_v[1] || _v[2]!=v.
_v[2] || _v[3]!=v.
_v[3]; }
70 if (_v[0]<v.
_v[0])
return true;
71 else if (_v[0]>v.
_v[0])
return false;
72 else if (_v[1]<v.
_v[1])
return true;
73 else if (_v[1]>v.
_v[1])
return false;
74 else if (_v[2]<v.
_v[2])
return true;
75 else if (_v[2]>v.
_v[2])
return false;
76 else return (_v[3]<v.
_v[3]);
79 inline value_type*
ptr() {
return _v; }
80 inline const value_type*
ptr()
const {
return _v; }
82 inline void set( value_type
x, value_type
y, value_type
z, value_type
w)
84 _v[0]=
x; _v[1]=
y; _v[2]=
z; _v[3]=
w;
87 inline value_type&
operator [] (
unsigned int i) {
return _v[i]; }
88 inline value_type
operator [] (
unsigned int i)
const {
return _v[i]; }
90 inline value_type&
x() {
return _v[0]; }
91 inline value_type&
y() {
return _v[1]; }
92 inline value_type&
z() {
return _v[2]; }
93 inline value_type&
w() {
return _v[3]; }
95 inline value_type
x()
const {
return _v[0]; }
96 inline value_type
y()
const {
return _v[1]; }
97 inline value_type
z()
const {
return _v[2]; }
98 inline value_type
w()
const {
return _v[3]; }
100 inline value_type&
r() {
return _v[0]; }
101 inline value_type&
g() {
return _v[1]; }
102 inline value_type&
b() {
return _v[2]; }
103 inline value_type&
a() {
return _v[3]; }
105 inline value_type
r()
const {
return _v[0]; }
106 inline value_type
g()
const {
return _v[1]; }
107 inline value_type
b()
const {
return _v[2]; }
108 inline value_type
a()
const {
return _v[3]; }
113 return (
unsigned int)
clampTo((_v[0]*255.0),0.0,255.0)<<24 |
114 (
unsigned int)
clampTo((_v[1]*255.0),0.0,255.0)<<16 |
115 (
unsigned int)
clampTo((_v[2]*255.0),0.0,255.0)<<8 |
116 (
unsigned int)
clampTo((_v[3]*255.0),0.0,255.0);
121 return (
unsigned int)
clampTo((_v[3]*255.0),0.0,255.0)<<24 |
122 (
unsigned int)
clampTo((_v[2]*255.0),0.0,255.0)<<16 |
123 (
unsigned int)
clampTo((_v[1]*255.0),0.0,255.0)<<8 |
124 (
unsigned int)
clampTo((_v[0]*255.0),0.0,255.0);
135 return _v[0]*rhs.
_v[0]+
144 return Vec4d(_v[0]*rhs, _v[1]*rhs, _v[2]*rhs, _v[3]*rhs);
160 return Vec4d(_v[0]/rhs, _v[1]/rhs, _v[2]/rhs, _v[3]/rhs);
176 return Vec4d(_v[0]+rhs.
_v[0], _v[1]+rhs.
_v[1],
177 _v[2]+rhs.
_v[2], _v[3]+rhs.
_v[3]);
195 return Vec4d(_v[0]-rhs.
_v[0], _v[1]-rhs.
_v[1],
196 _v[2]-rhs.
_v[2], _v[3]-rhs.
_v[3] );
212 return Vec4d (-_v[0], -_v[1], -_v[2], -_v[3]);
218 return sqrt( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3]);
224 return _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] + _v[3]*_v[3];
235 value_type inv = 1.0/norm;
251 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+rhs[3];
257 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+rhs[3];
263 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+rhs[3];
270 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3];
276 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3];
282 return lhs[0]*rhs[0]+lhs[1]*rhs[1]+lhs[2]*rhs[2]+lhs[3];
288 return Vec4d(lhs[0]*rhs[0], lhs[1]*rhs[1], lhs[2]*rhs[2], lhs[3]*rhs[3]);
294 return Vec4d(lhs[0]/rhs[0], lhs[1]/rhs[1], lhs[2]/rhs[2], lhs[3]/rhs[3]);
Vec4d & operator-=(const Vec4d &rhs)
unsigned int asRGBA() const
bool operator==(const Vec4d &v) const
value_type length() const
unsigned int asABGR() const
value_type & operator[](unsigned int i)
Vec4d & operator*=(value_type rhs)
Vec2d componentDivide(const Vec2d &lhs, const Vec2d &rhs)
Vec4d(value_type x, value_type y, value_type z, value_type w)
Vec4d(const Vec3d &v3, value_type w)
Vec4d operator/(value_type rhs) const
const Vec4d operator-() const
value_type operator*(const Vec4d &rhs) const
Vec4d & operator/=(value_type rhs)
value_type length2() const
bool operator!=(const Vec4d &v) const
void set(value_type x, value_type y, value_type z, value_type w)
const value_type * ptr() const
T clampTo(T v, T minimum, T maximum)
Vec4d operator+(const Vec4d &rhs) const
Vec3f operator*(const Vec3f &v, const Matrixd &m)
Vec4d & operator+=(const Vec4d &rhs)
Vec2d componentMultiply(const Vec2d &lhs, const Vec2d &rhs)
bool operator<(const Vec4d &v) const