HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vec4.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 #ifndef OPENVDB_MATH_VEC4_HAS_BEEN_INCLUDED
5 #define OPENVDB_MATH_VEC4_HAS_BEEN_INCLUDED
6 
7 #include <openvdb/Exceptions.h>
8 #include "Math.h"
9 #include "Tuple.h"
10 #include "Vec3.h"
11 #include <algorithm>
12 #include <cmath>
13 #include <type_traits>
14 
15 
16 namespace openvdb {
18 namespace OPENVDB_VERSION_NAME {
19 namespace math {
20 
21 template<typename T> class Mat3;
22 
23 template<typename T>
24 class Vec4: public Tuple<4, T>
25 {
26 public:
27  using value_type = T;
28  using ValueType = T;
29 
30  /// Trivial constructor, the vector is NOT initialized
31  /// @note destructor, copy constructor, assignment operator and
32  /// move constructor are left to be defined by the compiler (default)
33  Vec4() = default;
34 
35  /// @brief Construct a vector all of whose components have the given value.
36  explicit Vec4(T val) { this->mm[0] = this->mm[1] = this->mm[2] = this->mm[3] = val; }
37 
38  /// Constructor with four arguments, e.g. Vec4f v(1,2,3,4);
39  Vec4(T x, T y, T z, T w)
40  {
41  this->mm[0] = x;
42  this->mm[1] = y;
43  this->mm[2] = z;
44  this->mm[3] = w;
45  }
46 
47  /// Constructor with array argument, e.g. float a[4]; Vec4f v(a);
48  template <typename Source>
49  Vec4(Source *a)
50  {
51  this->mm[0] = static_cast<T>(a[0]);
52  this->mm[1] = static_cast<T>(a[1]);
53  this->mm[2] = static_cast<T>(a[2]);
54  this->mm[3] = static_cast<T>(a[3]);
55  }
56 
57  /// Conversion constructor
58  template<typename Source>
59  explicit Vec4(const Tuple<4, Source> &v)
60  {
61  this->mm[0] = static_cast<T>(v[0]);
62  this->mm[1] = static_cast<T>(v[1]);
63  this->mm[2] = static_cast<T>(v[2]);
64  this->mm[3] = static_cast<T>(v[3]);
65  }
66 
67  /// @brief Construct a vector all of whose components have the given value,
68  /// which may be of an arithmetic type different from this vector's value type.
69  /// @details Type conversion warnings are suppressed.
70  template<typename Other>
71  explicit Vec4(Other val,
72  typename std::enable_if<std::is_arithmetic<Other>::value, Conversion>::type = Conversion{})
73  {
74  this->mm[0] = this->mm[1] = this->mm[2] = this->mm[3] = static_cast<T>(val);
75  }
76 
77  /// Reference to the component, e.g. v.x() = 4.5f;
78  T& x() { return this->mm[0]; }
79  T& y() { return this->mm[1]; }
80  T& z() { return this->mm[2]; }
81  T& w() { return this->mm[3]; }
82 
83  /// Get the component, e.g. float f = v.y();
84  T x() const { return this->mm[0]; }
85  T y() const { return this->mm[1]; }
86  T z() const { return this->mm[2]; }
87  T w() const { return this->mm[3]; }
88 
89  T* asPointer() { return this->mm; }
90  const T* asPointer() const { return this->mm; }
91 
92  /// Alternative indexed reference to the elements
93  T& operator()(int i) { return this->mm[i]; }
94 
95  /// Alternative indexed constant reference to the elements,
96  T operator()(int i) const { return this->mm[i]; }
97 
98  /// Returns a Vec3 with the first three elements of the Vec4.
99  Vec3<T> getVec3() const { return Vec3<T>(this->mm[0], this->mm[1], this->mm[2]); }
100 
101  /// "this" vector gets initialized to [x, y, z, w],
102  /// calling v.init(); has same effect as calling v = Vec4::zero();
103  const Vec4<T>& init(T x=0, T y=0, T z=0, T w=0)
104  {
105  this->mm[0] = x; this->mm[1] = y; this->mm[2] = z; this->mm[3] = w;
106  return *this;
107  }
108 
109  /// Set "this" vector to zero
110  const Vec4<T>& setZero()
111  {
112  this->mm[0] = 0; this->mm[1] = 0; this->mm[2] = 0; this->mm[3] = 0;
113  return *this;
114  }
115 
116  /// Assignment operator
117  template<typename Source>
119  {
120  // note: don't static_cast because that suppresses warnings
121  this->mm[0] = v[0];
122  this->mm[1] = v[1];
123  this->mm[2] = v[2];
124  this->mm[3] = v[3];
125 
126  return *this;
127  }
128 
129  /// Test if "this" vector is equivalent to vector v with tolerance
130  /// of eps
131  bool eq(const Vec4<T> &v, T eps = static_cast<T>(1.0e-8)) const
132  {
133  return isApproxEqual(this->mm[0], v.mm[0], eps) &&
134  isApproxEqual(this->mm[1], v.mm[1], eps) &&
135  isApproxEqual(this->mm[2], v.mm[2], eps) &&
136  isApproxEqual(this->mm[3], v.mm[3], eps);
137  }
138 
139  /// Negation operator, for e.g. v1 = -v2;
141  {
142  return Vec4<T>(
143  -this->mm[0],
144  -this->mm[1],
145  -this->mm[2],
146  -this->mm[3]);
147  }
148 
149  /// this = v1 + v2
150  /// "this", v1 and v2 need not be distinct objects, e.g. v.add(v1,v);
151  template <typename T0, typename T1>
152  const Vec4<T>& add(const Vec4<T0> &v1, const Vec4<T1> &v2)
153  {
154  this->mm[0] = v1[0] + v2[0];
155  this->mm[1] = v1[1] + v2[1];
156  this->mm[2] = v1[2] + v2[2];
157  this->mm[3] = v1[3] + v2[3];
158 
159  return *this;
160  }
161 
162 
163  /// this = v1 - v2
164  /// "this", v1 and v2 need not be distinct objects, e.g. v.sub(v1,v);
165  template <typename T0, typename T1>
166  const Vec4<T>& sub(const Vec4<T0> &v1, const Vec4<T1> &v2)
167  {
168  this->mm[0] = v1[0] - v2[0];
169  this->mm[1] = v1[1] - v2[1];
170  this->mm[2] = v1[2] - v2[2];
171  this->mm[3] = v1[3] - v2[3];
172 
173  return *this;
174  }
175 
176  /// this = scalar*v, v need not be a distinct object from "this",
177  /// e.g. v.scale(1.5,v1);
178  template <typename T0, typename T1>
179  const Vec4<T>& scale(T0 scale, const Vec4<T1> &v)
180  {
181  this->mm[0] = scale * v[0];
182  this->mm[1] = scale * v[1];
183  this->mm[2] = scale * v[2];
184  this->mm[3] = scale * v[3];
185 
186  return *this;
187  }
188 
189  template <typename T0, typename T1>
190  const Vec4<T> &div(T0 scalar, const Vec4<T1> &v)
191  {
192  this->mm[0] = v[0] / scalar;
193  this->mm[1] = v[1] / scalar;
194  this->mm[2] = v[2] / scalar;
195  this->mm[3] = v[3] / scalar;
196 
197  return *this;
198  }
199 
200  /// Dot product
201  T dot(const Vec4<T> &v) const
202  {
203  return (this->mm[0]*v.mm[0] + this->mm[1]*v.mm[1]
204  + this->mm[2]*v.mm[2] + this->mm[3]*v.mm[3]);
205  }
206 
207  /// Length of the vector
208  T length() const
209  {
210  return std::sqrt(
211  this->mm[0]*this->mm[0] +
212  this->mm[1]*this->mm[1] +
213  this->mm[2]*this->mm[2] +
214  this->mm[3]*this->mm[3]);
215  }
216 
217 
218  /// Squared length of the vector, much faster than length() as it
219  /// does not involve square root
220  T lengthSqr() const
221  {
222  return (this->mm[0]*this->mm[0] + this->mm[1]*this->mm[1]
223  + this->mm[2]*this->mm[2] + this->mm[3]*this->mm[3]);
224  }
225 
226  /// Return a reference to itself after the exponent has been
227  /// applied to all the vector components.
228  inline const Vec4<T>& exp()
229  {
230  this->mm[0] = std::exp(this->mm[0]);
231  this->mm[1] = std::exp(this->mm[1]);
232  this->mm[2] = std::exp(this->mm[2]);
233  this->mm[3] = std::exp(this->mm[3]);
234  return *this;
235  }
236 
237  /// Return a reference to itself after log has been
238  /// applied to all the vector components.
239  inline const Vec4<T>& log()
240  {
241  this->mm[0] = std::log(this->mm[0]);
242  this->mm[1] = std::log(this->mm[1]);
243  this->mm[2] = std::log(this->mm[2]);
244  this->mm[3] = std::log(this->mm[3]);
245  return *this;
246  }
247 
248  /// Return the sum of all the vector components.
249  inline T sum() const
250  {
251  return this->mm[0] + this->mm[1] + this->mm[2] + this->mm[3];
252  }
253 
254  /// Return the product of all the vector components.
255  inline T product() const
256  {
257  return this->mm[0] * this->mm[1] * this->mm[2] * this->mm[3];
258  }
259 
260  /// this = normalized this
261  bool normalize(T eps = static_cast<T>(1.0e-8))
262  {
263  T d = length();
264  if (isApproxEqual(d, T(0), eps)) {
265  return false;
266  }
267  *this *= (T(1) / d);
268  return true;
269  }
270 
271  /// return normalized this, throws if null vector
272  Vec4<T> unit(T eps=0) const
273  {
274  T d;
275  return unit(eps, d);
276  }
277 
278  /// return normalized this and length, throws if null vector
279  Vec4<T> unit(T eps, T& len) const
280  {
281  len = length();
282  if (isApproxEqual(len, T(0), eps)) {
283  throw ArithmeticError("Normalizing null 4-vector");
284  }
285  return *this / len;
286  }
287 
288  /// return normalized this, or (1, 0, 0, 0) if this is null vector
290  {
291  T l2 = lengthSqr();
292  return l2 ? *this / static_cast<T>(sqrt(l2)) : Vec4<T>(1, 0, 0, 0);
293  }
294 
295  /// Multiply each element of this vector by @a scalar.
296  template <typename S>
297  const Vec4<T> &operator*=(S scalar)
298  {
299  this->mm[0] *= scalar;
300  this->mm[1] *= scalar;
301  this->mm[2] *= scalar;
302  this->mm[3] *= scalar;
303  return *this;
304  }
305 
306  /// Multiply each element of this vector by the corresponding element of the given vector.
307  template <typename S>
308  const Vec4<T> &operator*=(const Vec4<S> &v1)
309  {
310  this->mm[0] *= v1[0];
311  this->mm[1] *= v1[1];
312  this->mm[2] *= v1[2];
313  this->mm[3] *= v1[3];
314 
315  return *this;
316  }
317 
318  /// Divide each element of this vector by @a scalar.
319  template <typename S>
320  const Vec4<T> &operator/=(S scalar)
321  {
322  this->mm[0] /= scalar;
323  this->mm[1] /= scalar;
324  this->mm[2] /= scalar;
325  this->mm[3] /= scalar;
326  return *this;
327  }
328 
329  /// Divide each element of this vector by the corresponding element of the given vector.
330  template <typename S>
331  const Vec4<T> &operator/=(const Vec4<S> &v1)
332  {
333  this->mm[0] /= v1[0];
334  this->mm[1] /= v1[1];
335  this->mm[2] /= v1[2];
336  this->mm[3] /= v1[3];
337  return *this;
338  }
339 
340  /// Add @a scalar to each element of this vector.
341  template <typename S>
342  const Vec4<T> &operator+=(S scalar)
343  {
344  this->mm[0] += scalar;
345  this->mm[1] += scalar;
346  this->mm[2] += scalar;
347  this->mm[3] += scalar;
348  return *this;
349  }
350 
351  /// Add each element of the given vector to the corresponding element of this vector.
352  template <typename S>
353  const Vec4<T> &operator+=(const Vec4<S> &v1)
354  {
355  this->mm[0] += v1[0];
356  this->mm[1] += v1[1];
357  this->mm[2] += v1[2];
358  this->mm[3] += v1[3];
359  return *this;
360  }
361 
362  /// Subtract @a scalar from each element of this vector.
363  template <typename S>
364  const Vec4<T> &operator-=(S scalar)
365  {
366  this->mm[0] -= scalar;
367  this->mm[1] -= scalar;
368  this->mm[2] -= scalar;
369  this->mm[3] -= scalar;
370  return *this;
371  }
372 
373  /// Subtract each element of the given vector from the corresponding element of this vector.
374  template <typename S>
375  const Vec4<T> &operator-=(const Vec4<S> &v1)
376  {
377  this->mm[0] -= v1[0];
378  this->mm[1] -= v1[1];
379  this->mm[2] -= v1[2];
380  this->mm[3] -= v1[3];
381  return *this;
382  }
383 
384  // Number of cols, rows, elements
385  static unsigned numRows() { return 1; }
386  static unsigned numColumns() { return 4; }
387  static unsigned numElements() { return 4; }
388 
389  /// Predefined constants, e.g. Vec4f v = Vec4f::xNegAxis();
390  static Vec4<T> zero() { return Vec4<T>(0, 0, 0, 0); }
391  static Vec4<T> origin() { return Vec4<T>(0, 0, 0, 1); }
392  static Vec4<T> ones() { return Vec4<T>(1, 1, 1, 1); }
393 };
394 
395 /// Equality operator, does exact floating point comparisons
396 template <typename T0, typename T1>
397 inline bool operator==(const Vec4<T0> &v0, const Vec4<T1> &v1)
398 {
399  return
400  isExactlyEqual(v0[0], v1[0]) &&
401  isExactlyEqual(v0[1], v1[1]) &&
402  isExactlyEqual(v0[2], v1[2]) &&
403  isExactlyEqual(v0[3], v1[3]);
404 }
405 
406 /// Inequality operator, does exact floating point comparisons
407 template <typename T0, typename T1>
408 inline bool operator!=(const Vec4<T0> &v0, const Vec4<T1> &v1) { return !(v0==v1); }
409 
410 /// Multiply each element of the given vector by @a scalar and return the result.
411 template <typename S, typename T>
413 { return v*scalar; }
414 
415 /// Multiply each element of the given vector by @a scalar and return the result.
416 template <typename S, typename T>
418 {
420  result *= scalar;
421  return result;
422 }
423 
424 /// Multiply corresponding elements of @a v0 and @a v1 and return the result.
425 template <typename T0, typename T1>
427 {
429  v0[1]*v1[1],
430  v0[2]*v1[2],
431  v0[3]*v1[3]);
432  return result;
433 }
434 
435 /// Divide @a scalar by each element of the given vector and return the result.
436 template <typename S, typename T>
438 {
439  return Vec4<typename promote<S, T>::type>(scalar/v[0],
440  scalar/v[1],
441  scalar/v[2],
442  scalar/v[3]);
443 }
444 
445 /// Divide each element of the given vector by @a scalar and return the result.
446 template <typename S, typename T>
448 {
450  result /= scalar;
451  return result;
452 }
453 
454 /// Divide corresponding elements of @a v0 and @a v1 and return the result.
455 template <typename T0, typename T1>
457 {
459  result(v0[0]/v1[0], v0[1]/v1[1], v0[2]/v1[2], v0[3]/v1[3]);
460  return result;
461 }
462 
463 /// Add corresponding elements of @a v0 and @a v1 and return the result.
464 template <typename T0, typename T1>
466 {
468  result += v1;
469  return result;
470 }
471 
472 /// Add @a scalar to each element of the given vector and return the result.
473 template <typename S, typename T>
475 {
477  result += scalar;
478  return result;
479 }
480 
481 /// Subtract corresponding elements of @a v0 and @a v1 and return the result.
482 template <typename T0, typename T1>
484 {
486  result -= v1;
487  return result;
488 }
489 
490 /// Subtract @a scalar from each element of the given vector and return the result.
491 template <typename S, typename T>
493 {
495  result -= scalar;
496  return result;
497 }
498 
499 template <typename T>
500 inline bool
501 isApproxEqual(const Vec4<T>& a, const Vec4<T>& b)
502 {
503  return a.eq(b);
504 }
505 template <typename T>
506 inline bool
507 isApproxEqual(const Vec4<T>& a, const Vec4<T>& b, const Vec4<T>& eps)
508 {
509  return isApproxEqual(a[0], b[0], eps[0]) &&
510  isApproxEqual(a[1], b[1], eps[1]) &&
511  isApproxEqual(a[2], b[2], eps[2]) &&
512  isApproxEqual(a[3], b[3], eps[3]);
513 }
514 
515 template<typename T>
516 inline Vec4<T>
517 Abs(const Vec4<T>& v)
518 {
519  return Vec4<T>(Abs(v[0]), Abs(v[1]), Abs(v[2]), Abs(v[3]));
520 }
521 
522 /// @remark We are switching to a more explicit name because the semantics
523 /// are different from std::min/max. In that case, the function returns a
524 /// reference to one of the objects based on a comparator. Here, we must
525 /// fabricate a new object which might not match either of the inputs.
526 
527 /// Return component-wise minimum of the two vectors.
528 template <typename T>
529 inline Vec4<T> minComponent(const Vec4<T> &v1, const Vec4<T> &v2)
530 {
531  return Vec4<T>(
532  std::min(v1.x(), v2.x()),
533  std::min(v1.y(), v2.y()),
534  std::min(v1.z(), v2.z()),
535  std::min(v1.w(), v2.w()));
536 }
537 
538 /// Return component-wise maximum of the two vectors.
539 template <typename T>
540 inline Vec4<T> maxComponent(const Vec4<T> &v1, const Vec4<T> &v2)
541 {
542  return Vec4<T>(
543  std::max(v1.x(), v2.x()),
544  std::max(v1.y(), v2.y()),
545  std::max(v1.z(), v2.z()),
546  std::max(v1.w(), v2.w()));
547 }
548 
549 /// @brief Return a vector with the exponent applied to each of
550 /// the components of the input vector.
551 template <typename T>
552 inline Vec4<T> Exp(Vec4<T> v) { return v.exp(); }
553 
554 /// @brief Return a vector with log applied to each of
555 /// the components of the input vector.
556 template <typename T>
557 inline Vec4<T> Log(Vec4<T> v) { return v.log(); }
558 
563 
568 
569 } // namespace math
570 } // namespace OPENVDB_VERSION_NAME
571 } // namespace openvdb
572 
573 #endif // OPENVDB_MATH_VEC4_HAS_BEEN_INCLUDED
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:504
T x() const
Get the component, e.g. float f = v.y();.
Definition: Vec4.h:84
Vec4(T val)
Construct a vector all of whose components have the given value.
Definition: Vec4.h:36
Vec4(const Tuple< 4, Source > &v)
Conversion constructor.
Definition: Vec4.h:59
const Vec4< T > & operator*=(S scalar)
Multiply each element of this vector by scalar.
Definition: Vec4.h:297
const Vec4< T > & operator-=(const Vec4< S > &v1)
Subtract each element of the given vector from the corresponding element of this vector.
Definition: Vec4.h:375
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:443
const GLdouble * v
Definition: glcorearb.h:837
const Vec4< T > & operator+=(S scalar)
Add scalar to each element of this vector.
Definition: Vec4.h:342
GLsizei const GLfloat * value
Definition: glcorearb.h:824
Vec3< typename promote< T, Coord::ValueType >::type > operator-(const Vec3< T > &v0, const Coord &v1)
Allow a Coord to be subtracted from a Vec3.
Definition: Coord.h:553
vfloat4 sqrt(const vfloat4 &a)
Definition: simd.h:7481
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
const Vec4< T > & operator*=(const Vec4< S > &v1)
Multiply each element of this vector by the corresponding element of the given vector.
Definition: Vec4.h:308
Mat3< typename promote< T0, T1 >::type > operator*(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Multiply m0 by m1 and return the resulting matrix.
Definition: Mat3.h:597
Vec4(Source *a)
Constructor with array argument, e.g. float a[4]; Vec4f v(a);.
Definition: Vec4.h:49
const Vec4< T > & operator/=(S scalar)
Divide each element of this vector by scalar.
Definition: Vec4.h:320
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:239
Vec2< T > Log(Vec2< T > v)
Return a vector with log applied to each of the components of the input vector.
Definition: Vec2.h:528
Dummy class for tag dispatch of conversion constructors.
Definition: Tuple.h:23
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
const Vec4< T > & div(T0 scalar, const Vec4< T1 > &v)
Definition: Vec4.h:190
const Vec4< T > & operator/=(const Vec4< S > &v1)
Divide each element of this vector by the corresponding element of the given vector.
Definition: Vec4.h:331
**But if you need a or simply need to know when the task has note that the like this
Definition: thread.h:617
GLint y
Definition: glcorearb.h:103
**But if you need a result
Definition: thread.h:613
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
Vec4< T > unit(T eps=0) const
return normalized this, throws if null vector
Definition: Vec4.h:272
const Vec4< T > & init(T x=0, T y=0, T z=0, T w=0)
Definition: Vec4.h:103
Vec2< typename promote< S, T >::type > operator/(S scalar, const Vec2< T > &v)
Divide scalar by each element of the given vector and return the result.
Definition: Vec2.h:385
const Vec4< T > & scale(T0 scale, const Vec4< T1 > &v)
Definition: Vec4.h:179
Vec4< T > unit(T eps, T &len) const
return normalized this and length, throws if null vector
Definition: Vec4.h:279
const Vec4< T > & sub(const Vec4< T0 > &v1, const Vec4< T1 > &v2)
Definition: Vec4.h:166
#define OPENVDB_IS_POD(Type)
Definition: Math.h:56
bool isApproxEqual(const Type &a, const Type &b, const Type &tolerance)
Return true if a is equal to b to within the given tolerance.
Definition: Math.h:406
bool normalize(T eps=static_cast< T >(1.0e-8))
this = normalized this
Definition: Vec4.h:261
Coord Abs(const Coord &xyz)
Definition: Coord.h:517
T sum() const
Return the sum of all the vector components.
Definition: Vec4.h:249
Vec4< T > operator-() const
Negation operator, for e.g. v1 = -v2;.
Definition: Vec4.h:140
static Vec4< T > zero()
Predefined constants, e.g. Vec4f v = Vec4f::xNegAxis();.
Definition: Vec4.h:390
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Vec4(Other val, typename std::enable_if< std::is_arithmetic< Other >::value, Conversion >::type=Conversion{})
Construct a vector all of whose components have the given value, which may be of an arithmetic type d...
Definition: Vec4.h:71
const Vec4< T > & operator+=(const Vec4< S > &v1)
Add each element of the given vector to the corresponding element of this vector. ...
Definition: Vec4.h:353
const Vec4< T > & setZero()
Set "this" vector to zero.
Definition: Vec4.h:110
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition: Vec4.h:78
Vec4(T x, T y, T z, T w)
Constructor with four arguments, e.g. Vec4f v(1,2,3,4);.
Definition: Vec4.h:39
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
const Vec4< T > & operator=(const Vec4< Source > &v)
Assignment operator.
Definition: Vec4.h:118
Vec3< T > getVec3() const
Returns a Vec3 with the first three elements of the Vec4.
Definition: Vec4.h:99
T & operator()(int i)
Alternative indexed reference to the elements.
Definition: Vec4.h:93
GLfloat v0
Definition: glcorearb.h:816
const Vec4< T > & add(const Vec4< T0 > &v1, const Vec4< T1 > &v2)
Definition: Vec4.h:152
T length() const
Length of the vector.
Definition: Vec4.h:208
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:481
T product() const
Return the product of all the vector components.
Definition: Vec4.h:255
const Vec4< T > & operator-=(S scalar)
Subtract scalar from each element of this vector.
Definition: Vec4.h:364
Vec4< T > unitSafe() const
return normalized this, or (1, 0, 0, 0) if this is null vector
Definition: Vec4.h:289
GLfloat GLfloat v1
Definition: glcorearb.h:817
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLuint GLfloat * val
Definition: glcorearb.h:1608
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
Definition: Vec2.h:513
T dot(const Vec4< T > &v) const
Dot product.
Definition: Vec4.h:201
Vec3< typename promote< T, typename Coord::ValueType >::type > operator+(const Vec3< T > &v0, const Coord &v1)
Allow a Coord to be added to or subtracted from a Vec3.
Definition: Coord.h:527
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
Definition: ImathVec.h:33
OIIO_FORCEINLINE T log(const T &v)
Definition: simd.h:7688
type
Definition: core.h:1059
bool eq(const Vec4< T > &v, T eps=static_cast< T >(1.0e-8)) const
Definition: Vec4.h:131
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:119
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:473
Type Exp(const Type &x)
Return ex.
Definition: Math.h:710
T operator()(int i) const
Alternative indexed constant reference to the elements,.
Definition: Vec4.h:96