OpenVDB 7.0.0

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 {
17 OPENVDB_USE_VERSION_NAMESPACE
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
31 Vec4() {}
32
34 explicit Vec4(T val) { this->mm[0] = this->mm[1] = this->mm[2] = this->mm[3] = val; }
35
37 Vec4(T x, T y, T z, T w)
38 {
39 this->mm[0] = x;
40 this->mm[1] = y;
41 this->mm[2] = z;
42 this->mm[3] = w;
43 }
44
46 template <typename Source>
47 Vec4(Source *a)
48 {
49 this->mm[0] = static_cast<T>(a[0]);
50 this->mm[1] = static_cast<T>(a[1]);
51 this->mm[2] = static_cast<T>(a[2]);
52 this->mm[3] = static_cast<T>(a[3]);
53 }
54
56 template<typename Source>
57 explicit Vec4(const Tuple<4, Source> &v)
58 {
59 this->mm[0] = static_cast<T>(v[0]);
60 this->mm[1] = static_cast<T>(v[1]);
61 this->mm[2] = static_cast<T>(v[2]);
62 this->mm[3] = static_cast<T>(v[3]);
63 }
64
68 template<typename Other>
69 explicit Vec4(Other val,
70 typename std::enable_if<std::is_arithmetic<Other>::value, Conversion>::type = Conversion{})
71 {
72 this->mm[0] = this->mm[1] = this->mm[2] = this->mm[3] = static_cast<T>(val);
73 }
74
76 T& x() { return this->mm[0]; }
77 T& y() { return this->mm[1]; }
78 T& z() { return this->mm[2]; }
79 T& w() { return this->mm[3]; }
80
82 T x() const { return this->mm[0]; }
83 T y() const { return this->mm[1]; }
84 T z() const { return this->mm[2]; }
85 T w() const { return this->mm[3]; }
86
87 T* asPointer() { return this->mm; }
88 const T* asPointer() const { return this->mm; }
89
91 T& operator()(int i) { return this->mm[i]; }
92
94 T operator()(int i) const { return this->mm[i]; }
95
97 Vec3<T> getVec3() const { return Vec3<T>(this->mm[0], this->mm[1], this->mm[2]); }
98
101 const Vec4<T>& init(T x=0, T y=0, T z=0, T w=0)
102 {
103 this->mm[0] = x; this->mm[1] = y; this->mm[2] = z; this->mm[3] = w;
104 return *this;
105 }
106
108 const Vec4<T>& setZero()
109 {
110 this->mm[0] = 0; this->mm[1] = 0; this->mm[2] = 0; this->mm[3] = 0;
111 return *this;
112 }
113
115 template<typename Source>
116 const Vec4<T>& operator=(const Vec4<Source> &v)
117 {
118 // note: don't static_cast because that suppresses warnings
119 this->mm[0] = v[0];
120 this->mm[1] = v[1];
121 this->mm[2] = v[2];
122 this->mm[3] = v[3];
123
124 return *this;
125 }
126
129 bool eq(const Vec4<T> &v, T eps = static_cast<T>(1.0e-8)) const
130 {
131 return isApproxEqual(this->mm[0], v.mm[0], eps) &&
132 isApproxEqual(this->mm[1], v.mm[1], eps) &&
133 isApproxEqual(this->mm[2], v.mm[2], eps) &&
134 isApproxEqual(this->mm[3], v.mm[3], eps);
135 }
136
138 Vec4<T> operator-() const
139 {
140 return Vec4<T>(
141 -this->mm[0],
142 -this->mm[1],
143 -this->mm[2],
144 -this->mm[3]);
145 }
146
149 template <typename T0, typename T1>
150 const Vec4<T>& add(const Vec4<T0> &v1, const Vec4<T1> &v2)
151 {
152 this->mm[0] = v1[0] + v2[0];
153 this->mm[1] = v1[1] + v2[1];
154 this->mm[2] = v1[2] + v2[2];
155 this->mm[3] = v1[3] + v2[3];
156
157 return *this;
158 }
159
160
163 template <typename T0, typename T1>
164 const Vec4<T>& sub(const Vec4<T0> &v1, const Vec4<T1> &v2)
165 {
166 this->mm[0] = v1[0] - v2[0];
167 this->mm[1] = v1[1] - v2[1];
168 this->mm[2] = v1[2] - v2[2];
169 this->mm[3] = v1[3] - v2[3];
170
171 return *this;
172 }
173
176 template <typename T0, typename T1>
177 const Vec4<T>& scale(T0 scale, const Vec4<T1> &v)
178 {
179 this->mm[0] = scale * v[0];
180 this->mm[1] = scale * v[1];
181 this->mm[2] = scale * v[2];
182 this->mm[3] = scale * v[3];
183
184 return *this;
185 }
186
187 template <typename T0, typename T1>
188 const Vec4<T> &div(T0 scalar, const Vec4<T1> &v)
189 {
190 this->mm[0] = v[0] / scalar;
191 this->mm[1] = v[1] / scalar;
192 this->mm[2] = v[2] / scalar;
193 this->mm[3] = v[3] / scalar;
194
195 return *this;
196 }
197
199 T dot(const Vec4<T> &v) const
200 {
201 return (this->mm[0]*v.mm[0] + this->mm[1]*v.mm[1]
202 + this->mm[2]*v.mm[2] + this->mm[3]*v.mm[3]);
203 }
204
206 T length() const
207 {
208 return sqrt(
209 this->mm[0]*this->mm[0] +
210 this->mm[1]*this->mm[1] +
211 this->mm[2]*this->mm[2] +
212 this->mm[3]*this->mm[3]);
213 }
214
215
218 T lengthSqr() const
219 {
220 return (this->mm[0]*this->mm[0] + this->mm[1]*this->mm[1]
221 + this->mm[2]*this->mm[2] + this->mm[3]*this->mm[3]);
222 }
223
226 inline const Vec4<T>& exp()
227 {
228 this->mm[0] = std::exp(this->mm[0]);
229 this->mm[1] = std::exp(this->mm[1]);
230 this->mm[2] = std::exp(this->mm[2]);
231 this->mm[3] = std::exp(this->mm[3]);
232 return *this;
233 }
234
237 inline const Vec4<T>& log()
238 {
239 this->mm[0] = std::log(this->mm[0]);
240 this->mm[1] = std::log(this->mm[1]);
241 this->mm[2] = std::log(this->mm[2]);
242 this->mm[3] = std::log(this->mm[3]);
243 return *this;
244 }
245
247 inline T sum() const
248 {
249 return this->mm[0] + this->mm[1] + this->mm[2] + this->mm[3];
250 }
251
253 inline T product() const
254 {
255 return this->mm[0] * this->mm[1] * this->mm[2] * this->mm[3];
256 }
257
259 bool normalize(T eps = static_cast<T>(1.0e-8))
260 {
261 T d = length();
262 if (isApproxEqual(d, T(0), eps)) {
263 return false;
264 }
265 *this *= (T(1) / d);
266 return true;
267 }
268
270 Vec4<T> unit(T eps=0) const
271 {
272 T d;
273 return unit(eps, d);
274 }
275
277 Vec4<T> unit(T eps, T& len) const
278 {
279 len = length();
280 if (isApproxEqual(len, T(0), eps)) {
281 throw ArithmeticError("Normalizing null 4-vector");
282 }
283 return *this / len;
284 }
285
287 Vec4<T> unitSafe() const
288 {
289 T l2 = lengthSqr();
290 return l2 ? *this / static_cast<T>(sqrt(l2)) : Vec4<T>(1, 0, 0, 0);
291 }
292
294 template <typename S>
295 const Vec4<T> &operator*=(S scalar)
296 {
297 this->mm[0] *= scalar;
298 this->mm[1] *= scalar;
299 this->mm[2] *= scalar;
300 this->mm[3] *= scalar;
301 return *this;
302 }
303
305 template <typename S>
306 const Vec4<T> &operator*=(const Vec4<S> &v1)
307 {
308 this->mm[0] *= v1[0];
309 this->mm[1] *= v1[1];
310 this->mm[2] *= v1[2];
311 this->mm[3] *= v1[3];
312
313 return *this;
314 }
315
317 template <typename S>
318 const Vec4<T> &operator/=(S scalar)
319 {
320 this->mm[0] /= scalar;
321 this->mm[1] /= scalar;
322 this->mm[2] /= scalar;
323 this->mm[3] /= scalar;
324 return *this;
325 }
326
328 template <typename S>
329 const Vec4<T> &operator/=(const Vec4<S> &v1)
330 {
331 this->mm[0] /= v1[0];
332 this->mm[1] /= v1[1];
333 this->mm[2] /= v1[2];
334 this->mm[3] /= v1[3];
335 return *this;
336 }
337
339 template <typename S>
340 const Vec4<T> &operator+=(S scalar)
341 {
342 this->mm[0] += scalar;
343 this->mm[1] += scalar;
344 this->mm[2] += scalar;
345 this->mm[3] += scalar;
346 return *this;
347 }
348
350 template <typename S>
351 const Vec4<T> &operator+=(const Vec4<S> &v1)
352 {
353 this->mm[0] += v1[0];
354 this->mm[1] += v1[1];
355 this->mm[2] += v1[2];
356 this->mm[3] += v1[3];
357 return *this;
358 }
359
361 template <typename S>
362 const Vec4<T> &operator-=(S scalar)
363 {
364 this->mm[0] -= scalar;
365 this->mm[1] -= scalar;
366 this->mm[2] -= scalar;
367 this->mm[3] -= scalar;
368 return *this;
369 }
370
372 template <typename S>
373 const Vec4<T> &operator-=(const Vec4<S> &v1)
374 {
375 this->mm[0] -= v1[0];
376 this->mm[1] -= v1[1];
377 this->mm[2] -= v1[2];
378 this->mm[3] -= v1[3];
379 return *this;
380 }
381
382 // Number of cols, rows, elements
383 static unsigned numRows() { return 1; }
384 static unsigned numColumns() { return 4; }
385 static unsigned numElements() { return 4; }
386
388 static Vec4<T> zero() { return Vec4<T>(0, 0, 0, 0); }
389 static Vec4<T> origin() { return Vec4<T>(0, 0, 0, 1); }
390 static Vec4<T> ones() { return Vec4<T>(1, 1, 1, 1); }
391 };
392
394 template <typename T0, typename T1>
395 inline bool operator==(const Vec4<T0> &v0, const Vec4<T1> &v1)
396 {
397 return
398 isExactlyEqual(v0[0], v1[0]) &&
399 isExactlyEqual(v0[1], v1[1]) &&
400 isExactlyEqual(v0[2], v1[2]) &&
401 isExactlyEqual(v0[3], v1[3]);
402 }
403
405 template <typename T0, typename T1>
406 inline bool operator!=(const Vec4<T0> &v0, const Vec4<T1> &v1) { return !(v0==v1); }
407
409 template <typename S, typename T>
410 inline Vec4<typename promote<S, T>::type> operator*(S scalar, const Vec4<T> &v)
411 { return v*scalar; }
412
414 template <typename S, typename T>
415 inline Vec4<typename promote<S, T>::type> operator*(const Vec4<T> &v, S scalar)
416 {
417 Vec4<typename promote<S, T>::type> result(v);
418 result *= scalar;
419 return result;
420 }
421
423 template <typename T0, typename T1>
424 inline Vec4<typename promote<T0, T1>::type> operator*(const Vec4<T0> &v0, const Vec4<T1> &v1)
425 {
426 Vec4<typename promote<T0, T1>::type> result(v0[0]*v1[0],
427 v0[1]*v1[1],
428 v0[2]*v1[2],
429 v0[3]*v1[3]);
430 return result;
431 }
432
434 template <typename S, typename T>
435 inline Vec4<typename promote<S, T>::type> operator/(S scalar, const Vec4<T> &v)
436 {
437 return Vec4<typename promote<S, T>::type>(scalar/v[0],
438 scalar/v[1],
439 scalar/v[2],
440 scalar/v[3]);
441 }
442
444 template <typename S, typename T>
445 inline Vec4<typename promote<S, T>::type> operator/(const Vec4<T> &v, S scalar)
446 {
447 Vec4<typename promote<S, T>::type> result(v);
448 result /= scalar;
449 return result;
450 }
451
453 template <typename T0, typename T1>
454 inline Vec4<typename promote<T0, T1>::type> operator/(const Vec4<T0> &v0, const Vec4<T1> &v1)
455 {
456 Vec4<typename promote<T0, T1>::type>
457 result(v0[0]/v1[0], v0[1]/v1[1], v0[2]/v1[2], v0[3]/v1[3]);
458 return result;
459 }
460
462 template <typename T0, typename T1>
463 inline Vec4<typename promote<T0, T1>::type> operator+(const Vec4<T0> &v0, const Vec4<T1> &v1)
464 {
465 Vec4<typename promote<T0, T1>::type> result(v0);
466 result += v1;
467 return result;
468 }
469
471 template <typename S, typename T>
472 inline Vec4<typename promote<S, T>::type> operator+(const Vec4<T> &v, S scalar)
473 {
474 Vec4<typename promote<S, T>::type> result(v);
475 result += scalar;
476 return result;
477 }
478
480 template <typename T0, typename T1>
481 inline Vec4<typename promote<T0, T1>::type> operator-(const Vec4<T0> &v0, const Vec4<T1> &v1)
482 {
483 Vec4<typename promote<T0, T1>::type> result(v0);
484 result -= v1;
485 return result;
486 }
487
489 template <typename S, typename T>
490 inline Vec4<typename promote<S, T>::type> operator-(const Vec4<T> &v, S scalar)
491 {
492 Vec4<typename promote<S, T>::type> result(v);
493 result -= scalar;
494 return result;
495 }
496
497 template <typename T>
498 inline bool
499 isApproxEqual(const Vec4<T>& a, const Vec4<T>& b)
500 {
501 return a.eq(b);
502 }
503 template <typename T>
504 inline bool
505 isApproxEqual(const Vec4<T>& a, const Vec4<T>& b, const Vec4<T>& eps)
506 {
507 return isApproxEqual(a[0], b[0], eps[0]) &&
508 isApproxEqual(a[1], b[1], eps[1]) &&
509 isApproxEqual(a[2], b[2], eps[2]) &&
510 isApproxEqual(a[3], b[3], eps[3]);
511 }
512
513 template<typename T>
514 inline Vec4<T>
515 Abs(const Vec4<T>& v)
516 {
517 return Vec4<T>(Abs(v[0]), Abs(v[1]), Abs(v[2]), Abs(v[3]));
518 }
519
524
526 template <typename T>
527 inline Vec4<T> minComponent(const Vec4<T> &v1, const Vec4<T> &v2)
528 {
529 return Vec4<T>(
530 std::min(v1.x(), v2.x()),
531 std::min(v1.y(), v2.y()),
532 std::min(v1.z(), v2.z()),
533 std::min(v1.w(), v2.w()));
534 }
535
537 template <typename T>
538 inline Vec4<T> maxComponent(const Vec4<T> &v1, const Vec4<T> &v2)
539 {
540 return Vec4<T>(
541 std::max(v1.x(), v2.x()),
542 std::max(v1.y(), v2.y()),
543 std::max(v1.z(), v2.z()),
544 std::max(v1.w(), v2.w()));
545 }
546
549 template <typename T>
550 inline Vec4<T> Exp(Vec4<T> v) { return v.exp(); }
551
554 template <typename T>
555 inline Vec4<T> Log(Vec4<T> v) { return v.log(); }
556
557 using Vec4i = Vec4<int32_t>;
558 using Vec4ui = Vec4<uint32_t>;
559 using Vec4s = Vec4<float>;
560 using Vec4d = Vec4<double>;
561
562 } // namespace math
563 } // namespace OPENVDB_VERSION_NAME
564 } // namespace openvdb
565
566 #endif // OPENVDB_MATH_VEC4_HAS_BEEN_INCLUDED
openvdb::v7_0::math::Vec4::sub
const Vec4< T > & sub(const Vec4< T0 > &v1, const Vec4< T1 > &v2)
Definition: Vec4.h:164
openvdb::v7_0::math::Vec4::Vec4
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:69
openvdb::v7_0::math::Vec4::lengthSqr
T lengthSqr() const
Definition: Vec4.h:218
openvdb::v7_0::math::Vec4::dot
T dot(const Vec4< T > &v) const
Dot product.
Definition: Vec4.h:199
openvdb::v7_0::math::Vec4::operator()
T & operator()(int i)
Alternative indexed reference to the elements.
Definition: Vec4.h:91
openvdb::v7_0::math::Tuple
Definition: Tuple.h:28
openvdb::v7_0::math::Vec4::Vec4
Vec4(Source *a)
Constructor with array argument, e.g. float a[4]; Vec4f v(a);.
Definition: Vec4.h:47
openvdb::v7_0::math::Vec4::zero
static Vec4< T > zero()
Predefined constants, e.g. Vec4f v = Vec4f::xNegAxis();.
Definition: Vec4.h:388
openvdb::v7_0::math::Vec4::operator*=
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:306
openvdb::v7_0::math::Vec4::z
T z() const
Definition: Vec4.h:84
openvdb::v7_0::math::Vec4::numRows
static unsigned numRows()
Definition: Vec4.h:383
openvdb::v7_0::math::Abs
Vec4< T > Abs(const Vec4< T > &v)
Definition: Vec4.h:515
openvdb::v7_0::math::Vec4::Vec4
Vec4()
Trivial constructor, the vector is NOT initialized.
Definition: Vec4.h:31
openvdb::v7_0::math::Vec4::operator*=
const Vec4< T > & operator*=(S scalar)
Multiply each element of this vector by scalar.
Definition: Vec4.h:295
openvdb::v7_0::math::operator/
Vec4< typename promote< T0, T1 >::type > operator/(const Vec4< T0 > &v0, const Vec4< T1 > &v1)
Divide corresponding elements of v0 and v1 and return the result.
Definition: Vec4.h:454
openvdb::v7_0::math::Vec4::x
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition: Vec4.h:76
openvdb::v7_0::math::Vec4::setZero
const Vec4< T > & setZero()
Set "this" vector to zero.
Definition: Vec4.h:108
openvdb::v7_0::math::maxComponent
Vec4< T > maxComponent(const Vec4< T > &v1, const Vec4< T > &v2)
Return component-wise maximum of the two vectors.
Definition: Vec4.h:538
openvdb::v7_0::math::operator*
Vec4< typename promote< T0, T1 >::type > operator*(const Vec4< T0 > &v0, const Vec4< T1 > &v1)
Multiply corresponding elements of v0 and v1 and return the result.
Definition: Vec4.h:424
openvdb::v7_0::math::Conversion
Dummy class for tag dispatch of conversion constructors.
Definition: Tuple.h:22
openvdb::v7_0::math::Vec4::unit
Vec4< T > unit(T eps=0) const
return normalized this, throws if null vector
Definition: Vec4.h:270
openvdb::v7_0::math::Vec4::operator-
Vec4< T > operator-() const
Negation operator, for e.g. v1 = -v2;.
Definition: Vec4.h:138
openvdb::v7_0::math::Vec4::w
T & w()
Definition: Vec4.h:79
openvdb::v7_0::math::Vec4::log
const Vec4< T > & log()
Definition: Vec4.h:237
openvdb::v7_0::math::Vec4::w
T w() const
Definition: Vec4.h:85
openvdb::v7_0::math::Exp
Vec4< T > Exp(Vec4< T > v)
Return a vector with the exponent applied to each of the components of the input vector.
Definition: Vec4.h:550
openvdb::v7_0::math::Vec4::operator-=
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:373
openvdb::v7_0::math::Vec4::ones
static Vec4< T > ones()
Definition: Vec4.h:390
openvdb::v7_0::math::Vec4
Definition: Mat4.h:24
openvdb::v7_0::math::operator-
Vec4< typename promote< S, T >::type > operator-(const Vec4< T > &v, S scalar)
Subtract scalar from each element of the given vector and return the result.
Definition: Vec4.h:490
openvdb::v7_0::math::Vec4::normalize
bool normalize(T eps=static_cast< T >(1.0e-8))
this = normalized this
Definition: Vec4.h:259
openvdb::v7_0::math::Vec4::operator/=
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:329
openvdb::v7_0::math::Vec4::asPointer
const T * asPointer() const
Definition: Vec4.h:88
openvdb::v7_0::math::Vec4::getVec3
Vec3< T > getVec3() const
Returns a Vec3 with the first three elements of the Vec4.
Definition: Vec4.h:97
openvdb::v7_0::math::Log
Vec4< T > Log(Vec4< T > v)
Return a vector with log applied to each of the components of the input vector.
Definition: Vec4.h:555
Vec3.h
openvdb::v7_0::math::Vec4::div
const Vec4< T > & div(T0 scalar, const Vec4< T1 > &v)
Definition: Vec4.h:188
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v7_0::math::Vec4::numElements
static unsigned numElements()
Definition: Vec4.h:385
openvdb::v7_0::math::Vec4::y
T y() const
Definition: Vec4.h:83
openvdb::v7_0::math::Vec4::operator+=
const Vec4< T > & operator+=(S scalar)
Add scalar to each element of this vector.
Definition: Vec4.h:340
openvdb::v7_0::tools::composite::max
const std::enable_if<!VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:106
openvdb::v7_0::math::Vec4::x
T x() const
Get the component, e.g. float f = v.y();.
Definition: Vec4.h:82
openvdb::v7_0::math::Vec3
Definition: Mat.h:170
openvdb::v7_0::math::Vec4::operator/=
const Vec4< T > & operator/=(S scalar)
Divide each element of this vector by scalar.
Definition: Vec4.h:318
openvdb::v7_0::math::Vec4::value_type
T value_type
Definition: Vec4.h:27
openvdb::v7_0::math::Vec4::operator=
const Vec4< T > & operator=(const Vec4< Source > &v)
Assignment operator.
Definition: Vec4.h:116
openvdb::v7_0::math::operator!=
bool operator!=(const Vec4< T0 > &v0, const Vec4< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec4.h:406
openvdb::v7_0::math::Vec4::Vec4
Vec4(T x, T y, T z, T w)
Constructor with four arguments, e.g. Vec4f v(1,2,3,4);.
Definition: Vec4.h:37
openvdb::v7_0::math::Vec4::ValueType
T ValueType
Definition: Vec4.h:28
openvdb::v7_0::math::Vec4::product
T product() const
Return the product of all the vector components.
Definition: Vec4.h:253
openvdb::v7_0::math::unit
MatType unit(const MatType &mat, typename MatType::value_type eps=1.0e-8)
Return a copy of the given matrix with its upper 3×3 rows normalized.
Definition: Mat.h:653
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
openvdb::v7_0::math::minComponent
Vec4< T > minComponent(const Vec4< T > &v1, const Vec4< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec4.h:527
openvdb::v7_0::math::Vec4::scale
const Vec4< T > & scale(T0 scale, const Vec4< T1 > &v)
Definition: Vec4.h:177
openvdb::v7_0::math::Vec4::z
T & z()
Definition: Vec4.h:78
openvdb::v7_0::tools::composite::min
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:102
openvdb::v7_0::math::Vec4::operator-=
const Vec4< T > & operator-=(S scalar)
Subtract scalar from each element of this vector.
Definition: Vec4.h:362
openvdb::v7_0::math::Vec4::init
const Vec4< T > & init(T x=0, T y=0, T z=0, T w=0)
Definition: Vec4.h:101
openvdb::v7_0::math::Vec4::asPointer
T * asPointer()
Definition: Vec4.h:87
openvdb::v7_0::math::Vec4::y
T & y()
Definition: Vec4.h:77
openvdb::v7_0::math::Vec4::operator+=
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:351
openvdb::v7_0::math::Vec4::numColumns
static unsigned numColumns()
Definition: Vec4.h:384
openvdb::v7_0::math::Vec4::sum
T sum() const
Return the sum of all the vector components.
Definition: Vec4.h:247
openvdb::v7_0::math::isExactlyEqual
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:388
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
openvdb::v7_0::math::scale
MatType scale(const Vec3< typename MatType::value_type > &s)
Return a matrix that scales by s.
Definition: Mat.h:620
openvdb::v7_0::math::Vec4::unitSafe
Vec4< T > unitSafe() const
return normalized this, or (1, 0, 0, 0) if this is null vector
Definition: Vec4.h:287
openvdb::v7_0::math::Vec4::add
const Vec4< T > & add(const Vec4< T0 > &v1, const Vec4< T1 > &v2)
Definition: Vec4.h:150
openvdb::v7_0::math::operator==
bool operator==(const Vec4< T0 > &v0, const Vec4< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec4.h:395
openvdb::v7_0::math::Vec4::origin
static Vec4< T > origin()
Definition: Vec4.h:389
openvdb::v7_0::math::Vec4::eq
bool eq(const Vec4< T > &v, T eps=static_cast< T >(1.0e-8)) const
Definition: Vec4.h:129
openvdb
Definition: Exceptions.h:13
openvdb::v7_0::math::Vec4::Vec4
Vec4(const Tuple< 4, Source > &v)
Conversion constructor.
Definition: Vec4.h:57
openvdb::v7_0::math::Vec4::length
T length() const
Length of the vector.
Definition: Vec4.h:206
openvdb::v7_0::math::isApproxEqual
bool isApproxEqual(const Vec4< T > &a, const Vec4< T > &b, const Vec4< T > &eps)
Definition: Vec4.h:505
openvdb::v7_0::math::operator+
Vec4< typename promote< S, T >::type > operator+(const Vec4< T > &v, S scalar)
Add scalar to each element of the given vector and return the result.
Definition: Vec4.h:472
Tuple.h
openvdb::v7_0::math::Vec4::Vec4
Vec4(T val)
Construct a vector all of whose components have the given value.
Definition: Vec4.h:34
openvdb::v7_0::math::Vec4::unit
Vec4< T > unit(T eps, T &len) const
return normalized this and length, throws if null vector
Definition: Vec4.h:277
Exceptions.h
openvdb::v7_0::math::Vec4::operator()
T operator()(int i) const
Alternative indexed constant reference to the elements,.
Definition: Vec4.h:94
openvdb::v7_0::ArithmeticError
Definition: Exceptions.h:56
openvdb::v7_0::math::Vec4::exp
const Vec4< T > & exp()
Definition: Vec4.h:226