32 #ifndef Vector4_INCLUDE_ONCE 33 #define Vector4_INCLUDE_ONCE 43 template<
typename T_Scalar>
55 x() = (T_Scalar)other.x();
56 y() = (T_Scalar)other.y();
57 z() = (T_Scalar)other.z();
58 w() = (T_Scalar)other.w();
74 explicit Vector4(T_Scalar
x, T_Scalar
y, T_Scalar
z, T_Scalar
w)
141 return Vector4(
x()+other.
x(),
y()+other.
y(),
z()+other.
z(),
w()+other.
w());
145 return Vector4(
x()-other.
x(),
y()-other.
y(),
z()-other.
z(),
w()-other.
w());
149 return Vector4(
x()*other.
x(),
y()*other.
y(),
z()*other.
z(),
w()*other.
w());
153 return Vector4(
x()/other.
x(),
y()/other.
y(),
z()/other.
z(),
w()/other.
w());
157 return Vector4(
x()+val,
y()+val,
z()+val,
w()+val);
161 return Vector4(
x()-val,
y()-val,
z()-val,
w()-val);
165 return Vector4(
x()*val,
y()*val,
z()*val,
w()*val);
169 return Vector4(
x()/val,
y()/val,
z()/val,
w()/val);
177 *
this = *
this + other;
182 *
this = *
this - other;
187 *
this = *
this * other;
192 *
this = *
this / other;
225 x() =
y() =
z() =
w() = val;
230 return x() == other.
x() &&
y() == other.
y() &&
z() == other.
z() &&
w() == other.
w();
238 if (
x() != other.
x())
239 return x() < other.
x();
241 if (
y() != other.
y())
242 return y() < other.
y();
244 if (
z() != other.
z())
245 return z() < other.
z();
247 return w() < other.
w();
260 *
this *= (T_Scalar)(1.0/l);
291 #if VL_PIPELINE_PRECISION == 2 299 inline float dot(
const fvec4& v1,
const fvec4& v2) {
return v1.
x()*v2.
x() + v1.
y()*v2.
y() + v1.
z()*v2.
z() + v1.
w()*v2.
w(); }
300 inline double dot(
const dvec4& v1,
const dvec4& v2) {
return v1.
x()*v2.
x() + v1.
y()*v2.
y() + v1.
z()*v2.
z() + v1.
w()*v2.
w(); }
301 inline float dot(
const ivec4& v1,
const ivec4& v2) {
return (
float)(v1.
x()*v2.
x() + v1.
y()*v2.
y() + v1.
z()*v2.
z() + v1.
w()*v2.
w()); }
302 inline float dot(
const uvec4& v1,
const uvec4& v2) {
return (
float)(v1.
x()*v2.
x() + v1.
y()*v2.
y() + v1.
z()*v2.
z() + v1.
w()*v2.
w()); }
304 inline fvec4
min(
const fvec4&
a,
const fvec4&
b)
306 return fvec4( a.
x() < b.
x() ? a.
x() : b.
x(),
307 a.
y() < b.
y() ? a.
y() : b.
y(),
308 a.
z() < b.
z() ? a.
z() : b.
z(),
309 a.
w() < b.
w() ? a.
w() : b.
w() );
311 inline fvec4
min(
const fvec4&
a,
float b)
313 return fvec4( a.
x() < b ? a.
x() :
b,
314 a.
y() < b ? a.
y() :
b,
315 a.
z() < b ? a.
z() :
b,
316 a.
w() < b ? a.
w() :
b );
318 inline dvec4
min(
const dvec4&
a,
const dvec4&
b)
320 return dvec4( a.
x() < b.
x() ? a.
x() : b.
x(),
321 a.
y() < b.
y() ? a.
y() : b.
y(),
322 a.
z() < b.
z() ? a.
z() : b.
z(),
323 a.
w() < b.
w() ? a.
w() : b.
w() );
325 inline dvec4
min(
const dvec4&
a,
double b)
327 return dvec4( a.
x() < b ? a.
x() :
b,
328 a.
y() < b ? a.
y() :
b,
329 a.
z() < b ? a.
z() :
b,
330 a.
w() < b ? a.
w() :
b );
332 inline ivec4
min(
const ivec4&
a,
const ivec4&
b)
334 return ivec4( a.
x() < b.
x() ? a.
x() : b.
x(),
335 a.
y() < b.
y() ? a.
y() : b.
y(),
336 a.
z() < b.
z() ? a.
z() : b.
z(),
337 a.
w() < b.
w() ? a.
w() : b.
w() );
339 inline ivec4
min(
const ivec4&
a,
int b)
341 return ivec4( a.
x() < b ? a.
x() :
b,
342 a.
y() < b ? a.
y() :
b,
343 a.
z() < b ? a.
z() :
b,
344 a.
w() < b ? a.
w() :
b );
346 inline uvec4
min(
const uvec4&
a,
const uvec4&
b)
348 return uvec4( a.
x() < b.
x() ? a.
x() : b.
x(),
349 a.
y() < b.
y() ? a.
y() : b.
y(),
350 a.
z() < b.
z() ? a.
z() : b.
z(),
351 a.
w() < b.
w() ? a.
w() : b.
w() );
353 inline uvec4
min(
const uvec4&
a,
unsigned int b)
355 return uvec4( a.
x() < b ? a.
x() :
b,
356 a.
y() < b ? a.
y() :
b,
357 a.
z() < b ? a.
z() :
b,
358 a.
w() < b ? a.
w() :
b );
360 inline fvec4
max(
const fvec4&
a,
const fvec4&
b)
362 return fvec4( a.
x() > b.
x() ? a.
x() : b.
x(),
363 a.
y() > b.
y() ? a.
y() : b.
y(),
364 a.
z() > b.
z() ? a.
z() : b.
z(),
365 a.
w() > b.
w() ? a.
w() : b.
w() );
367 inline fvec4
max(
const fvec4&
a,
float b)
369 return fvec4( a.
x() > b ? a.
x() :
b,
370 a.
y() > b ? a.
y() :
b,
371 a.
z() > b ? a.
z() :
b,
372 a.
w() > b ? a.
w() :
b );
374 inline dvec4
max(
const dvec4&
a,
const dvec4&
b)
376 return dvec4( a.
x() > b.
x() ? a.
x() : b.
x(),
377 a.
y() > b.
y() ? a.
y() : b.
y(),
378 a.
z() > b.
z() ? a.
z() : b.
z(),
379 a.
w() > b.
w() ? a.
w() : b.
w() );
381 inline dvec4
max(
const dvec4&
a,
double b)
383 return dvec4( a.
x() > b ? a.
x() :
b,
384 a.
y() > b ? a.
y() :
b,
385 a.
z() > b ? a.
z() :
b,
386 a.
w() > b ? a.
w() :
b );
388 inline ivec4
max(
const ivec4&
a,
const ivec4&
b)
390 return ivec4( a.
x() > b.
x() ? a.
x() : b.
x(),
391 a.
y() > b.
y() ? a.
y() : b.
y(),
392 a.
z() > b.
z() ? a.
z() : b.
z(),
393 a.
w() > b.
w() ? a.
w() : b.
w() );
395 inline ivec4
max(
const ivec4&
a,
int b)
397 return ivec4( a.
x() > b ? a.
x() :
b,
398 a.
y() > b ? a.
y() :
b,
399 a.
z() > b ? a.
z() :
b,
400 a.
w() > b ? a.
w() :
b );
402 inline uvec4
max(
const uvec4&
a,
const uvec4&
b)
404 return uvec4( a.
x() > b.
x() ? a.
x() : b.
x(),
405 a.
y() > b.
y() ? a.
y() : b.
y(),
406 a.
z() > b.
z() ? a.
z() : b.
z(),
407 a.
w() > b.
w() ? a.
w() : b.
w() );
409 inline uvec4
max(
const uvec4&
a,
unsigned int b)
411 return uvec4( a.
x() > b ? a.
x() :
b,
412 a.
y() > b ? a.
y() :
b,
413 a.
z() > b ? a.
z() :
b,
414 a.
w() > b ? a.
w() :
b );
416 inline fvec4
clamp(
const fvec4&
x,
float minval,
float maxval) {
return min(
max(x,minval),maxval); }
417 inline fvec4
clamp(
const fvec4&
x,
const fvec4& minval,
const fvec4& maxval) {
return min(
max(x,minval),maxval); }
418 inline dvec4
clamp(
const dvec4&
x,
double minval,
double maxval) {
return min(
max(x,minval),maxval); }
419 inline dvec4
clamp(
const dvec4&
x,
const dvec4& minval,
const dvec4& maxval) {
return min(
max(x,minval),maxval); }
420 inline ivec4
clamp(
const ivec4&
x,
int minval,
int maxval) {
return min(
max(x,minval),maxval); }
421 inline ivec4
clamp(
const ivec4&
x,
const ivec4& minval,
const ivec4& maxval) {
return min(
max(x,minval),maxval); }
422 inline uvec4
clamp(
const uvec4&
x,
unsigned int minval,
unsigned int maxval) {
return min(
max(x,minval),maxval); }
423 inline uvec4
clamp(
const uvec4&
x,
const uvec4& minval,
const uvec4& maxval) {
return min(
max(x,minval),maxval); }
Vector4 & operator/=(T_Scalar val)
const T_Scalar & z() const
Vector4(T_Scalar x, T_Scalar y, T_Scalar z, T_Scalar w)
float clamp(float x, float minval, float maxval)
Vector2< T_Scalar > xy() const
T_Scalar & operator[](unsigned i)
const T_Scalar & x() const
Vector4< float > fvec4
A 4 components vector with float precision.
const T_Scalar & s() const
Vector4< unsigned char > ubvec4
A 4 components vector with unsigned char precision.
const T_Scalar & z() const
const T_Scalar & r() const
Vector4(const Vector4 &other)
Vector4 operator-(T_Scalar val) const
Vector4 operator-(const Vector4 &other) const
Vector3< T_Scalar > stp() const
Vector4 & operator/=(const Vector4 &other)
Vector3< T_Scalar > xyz() const
Vector4< unsigned int > uvec4
A 4 components vector with unsigned int precision.
The Vector4 class is a template class that implements a generic 4 components vector, see also vl::fvec4, vl::dvec4, vl::uvec4, vl::ivec4, vl::svec4, vl::usvec4, vl::bvec4, vl::ubvec4.
T_Scalar lengthSquared() const
Vector4 & operator+=(const Vector4 &other)
Visualization Library main namespace.
Vector4(const Vector3< T_Scalar > &v, T_Scalar w)
float dot(float a, float b)
Vector4 operator*(T_Scalar val) const
Vector4(const Vector2< T_Scalar > &u, const Vector2< T_Scalar > &v)
static const int scalar_count
Vector4 & operator-=(T_Scalar val)
Vector2< T_Scalar > st() const
const T_Scalar & p() const
const T_Scalar & g() const
const T_Scalar * ptr() const
Vector4 & operator-=(const Vector4 &other)
The Vector3 class is a template class that implements a generic 3 components vector, see also vl::fvec3, vl::dvec3, vl::uvec3, vl::ivec3, vl::svec3, vl::usvec3, vl::bvec3, vl::ubvec3.
Vector4 operator/(const Vector4 &other) const
Vector4< int > ivec4
A 4 components vector with int precision.
const T_Scalar & operator[](unsigned i) const
float max(float a, float b)
Vector4 & operator*=(T_Scalar val)
float min(float a, float b)
bool operator==(const Vector4 &other) const
Vector4< short > svec4
A 4 components vector with short precision.
Vector2< T_Scalar > rg() const
bool operator!=(const Vector4 &other) const
const T_Scalar & y() const
const T_Scalar & y() const
Vector4< double > dvec4
A 4 components vector with double precision.
Vector4 operator+(const Vector4 &other) const
const T_Scalar & b() const
Vector4 operator-() const
Vector4 & operator*=(const Vector4 &other)
Vector4 & operator=(const Vector4 &other)
The Vector2 class is a template class that implements a generic 2 components vector, see also vl::fvec2, vl::dvec2, vl::uvec2, vl::ivec2, vl::svec2, vl::usvec2, vl::bvec2, vl::ubvec2.
bool operator<(const Vector4 &other) const
Vector4< char > bvec4
A 4 components vector with char precision.
Vector4 operator+(T_Scalar val) const
const Vector4 & normalize(T_Scalar *len=NULL)
Vector4 operator/(T_Scalar val) const
const T_Scalar & t() const
Vector4< unsigned short > usvec4
A 4 components vector with unsigned short precision.
Vector4 & operator+=(T_Scalar val)
const T_Scalar & x() const
Vector4 operator*(const Vector4 &other) const
Vector4 & operator=(T_Scalar val)
const T_Scalar & x() const
Vector3< T_Scalar > rgb() const
fvec4 vec4
Defined as: 'typedef fvec4 vec4'. See also VL_PIPELINE_PRECISION.
const T_Scalar & y() const
const T_Scalar & q() const
T_Scalar mScalar[scalar_count]
const T_Scalar & w() const
const T_Scalar & a() const