OpenVDB 5.1.0

Vec2.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2018 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30
31 #ifndef OPENVDB_MATH_VEC2_HAS_BEEN_INCLUDED
32 #define OPENVDB_MATH_VEC2_HAS_BEEN_INCLUDED
33
34 #include <openvdb/Exceptions.h>
35 #include "Math.h"
36 #include "Tuple.h"
37 #include <algorithm>
38 #include <cmath>
39 #include <type_traits>
40
41
42 namespace openvdb {
43 OPENVDB_USE_VERSION_NAMESPACE
44 namespace OPENVDB_VERSION_NAME {
45 namespace math {
46
47 template<typename T> class Mat2;
48
49 template<typename T>
50 class Vec2: public Tuple<2, T>
51 {
52 public:
53 using value_type = T;
54 using ValueType = T;
55
57 Vec2() {}
58
60 explicit Vec2(T val) { this->mm[0] = this->mm[1] = val; }
61
63 Vec2(T x, T y)
64 {
65 this->mm[0] = x;
66 this->mm[1] = y;
67 }
68
70 template <typename Source>
71 Vec2(Source *a)
72 {
73 this->mm[0] = a[0];
74 this->mm[1] = a[1];
75 } // trivial
76
78 template<typename Source>
79 explicit Vec2(const Tuple<2, Source> &t)
80 {
81 this->mm[0] = static_cast<T>(t[0]);
82 this->mm[1] = static_cast<T>(t[1]);
83 }
84
88 template<typename Other>
89 explicit Vec2(Other val,
90 typename std::enable_if<std::is_arithmetic<Other>::value, Conversion>::type = Conversion{})
91 {
92 this->mm[0] = this->mm[1] = static_cast<T>(val);
93 }
94
96 T& x() {return this->mm[0];}
97 T& y() {return this->mm[1];}
98
100 T x() const {return this->mm[0];}
101 T y() const {return this->mm[1];}
102
104 T& operator()(int i) {return this->mm[i];}
105
107 T operator()(int i) const {return this->mm[i];}
108
109 T* asPointer() {return this->mm;}
110 const T* asPointer() const {return this->mm;}
111
114 const Vec2<T>& init(T x=0, T y=0)
115 {
116 this->mm[0] = x; this->mm[1] = y;
117 return *this;
118 }
119
121 const Vec2<T>& setZero()
122 {
123 this->mm[0] = 0; this->mm[1] = 0;
124 return *this;
125 }
126
128 template<typename Source>
129 const Vec2<T>& operator=(const Vec2<Source> &v)
130 {
131 // note: don't static_cast because that suppresses warnings
132 this->mm[0] = v[0];
133 this->mm[1] = v[1];
134
135 return *this;
136 }
137
139 bool operator==(const Vec2<T> &v) const
140 {
141 return (isExactlyEqual(this->mm[0], v.mm[0]) && isExactlyEqual(this->mm[1], v.mm[1]));
142 }
143
145 bool operator!=(const Vec2<T> &v) const { return !(*this==v); }
146
148 bool eq(const Vec2<T> &v, T eps = static_cast<T>(1.0e-7)) const
149 {
150 return isApproxEqual(this->mm[0], v.mm[0], eps) &&
151 isApproxEqual(this->mm[1], v.mm[1], eps);
152 } // trivial
153
155 Vec2<T> operator-() const {return Vec2<T>(-this->mm[0], -this->mm[1]);}
156
159 template <typename T0, typename T1>
160 const Vec2<T>& add(const Vec2<T0> &v1, const Vec2<T1> &v2)
161 {
162 this->mm[0] = v1[0] + v2[0];
163 this->mm[1] = v1[1] + v2[1];
164
165 return *this;
166 }
167
170 template <typename T0, typename T1>
171 const Vec2<T>& sub(const Vec2<T0> &v1, const Vec2<T1> &v2)
172 {
173 this->mm[0] = v1[0] - v2[0];
174 this->mm[1] = v1[1] - v2[1];
175
176 return *this;
177 }
178
181 template <typename T0, typename T1>
182 const Vec2<T>& scale(T0 scalar, const Vec2<T1> &v)
183 {
184 this->mm[0] = scalar * v[0];
185 this->mm[1] = scalar * v[1];
186
187 return *this;
188 }
189
190 template <typename T0, typename T1>
191 const Vec2<T> &div(T0 scalar, const Vec2<T1> &v)
192 {
193 this->mm[0] = v[0] / scalar;
194 this->mm[1] = v[1] / scalar;
195
196 return *this;
197 }
198
200 T dot(const Vec2<T> &v) const { return this->mm[0]*v[0] + this->mm[1]*v[1]; } // trivial
201
203 T length() const
204 {
205 return static_cast<T>(sqrt(double(this->mm[0]*this->mm[0] + this->mm[1]*this->mm[1])));
206 }
207
210 T lengthSqr() const { return (this->mm[0]*this->mm[0] + this->mm[1]*this->mm[1]); }
211
214 inline const Vec2<T>& exp()
215 {
216 this->mm[0] = std::exp(this->mm[0]);
217 this->mm[1] = std::exp(this->mm[1]);
218 return *this;
219 }
220
223 inline const Vec2<T>& log()
224 {
225 this->mm[0] = std::log(this->mm[0]);
226 this->mm[1] = std::log(this->mm[1]);
227 return *this;
228 }
229
231 inline T sum() const
232 {
233 return this->mm[0] + this->mm[1];
234 }
235
237 inline T product() const
238 {
239 return this->mm[0] * this->mm[1];
240 }
241
243 bool normalize(T eps=1.0e-8)
244 {
245 T d = length();
246 if (isApproxEqual(d, T(0), eps)) {
247 return false;
248 }
249 *this *= (T(1) / d);
250 return true;
251 }
252
254 Vec2<T> unit(T eps=0) const
255 {
256 T d;
257 return unit(eps, d);
258 }
259
261 Vec2<T> unit(T eps, T& len) const
262 {
263 len = length();
264 if (isApproxEqual(len, T(0), eps)) {
265 OPENVDB_THROW(ArithmeticError, "Normalizing null 2-vector");
266 }
267 return *this / len;
268 }
269
271 Vec2<T> unitSafe() const
272 {
273 T l2 = lengthSqr();
274 return l2 ? *this/static_cast<T>(sqrt(l2)) : Vec2<T>(1,0);
275 }
276
278 template <typename S>
279 const Vec2<T> &operator*=(S scalar)
280 {
281 this->mm[0] *= scalar;
282 this->mm[1] *= scalar;
283 return *this;
284 }
285
287 template <typename S>
288 const Vec2<T> &operator*=(const Vec2<S> &v1)
289 {
290 this->mm[0] *= v1[0];
291 this->mm[1] *= v1[1];
292 return *this;
293 }
294
296 template <typename S>
297 const Vec2<T> &operator/=(S scalar)
298 {
299 this->mm[0] /= scalar;
300 this->mm[1] /= scalar;
301 return *this;
302 }
303
305 template <typename S>
306 const Vec2<T> &operator/=(const Vec2<S> &v1)
307 {
308 this->mm[0] /= v1[0];
309 this->mm[1] /= v1[1];
310 return *this;
311 }
312
314 template <typename S>
315 const Vec2<T> &operator+=(S scalar)
316 {
317 this->mm[0] += scalar;
318 this->mm[1] += scalar;
319 return *this;
320 }
321
323 template <typename S>
324 const Vec2<T> &operator+=(const Vec2<S> &v1)
325 {
326 this->mm[0] += v1[0];
327 this->mm[1] += v1[1];
328 return *this;
329 }
330
332 template <typename S>
333 const Vec2<T> &operator-=(S scalar)
334 {
335 this->mm[0] -= scalar;
336 this->mm[1] -= scalar;
337 return *this;
338 }
339
341 template <typename S>
342 const Vec2<T> &operator-=(const Vec2<S> &v1)
343 {
344 this->mm[0] -= v1[0];
345 this->mm[1] -= v1[1];
346 return *this;
347 }
348
349 // Number of cols, rows, elements
350 static unsigned numRows() { return 1; }
351 static unsigned numColumns() { return 2; }
352 static unsigned numElements() { return 2; }
353
356 T component(const Vec2<T> &onto, T eps=1.0e-8) const
357 {
358 T l = onto.length();
359 if (isApproxEqual(l, T(0), eps)) return 0;
360
361 return dot(onto)*(T(1)/l);
362 }
363
366 Vec2<T> projection(const Vec2<T> &onto, T eps=1.0e-8) const
367 {
368 T l = onto.lengthSqr();
369 if (isApproxEqual(l, T(0), eps)) return Vec2::zero();
370
371 return onto*(dot(onto)*(T(1)/l));
372 }
373
377 Vec2<T> getArbPerpendicular() const { return Vec2<T>(-this->mm[1], this->mm[0]); }
378
380 static Vec2<T> zero() { return Vec2<T>(0, 0); }
381 static Vec2<T> ones() { return Vec2<T>(1, 1); }
382 };
383
384
386 template <typename S, typename T>
387 inline Vec2<typename promote<S, T>::type> operator*(S scalar, const Vec2<T> &v)
388 {
389 return v * scalar;
390 }
391
393 template <typename S, typename T>
394 inline Vec2<typename promote<S, T>::type> operator*(const Vec2<T> &v, S scalar)
395 {
396 Vec2<typename promote<S, T>::type> result(v);
397 result *= scalar;
398 return result;
399 }
400
402 template <typename T0, typename T1>
403 inline Vec2<typename promote<T0, T1>::type> operator*(const Vec2<T0> &v0, const Vec2<T1> &v1)
404 {
405 Vec2<typename promote<T0, T1>::type> result(v0[0] * v1[0], v0[1] * v1[1]);
406 return result;
407 }
408
410 template <typename S, typename T>
411 inline Vec2<typename promote<S, T>::type> operator/(S scalar, const Vec2<T> &v)
412 {
413 return Vec2<typename promote<S, T>::type>(scalar/v[0], scalar/v[1]);
414 }
415
417 template <typename S, typename T>
418 inline Vec2<typename promote<S, T>::type> operator/(const Vec2<T> &v, S scalar)
419 {
420 Vec2<typename promote<S, T>::type> result(v);
421 result /= scalar;
422 return result;
423 }
424
426 template <typename T0, typename T1>
427 inline Vec2<typename promote<T0, T1>::type> operator/(const Vec2<T0> &v0, const Vec2<T1> &v1)
428 {
429 Vec2<typename promote<T0, T1>::type> result(v0[0] / v1[0], v0[1] / v1[1]);
430 return result;
431 }
432
434 template <typename T0, typename T1>
435 inline Vec2<typename promote<T0, T1>::type> operator+(const Vec2<T0> &v0, const Vec2<T1> &v1)
436 {
437 Vec2<typename promote<T0, T1>::type> result(v0);
438 result += v1;
439 return result;
440 }
441
443 template <typename S, typename T>
444 inline Vec2<typename promote<S, T>::type> operator+(const Vec2<T> &v, S scalar)
445 {
446 Vec2<typename promote<S, T>::type> result(v);
447 result += scalar;
448 return result;
449 }
450
452 template <typename T0, typename T1>
453 inline Vec2<typename promote<T0, T1>::type> operator-(const Vec2<T0> &v0, const Vec2<T1> &v1)
454 {
455 Vec2<typename promote<T0, T1>::type> result(v0);
456 result -= v1;
457 return result;
458 }
459
461 template <typename S, typename T>
462 inline Vec2<typename promote<S, T>::type> operator-(const Vec2<T> &v, S scalar)
463 {
464 Vec2<typename promote<S, T>::type> result(v);
465 result -= scalar;
466 return result;
467 }
468
471 template <typename T>
472 inline T angle(const Vec2<T> &v1, const Vec2<T> &v2)
473 {
474 T c = v1.dot(v2);
475 return acos(c);
476 }
477
478 template <typename T>
479 inline bool
480 isApproxEqual(const Vec2<T>& a, const Vec2<T>& b)
481 {
482 return a.eq(b);
483 }
484 template <typename T>
485 inline bool
486 isApproxEqual(const Vec2<T>& a, const Vec2<T>& b, const Vec2<T>& eps)
487 {
488 return isApproxEqual(a.x(), b.x(), eps.x()) &&
489 isApproxEqual(a.y(), b.y(), eps.y());
490 }
491
492 template<typename T>
493 inline Vec2<T>
494 Abs(const Vec2<T>& v)
495 {
496 return Vec2<T>(Abs(v[0]), Abs(v[1]));
497 }
498
501 template <typename T>
502 inline void orthonormalize(Vec2<T> &v1, Vec2<T> &v2)
503 {
504 // If the input vectors are v0, v1, and v2, then the Gram-Schmidt
505 // orthonormalization produces vectors u0, u1, and u2 as follows,
506 //
507 // u0 = v0/|v0|
508 // u1 = (v1-(u0*v1)u0)/|v1-(u0*v1)u0|
509 //
510 // where |A| indicates length of vector A and A*B indicates dot
511 // product of vectors A and B.
512
513 // compute u0
514 v1.normalize();
515
516 // compute u1
517 T d0 = v1.dot(v2);
518 v2 -= v1*d0;
519 v2.normalize();
520 }
521
522
527
529 template <typename T>
530 inline Vec2<T> minComponent(const Vec2<T> &v1, const Vec2<T> &v2)
531 {
532 return Vec2<T>(
533 std::min(v1.x(), v2.x()),
534 std::min(v1.y(), v2.y()));
535 }
536
538 template <typename T>
539 inline Vec2<T> maxComponent(const Vec2<T> &v1, const Vec2<T> &v2)
540 {
541 return Vec2<T>(
542 std::max(v1.x(), v2.x()),
543 std::max(v1.y(), v2.y()));
544 }
545
548 template <typename T>
549 inline Vec2<T> Exp(Vec2<T> v) { return v.exp(); }
550
553 template <typename T>
554 inline Vec2<T> Log(Vec2<T> v) { return v.log(); }
555
556 using Vec2i = Vec2<int32_t>;
557 using Vec2ui = Vec2<uint32_t>;
558 using Vec2s = Vec2<float>;
559 using Vec2d = Vec2<double>;
560
561 } // namespace math
562 } // namespace OPENVDB_VERSION_NAME
563 } // namespace openvdb
564
565 #endif // OPENVDB_MATH_VEC2_HAS_BEEN_INCLUDED
566
567 // Copyright (c) 2012-2018 DreamWorks Animation LLC
568 // All rights reserved. This software is distributed under the
569 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v5_1::math::isExactlyEqual
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:395
openvdb::v5_1::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:678
openvdb::v5_1::math::Vec2::numRows
static unsigned numRows()
Definition: Vec2.h:350
openvdb::v5_1::math::Vec2::div
const Vec2< T > & div(T0 scalar, const Vec2< T1 > &v)
Definition: Vec2.h:191
openvdb::v5_1::math::Vec2::setZero
const Vec2< T > & setZero()
Set "this" vector to zero.
Definition: Vec2.h:121
openvdb::v5_1::math::Vec2::unitSafe
Vec2< T > unitSafe() const
return normalized this, or (1, 0) if this is null vector
Definition: Vec2.h:271
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v5_1::math::Vec2::operator()
T operator()(int i) const
Alternative indexed constant reference to the elements,.
Definition: Vec2.h:107
openvdb::v5_1::math::Vec2::operator*=
const Vec2< T > & operator*=(const Vec2< S > &v1)
Multiply each element of this vector by the corresponding element of the given vector.
Definition: Vec2.h:288
openvdb::v5_1::math::Vec2::operator=
const Vec2< T > & operator=(const Vec2< Source > &v)
Assignment operator.
Definition: Vec2.h:129
openvdb::v5_1::math::Vec2::product
T product() const
Return the product of all the vector components.
Definition: Vec2.h:237
openvdb::v5_1::math::Vec2::operator-=
const Vec2< T > & operator-=(const Vec2< S > &v1)
Subtract each element of the given vector from the corresponding element of this vector.
Definition: Vec2.h:342
openvdb::v5_1::math::Vec2::operator()
T & operator()(int i)
Alternative indexed reference to the elements.
Definition: Vec2.h:104
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
openvdb::v5_1::math::Vec2::Vec2
Vec2(Source *a)
Constructor with array argument, e.g. float a[2]; Vec2f v(a);.
Definition: Vec2.h:71
openvdb::v5_1::math::operator-
Vec2< typename promote< S, T >::type > operator-(const Vec2< T > &v, S scalar)
Subtract scalar from each element of the given vector and return the result.
Definition: Vec2.h:462
openvdb::v5_1::math::Vec2::Vec2
Vec2()
Trivial constructor, the vector is NOT initialized.
Definition: Vec2.h:57
openvdb::v5_1::math::Vec2::operator-
Vec2< T > operator-() const
Negation operator, for e.g. v1 = -v2;.
Definition: Vec2.h:155
openvdb::v5_1::math::Vec2::x
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition: Vec2.h:96
openvdb::v5_1::math::Vec2::add
const Vec2< T > & add(const Vec2< T0 > &v1, const Vec2< T1 > &v2)
Definition: Vec2.h:160
openvdb::v5_1::math::Log
Vec2< T > Log(Vec2< T > v)
Return a vector with log applied to each of the components of the input vector.
Definition: Vec2.h:554
openvdb::v5_1::math::Vec2::x
T x() const
Get the component, e.g. float f = v.y();.
Definition: Vec2.h:100
openvdb::v5_1::math::Vec2::operator/=
const Vec2< T > & operator/=(S scalar)
Divide each element of this vector by scalar.
Definition: Vec2.h:297
openvdb::v5_1::math::angle
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition: Vec2.h:472
openvdb::v5_1::math::Vec2::Vec2
Vec2(T val)
Construct a vector all of whose components have the given value.
Definition: Vec2.h:60
openvdb::v5_1::math::Vec2::sum
T sum() const
Return the sum of all the vector components.
Definition: Vec2.h:231
openvdb::v5_1::math::Vec2::y
T & y()
Definition: Vec2.h:97
openvdb::v5_1::math::Vec2::Vec2
Vec2(const Tuple< 2, Source > &t)
Conversion constructor.
Definition: Vec2.h:79
openvdb::v5_1::math::Vec2::value_type
T value_type
Definition: Vec2.h:53
openvdb::v5_1::math::Vec2::normalize
bool normalize(T eps=1.0e-8)
this = normalized this
Definition: Vec2.h:243
openvdb::v5_1::math::Vec2::component
T component(const Vec2< T > &onto, T eps=1.0e-8) const
Definition: Vec2.h:356
openvdb::v5_1::math::Vec2::asPointer
const T * asPointer() const
Definition: Vec2.h:110
openvdb::v5_1::math::isApproxEqual
bool isApproxEqual(const Vec2< T > &a, const Vec2< T > &b, const Vec2< T > &eps)
Definition: Vec2.h:486
openvdb::v5_1::math::Vec2::unit
Vec2< T > unit(T eps=0) const
return normalized this, throws if null vector
Definition: Vec2.h:254
openvdb::v5_1::math::Vec2::operator+=
const Vec2< T > & operator+=(S scalar)
Add scalar to each element of this vector.
Definition: Vec2.h:315
openvdb::v5_1::math::Vec2::operator==
bool operator==(const Vec2< T > &v) const
Equality operator, does exact floating point comparisons.
Definition: Vec2.h:139
openvdb::v5_1::math::Vec2::operator*=
const Vec2< T > & operator*=(S scalar)
Multiply each element of this vector by scalar.
Definition: Vec2.h:279
openvdb::v5_1::math::Conversion
Dummy class for tag dispatch of conversion constructors.
Definition: Tuple.h:49
openvdb::v5_1::math::operator/
Vec2< typename promote< T0, T1 >::type > operator/(const Vec2< T0 > &v0, const Vec2< T1 > &v1)
Divide corresponding elements of v0 and v1 and return the result.
Definition: Vec2.h:427
Exceptions.h
openvdb::v5_1::math::Vec2::exp
const Vec2< T > & exp()
Definition: Vec2.h:214
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
openvdb::v5_1::math::Vec2::y
T y() const
Definition: Vec2.h:101
openvdb::v5_1::math::Vec2::dot
T dot(const Vec2< T > &v) const
Dot product.
Definition: Vec2.h:200
openvdb::v5_1::math::Vec2::asPointer
T * asPointer()
Definition: Vec2.h:109
openvdb::v5_1::ArithmeticError
Definition: Exceptions.h:83
openvdb::v5_1::math::Vec2::getArbPerpendicular
Vec2< T > getArbPerpendicular() const
Definition: Vec2.h:377
openvdb::v5_1::math::Vec2::Vec2
Vec2(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: Vec2.h:89
openvdb::v5_1::math::Vec2::unit
Vec2< T > unit(T eps, T &len) const
return normalized this and length, throws if null vector
Definition: Vec2.h:261
openvdb::v5_1::math::Vec2::sub
const Vec2< T > & sub(const Vec2< T0 > &v1, const Vec2< T1 > &v2)
Definition: Vec2.h:171
openvdb::v5_1::math::operator+
Vec2< typename promote< S, T >::type > operator+(const Vec2< T > &v, S scalar)
Add scalar to each element of the given vector and return the result.
Definition: Vec2.h:444
openvdb
Definition: Exceptions.h:40
openvdb::v5_1::math::Vec2::ones
static Vec2< T > ones()
Definition: Vec2.h:381
openvdb::v5_1::math::Vec2::lengthSqr
T lengthSqr() const
Definition: Vec2.h:210
openvdb::v5_1::math::Vec2::init
const Vec2< T > & init(T x=0, T y=0)
Definition: Vec2.h:114
openvdb::v5_1::math::minComponent
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:530
openvdb::v5_1::math::Tuple
Definition: Tuple.h:55
openvdb::v5_1::math::Vec2::scale
const Vec2< T > & scale(T0 scalar, const Vec2< T1 > &v)
Definition: Vec2.h:182
openvdb::v5_1::math::Vec2::numColumns
static unsigned numColumns()
Definition: Vec2.h:351
openvdb::v5_1::math::Exp
Vec2< T > Exp(Vec2< T > v)
Return a vector with the exponent applied to each of the components of the input vector.
Definition: Vec2.h:549
openvdb::v5_1::math::Vec2::zero
static Vec2< T > zero()
Predefined constants, e.g. Vec2f v = Vec2f::xNegAxis();.
Definition: Vec2.h:380
openvdb::v5_1::math::Vec2::log
const Vec2< T > & log()
Definition: Vec2.h:223
openvdb::v5_1::math::Vec2::eq
bool eq(const Vec2< T > &v, T eps=static_cast< T >(1.0e-7)) const
Test if "this" vector is equivalent to vector v with tolerance of eps.
Definition: Vec2.h:148
openvdb::v5_1::math::Tuple< 2, T >::mm
T mm[SIZE]
Definition: Tuple.h:197
openvdb::v5_1::tools::composite::min
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:129
openvdb::v5_1::math::Vec2::operator/=
const Vec2< T > & operator/=(const Vec2< S > &v1)
Divide each element of this vector by the corresponding element of the given vector.
Definition: Vec2.h:306
openvdb::v5_1::math::Vec2
Definition: Vec2.h:50
Tuple.h
openvdb::v5_1::math::Vec2::ValueType
T ValueType
Definition: Vec2.h:54
openvdb::v5_1::math::operator*
Vec2< typename promote< T0, T1 >::type > operator*(const Vec2< T0 > &v0, const Vec2< T1 > &v1)
Multiply corresponding elements of v0 and v1 and return the result.
Definition: Vec2.h:403
openvdb::v5_1::math::Vec2::operator!=
bool operator!=(const Vec2< T > &v) const
Inequality operator, does exact floating point comparisons.
Definition: Vec2.h:145
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
openvdb::v5_1::math::maxComponent
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
Definition: Vec2.h:539
openvdb::v5_1::math::Vec2::numElements
static unsigned numElements()
Definition: Vec2.h:352
openvdb::v5_1::math::Mat2
Definition: Vec2.h:47
openvdb::v5_1::tools::composite::max
const std::enable_if<!VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:133
openvdb::v5_1::math::Vec2::length
T length() const
Length of the vector.
Definition: Vec2.h:203
openvdb::v5_1::math::Vec2::Vec2
Vec2(T x, T y)
Constructor with two arguments, e.g. Vec2f v(1,2,3);.
Definition: Vec2.h:63
openvdb::v5_1::math::Abs
Vec2< T > Abs(const Vec2< T > &v)
Definition: Vec2.h:494
openvdb::v5_1::math::Vec2::projection
Vec2< T > projection(const Vec2< T > &onto, T eps=1.0e-8) const
Definition: Vec2.h:366
openvdb::v5_1::math::Vec2::operator-=
const Vec2< T > & operator-=(S scalar)
Subtract scalar from each element of this vector.
Definition: Vec2.h:333
openvdb::v5_1::math::orthonormalize
void orthonormalize(Vec2< T > &v1, Vec2< T > &v2)
Definition: Vec2.h:502
openvdb::v5_1::math::Vec2::operator+=
const Vec2< T > & operator+=(const Vec2< S > &v1)
Add each element of the given vector to the corresponding element of this vector. ...
Definition: Vec2.h:324