32 #ifndef Vector4_INCLUDE_ONCE 33 #define Vector4_INCLUDE_ONCE 43 template<
typename T_Scalar>
56 x() = (T_Scalar)other.x();
57 y() = (T_Scalar)other.y();
58 z() = (T_Scalar)other.z();
59 w() = (T_Scalar)other.w();
62 explicit Vector4(
const scalar_ptr_type& pval)
75 explicit Vector4(T_Scalar
x, T_Scalar
y, T_Scalar
z, T_Scalar
w)
142 return Vector4(
x()+other.
x(),
y()+other.
y(),
z()+other.
z(),
w()+other.
w());
146 return Vector4(
x()-other.
x(),
y()-other.
y(),
z()-other.
z(),
w()-other.
w());
150 return Vector4(
x()*other.
x(),
y()*other.
y(),
z()*other.
z(),
w()*other.
w());
154 return Vector4(
x()/other.
x(),
y()/other.
y(),
z()/other.
z(),
w()/other.
w());
158 return Vector4(
x()+val,
y()+val,
z()+val,
w()+val);
162 return Vector4(
x()-val,
y()-val,
z()-val,
w()-val);
166 return Vector4(
x()*val,
y()*val,
z()*val,
w()*val);
170 return Vector4(
x()/val,
y()/val,
z()/val,
w()/val);
178 *
this = *
this + other;
183 *
this = *
this - other;
188 *
this = *
this * other;
193 *
this = *
this / other;
226 x() =
y() =
z() =
w() = val;
231 return x() == other.
x() &&
y() == other.
y() &&
z() == other.
z() &&
w() == other.
w();
239 if (
x() != other.
x())
240 return x() < other.
x();
242 if (
y() != other.
y())
243 return y() < other.
y();
245 if (
z() != other.
z())
246 return z() < other.
z();
248 return w() < other.
w();
261 *
this *= (T_Scalar)(1.0/l);
292 #if VL_PIPELINE_PRECISION == 2 300 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(); }
301 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(); }
302 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()); }
303 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()); }
305 inline fvec4
min(
const fvec4&
a,
const fvec4&
b)
307 return fvec4( a.
x() < b.
x() ? a.
x() : b.
x(),
308 a.
y() < b.
y() ? a.
y() : b.
y(),
309 a.
z() < b.
z() ? a.
z() : b.
z(),
310 a.
w() < b.
w() ? a.
w() : b.
w() );
312 inline fvec4
min(
const fvec4&
a,
float b)
314 return fvec4( a.
x() < b ? a.
x() :
b,
315 a.
y() < b ? a.
y() :
b,
316 a.
z() < b ? a.
z() :
b,
317 a.
w() < b ? a.
w() :
b );
319 inline dvec4
min(
const dvec4&
a,
const dvec4&
b)
321 return dvec4( a.
x() < b.
x() ? a.
x() : b.
x(),
322 a.
y() < b.
y() ? a.
y() : b.
y(),
323 a.
z() < b.
z() ? a.
z() : b.
z(),
324 a.
w() < b.
w() ? a.
w() : b.
w() );
326 inline dvec4
min(
const dvec4&
a,
double b)
328 return dvec4( a.
x() < b ? a.
x() :
b,
329 a.
y() < b ? a.
y() :
b,
330 a.
z() < b ? a.
z() :
b,
331 a.
w() < b ? a.
w() :
b );
333 inline ivec4
min(
const ivec4&
a,
const ivec4&
b)
335 return ivec4( a.
x() < b.
x() ? a.
x() : b.
x(),
336 a.
y() < b.
y() ? a.
y() : b.
y(),
337 a.
z() < b.
z() ? a.
z() : b.
z(),
338 a.
w() < b.
w() ? a.
w() : b.
w() );
340 inline ivec4
min(
const ivec4&
a,
int b)
342 return ivec4( a.
x() < b ? a.
x() :
b,
343 a.
y() < b ? a.
y() :
b,
344 a.
z() < b ? a.
z() :
b,
345 a.
w() < b ? a.
w() :
b );
347 inline uvec4
min(
const uvec4&
a,
const uvec4&
b)
349 return uvec4( a.
x() < b.
x() ? a.
x() : b.
x(),
350 a.
y() < b.
y() ? a.
y() : b.
y(),
351 a.
z() < b.
z() ? a.
z() : b.
z(),
352 a.
w() < b.
w() ? a.
w() : b.
w() );
354 inline uvec4
min(
const uvec4&
a,
unsigned int b)
356 return uvec4( a.
x() < b ? a.
x() :
b,
357 a.
y() < b ? a.
y() :
b,
358 a.
z() < b ? a.
z() :
b,
359 a.
w() < b ? a.
w() :
b );
361 inline fvec4
max(
const fvec4&
a,
const fvec4&
b)
363 return fvec4( a.
x() > b.
x() ? a.
x() : b.
x(),
364 a.
y() > b.
y() ? a.
y() : b.
y(),
365 a.
z() > b.
z() ? a.
z() : b.
z(),
366 a.
w() > b.
w() ? a.
w() : b.
w() );
368 inline fvec4
max(
const fvec4&
a,
float b)
370 return fvec4( a.
x() > b ? a.
x() :
b,
371 a.
y() > b ? a.
y() :
b,
372 a.
z() > b ? a.
z() :
b,
373 a.
w() > b ? a.
w() :
b );
375 inline dvec4
max(
const dvec4&
a,
const dvec4&
b)
377 return dvec4( a.
x() > b.
x() ? a.
x() : b.
x(),
378 a.
y() > b.
y() ? a.
y() : b.
y(),
379 a.
z() > b.
z() ? a.
z() : b.
z(),
380 a.
w() > b.
w() ? a.
w() : b.
w() );
382 inline dvec4
max(
const dvec4&
a,
double b)
384 return dvec4( a.
x() > b ? a.
x() :
b,
385 a.
y() > b ? a.
y() :
b,
386 a.
z() > b ? a.
z() :
b,
387 a.
w() > b ? a.
w() :
b );
389 inline ivec4
max(
const ivec4&
a,
const ivec4&
b)
391 return ivec4( a.
x() > b.
x() ? a.
x() : b.
x(),
392 a.
y() > b.
y() ? a.
y() : b.
y(),
393 a.
z() > b.
z() ? a.
z() : b.
z(),
394 a.
w() > b.
w() ? a.
w() : b.
w() );
396 inline ivec4
max(
const ivec4&
a,
int b)
398 return ivec4( a.
x() > b ? a.
x() :
b,
399 a.
y() > b ? a.
y() :
b,
400 a.
z() > b ? a.
z() :
b,
401 a.
w() > b ? a.
w() :
b );
403 inline uvec4
max(
const uvec4&
a,
const uvec4&
b)
405 return uvec4( a.
x() > b.
x() ? a.
x() : b.
x(),
406 a.
y() > b.
y() ? a.
y() : b.
y(),
407 a.
z() > b.
z() ? a.
z() : b.
z(),
408 a.
w() > b.
w() ? a.
w() : b.
w() );
410 inline uvec4
max(
const uvec4&
a,
unsigned int b)
412 return uvec4( a.
x() > b ? a.
x() :
b,
413 a.
y() > b ? a.
y() :
b,
414 a.
z() > b ? a.
z() :
b,
415 a.
w() > b ? a.
w() :
b );
417 inline fvec4
clamp(
const fvec4&
x,
float minval,
float maxval) {
return min(
max(x,minval),maxval); }
418 inline fvec4
clamp(
const fvec4&
x,
const fvec4& minval,
const fvec4& maxval) {
return min(
max(x,minval),maxval); }
419 inline dvec4
clamp(
const dvec4&
x,
double minval,
double maxval) {
return min(
max(x,minval),maxval); }
420 inline dvec4
clamp(
const dvec4&
x,
const dvec4& minval,
const dvec4& maxval) {
return min(
max(x,minval),maxval); }
421 inline ivec4
clamp(
const ivec4&
x,
int minval,
int maxval) {
return min(
max(x,minval),maxval); }
422 inline ivec4
clamp(
const ivec4&
x,
const ivec4& minval,
const ivec4& maxval) {
return min(
max(x,minval),maxval); }
423 inline uvec4
clamp(
const uvec4&
x,
unsigned int minval,
unsigned int maxval) {
return min(
max(x,minval),maxval); }
424 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
T_Scalar * scalar_ptr_type
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(const scalar_ptr_type &pval)
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