OpenVDB: Maps.h Source File

OpenVDB 6.0.0

Maps.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
32
33 #ifndef OPENVDB_MATH_MAPS_HAS_BEEN_INCLUDED
34 #define OPENVDB_MATH_MAPS_HAS_BEEN_INCLUDED
35
36 #include "Math.h"
37 #include "Mat4.h"
38 #include "Vec3.h"
39 #include "BBox.h"
40 #include "Coord.h"
41 #include <openvdb/io/io.h> // for io::getFormatVersion()
42 #include <openvdb/util/Name.h>
43 #include <openvdb/Types.h>
44 #include <cmath> // for std::abs()
45 #include <iostream>
46 #include <map>
47 #include <string>
48
49 namespace openvdb {
50 OPENVDB_USE_VERSION_NAMESPACE
51 namespace OPENVDB_VERSION_NAME {
52 namespace math {
53
54
56
58
59 class MapBase;
60 class ScaleMap;
61 class TranslationMap;
62 class ScaleTranslateMap;
63 class UniformScaleMap;
64 class UniformScaleTranslateMap;
65 class AffineMap;
66 class UnitaryMap;
67 class NonlinearFrustumMap;
68
69 template<typename T1, typename T2> class CompoundMap;
70
71 using UnitaryAndTranslationMap = CompoundMap<UnitaryMap, TranslationMap>;
72 using SpectralDecomposedMap = CompoundMap<CompoundMap<UnitaryMap, ScaleMap>, UnitaryMap>;
73 using SymmetricMap = SpectralDecomposedMap;
74 using FullyDecomposedMap = CompoundMap<SymmetricMap, UnitaryAndTranslationMap>;
75 using PolarDecomposedMap = CompoundMap<SymmetricMap, UnitaryMap>;
76
77
79
81
82 template<typename T> struct is_linear { static const bool value = false; };
83 template<> struct is_linear<AffineMap> { static const bool value = true; };
84 template<> struct is_linear<ScaleMap> { static const bool value = true; };
85 template<> struct is_linear<UniformScaleMap> { static const bool value = true; };
86 template<> struct is_linear<UnitaryMap> { static const bool value = true; };
87 template<> struct is_linear<TranslationMap> { static const bool value = true; };
88 template<> struct is_linear<ScaleTranslateMap> { static const bool value = true; };
89 template<> struct is_linear<UniformScaleTranslateMap> { static const bool value = true; };
90
91 template<typename T1, typename T2> struct is_linear<CompoundMap<T1, T2> > {
92 static const bool value = is_linear<T1>::value && is_linear<T2>::value;
93 };
94
95
96 template<typename T> struct is_uniform_scale { static const bool value = false; };
97 template<> struct is_uniform_scale<UniformScaleMap> { static const bool value = true; };
98
99 template<typename T> struct is_uniform_scale_translate { static const bool value = false; };
100 template<> struct is_uniform_scale_translate<TranslationMap> { static const bool value = true; };
101 template<> struct is_uniform_scale_translate<UniformScaleTranslateMap> {
102 static const bool value = true;
103 };
104
105
106 template<typename T> struct is_scale { static const bool value = false; };
107 template<> struct is_scale<ScaleMap> { static const bool value = true; };
108
109 template<typename T> struct is_scale_translate { static const bool value = false; };
110 template<> struct is_scale_translate<ScaleTranslateMap> { static const bool value = true; };
111
112
113 template<typename T> struct is_uniform_diagonal_jacobian {
114 static const bool value = is_uniform_scale<T>::value || is_uniform_scale_translate<T>::value;
115 };
116
117 template<typename T> struct is_diagonal_jacobian {
118 static const bool value = is_scale<T>::value || is_scale_translate<T>::value;
119 };
120
121
123
125
128 OPENVDB_API SharedPtr<SymmetricMap> createSymmetricMap(const Mat3d& m);
129
130
133 OPENVDB_API SharedPtr<FullyDecomposedMap> createFullyDecomposedMap(const Mat4d& m);
134
135
146 OPENVDB_API SharedPtr<PolarDecomposedMap> createPolarDecomposedMap(const Mat3d& m);
147
148
150 OPENVDB_API SharedPtr<MapBase> simplify(SharedPtr<AffineMap> affine);
151
154 OPENVDB_API Mat4d approxInverse(const Mat4d& mat);
155
156
158
159
161 class OPENVDB_API MapBase
162 {
163 public:
164 using Ptr = SharedPtr<MapBase>;
165 using ConstPtr = SharedPtr<const MapBase>;
166 using MapFactory = Ptr (*)();
167
168 MapBase(const MapBase&) = default;
169 virtual ~MapBase() = default;
170
171 virtual SharedPtr<AffineMap> getAffineMap() const = 0;
172
174 virtual Name type() const = 0;
175
177 template<typename MapT> bool isType() const { return this->type() == MapT::mapType(); }
178
180 virtual bool isEqual(const MapBase& other) const = 0;
181
183 virtual bool isLinear() const = 0;
185 virtual bool hasUniformScale() const = 0;
186
187 virtual Vec3d applyMap(const Vec3d& in) const = 0;
188 virtual Vec3d applyInverseMap(const Vec3d& in) const = 0;
189
191 virtual Vec3d applyIJT(const Vec3d& in) const = 0;
195 virtual Vec3d applyIJT(const Vec3d& in, const Vec3d& domainPos) const = 0;
197
198 virtual Mat3d applyIJC(const Mat3d& m) const = 0;
199 virtual Mat3d applyIJC(const Mat3d& m, const Vec3d& v, const Vec3d& domainPos) const = 0;
200
201
202 virtual double determinant() const = 0;
203 virtual double determinant(const Vec3d&) const = 0;
204
205
207 virtual Vec3d voxelSize() const = 0;
211 virtual Vec3d voxelSize(const Vec3d&) const = 0;
213
214 virtual void read(std::istream&) = 0;
215 virtual void write(std::ostream&) const = 0;
216
217 virtual std::string str() const = 0;
218
219 virtual MapBase::Ptr copy() const = 0;
220
222 virtual MapBase::Ptr preRotate(double radians, Axis axis = X_AXIS) const = 0;
224 virtual MapBase::Ptr preTranslate(const Vec3d&) const = 0;
225 virtual MapBase::Ptr preScale(const Vec3d&) const = 0;
226 virtual MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const = 0;
227
228 virtual MapBase::Ptr postRotate(double radians, Axis axis = X_AXIS) const = 0;
229 virtual MapBase::Ptr postTranslate(const Vec3d&) const = 0;
230 virtual MapBase::Ptr postScale(const Vec3d&) const = 0;
231 virtual MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const = 0;
233
235 virtual Vec3d applyJacobian(const Vec3d& in) const = 0;
241 virtual Vec3d applyJacobian(const Vec3d& in, const Vec3d& domainPos) const = 0;
243
245 virtual Vec3d applyInverseJacobian(const Vec3d& in) const = 0;
251 virtual Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d& domainPos) const = 0;
253
254
256 virtual Vec3d applyJT(const Vec3d& in) const = 0;
263 virtual Vec3d applyJT(const Vec3d& in, const Vec3d& domainPos) const = 0;
265
271 virtual MapBase::Ptr inverseMap() const = 0;
272
273 protected:
274 MapBase() {}
275
276 template<typename MapT>
277 static bool isEqualBase(const MapT& self, const MapBase& other)
278 {
279 return other.isType<MapT>() && (self == *static_cast<const MapT*>(&other));
280 }
281 };
282
283
285
286
289 class OPENVDB_API MapRegistry
290 {
291 public:
292 using MapDictionary = std::map<Name, MapBase::MapFactory>;
293
294 static MapRegistry* instance();
295
297 static MapBase::Ptr createMap(const Name&);
298
300 static bool isRegistered(const Name&);
301
303 static void registerMap(const Name&, MapBase::MapFactory);
304
306 static void unregisterMap(const Name&);
307
309 static void clear();
310
311 private:
312 MapRegistry() {}
313
314 static MapRegistry* staticInstance();
315
316 static MapRegistry* mInstance;
317
318 MapDictionary mMap;
319 };
320
321
323
324
327 class OPENVDB_API AffineMap: public MapBase
328 {
329 public:
330 using Ptr = SharedPtr<AffineMap>;
331 using ConstPtr = SharedPtr<const AffineMap>;
332
333 AffineMap():
334 mMatrix(Mat4d::identity()),
335 mMatrixInv(Mat4d::identity()),
336 mJacobianInv(Mat3d::identity()),
337 mDeterminant(1),
338 mVoxelSize(Vec3d(1,1,1)),
339 mIsDiagonal(true),
340 mIsIdentity(true)
341 // the default constructor for translation is zero
342 {
343 }
344
345 AffineMap(const Mat3d& m)
346 {
347 Mat4d mat4(Mat4d::identity());
348 mat4.setMat3(m);
349 mMatrix = mat4;
350 updateAcceleration();
351 }
352
353 AffineMap(const Mat4d& m): mMatrix(m)
354 {
355 if (!isAffine(m)) {
356 OPENVDB_THROW(ArithmeticError,
357 "Tried to initialize an affine transform from a non-affine 4x4 matrix");
358 }
359 updateAcceleration();
360 }
361
362 AffineMap(const AffineMap& other):
363 MapBase(other),
364 mMatrix(other.mMatrix),
365 mMatrixInv(other.mMatrixInv),
366 mJacobianInv(other.mJacobianInv),
367 mDeterminant(other.mDeterminant),
368 mVoxelSize(other.mVoxelSize),
369 mIsDiagonal(other.mIsDiagonal),
370 mIsIdentity(other.mIsIdentity)
371 {
372 }
373
375 AffineMap(const AffineMap& first, const AffineMap& second):
376 mMatrix(first.mMatrix * second.mMatrix)
377 {
378 updateAcceleration();
379 }
380
381 ~AffineMap() override = default;
382
384 static MapBase::Ptr create() { return MapBase::Ptr(new AffineMap()); }
386 MapBase::Ptr copy() const override { return MapBase::Ptr(new AffineMap(*this)); }
387
388 MapBase::Ptr inverseMap() const override { return MapBase::Ptr(new AffineMap(mMatrixInv)); }
389
390 static bool isRegistered() { return MapRegistry::isRegistered(AffineMap::mapType()); }
391
392 static void registerMap()
393 {
394 MapRegistry::registerMap(
395 AffineMap::mapType(),
396 AffineMap::create);
397 }
398
399 Name type() const override { return mapType(); }
400 static Name mapType() { return Name("AffineMap"); }
401
403 bool isLinear() const override { return true; }
404
406 bool hasUniformScale() const override
407 {
408 Mat3d mat = mMatrix.getMat3();
409 const double det = mat.det();
410 if (isApproxEqual(det, double(0))) {
411 return false;
412 } else {
413 mat *= (1.0 / pow(std::abs(det), 1.0/3.0));
414 return isUnitary(mat);
415 }
416 }
417
418 bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
419
420 bool operator==(const AffineMap& other) const
421 {
422 // the Mat.eq() is approximate
423 if (!mMatrix.eq(other.mMatrix)) { return false; }
424 if (!mMatrixInv.eq(other.mMatrixInv)) { return false; }
425 return true;
426 }
427
428 bool operator!=(const AffineMap& other) const { return !(*this == other); }
429
430 AffineMap& operator=(const AffineMap& other)
431 {
432 mMatrix = other.mMatrix;
433 mMatrixInv = other.mMatrixInv;
434
435 mJacobianInv = other.mJacobianInv;
436 mDeterminant = other.mDeterminant;
437 mVoxelSize = other.mVoxelSize;
438 mIsDiagonal = other.mIsDiagonal;
439 mIsIdentity = other.mIsIdentity;
440 return *this;
441 }
443 Vec3d applyMap(const Vec3d& in) const override { return in * mMatrix; }
445 Vec3d applyInverseMap(const Vec3d& in) const override {return in * mMatrixInv; }
446
448 Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const override { return applyJacobian(in); }
450 Vec3d applyJacobian(const Vec3d& in) const override { return mMatrix.transform3x3(in); }
451
454 Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const override {
455 return applyInverseJacobian(in);
456 }
459 Vec3d applyInverseJacobian(const Vec3d& in) const override {
460 return mMatrixInv.transform3x3(in);
461 }
462
465 Vec3d applyJT(const Vec3d& in, const Vec3d&) const override { return applyJT(in); }
467 Vec3d applyJT(const Vec3d& in) const override {
468 const double* m = mMatrix.asPointer();
469 return Vec3d( m[ 0] * in[0] + m[ 1] * in[1] + m[ 2] * in[2],
470 m[ 4] * in[0] + m[ 5] * in[1] + m[ 6] * in[2],
471 m[ 8] * in[0] + m[ 9] * in[1] + m[10] * in[2] );
472 }
473
475 Vec3d applyIJT(const Vec3d& in, const Vec3d&) const override { return applyIJT(in); }
477 Vec3d applyIJT(const Vec3d& in) const override { return in * mJacobianInv; }
479 Mat3d applyIJC(const Mat3d& m) const override {
480 return mJacobianInv.transpose()* m * mJacobianInv;
481 }
482 Mat3d applyIJC(const Mat3d& in, const Vec3d& , const Vec3d& ) const override {
483 return applyIJC(in);
484 }
486 double determinant(const Vec3d& ) const override { return determinant(); }
488 double determinant() const override { return mDeterminant; }
489
491 Vec3d voxelSize() const override { return mVoxelSize; }
494 Vec3d voxelSize(const Vec3d&) const override { return voxelSize(); }
496
498 bool isIdentity() const { return mIsIdentity; }
500 bool isDiagonal() const { return mIsDiagonal; }
502 bool isScale() const { return isDiagonal(); }
504 bool isScaleTranslate() const { return math::isDiagonal(mMatrix.getMat3()); }
505
506
507 // Methods that modify the existing affine map
508
510 void accumPreRotation(Axis axis, double radians)
512 {
513 mMatrix.preRotate(axis, radians);
514 updateAcceleration();
515 }
516 void accumPreScale(const Vec3d& v)
517 {
518 mMatrix.preScale(v);
519 updateAcceleration();
520 }
521 void accumPreTranslation(const Vec3d& v)
522 {
523 mMatrix.preTranslate(v);
524 updateAcceleration();
525 }
526 void accumPreShear(Axis axis0, Axis axis1, double shear)
527 {
528 mMatrix.preShear(axis0, axis1, shear);
529 updateAcceleration();
530 }
532
533
535 void accumPostRotation(Axis axis, double radians)
537 {
538 mMatrix.postRotate(axis, radians);
539 updateAcceleration();
540 }
541 void accumPostScale(const Vec3d& v)
542 {
543 mMatrix.postScale(v);
544 updateAcceleration();
545 }
546 void accumPostTranslation(const Vec3d& v)
547 {
548 mMatrix.postTranslate(v);
549 updateAcceleration();
550 }
551 void accumPostShear(Axis axis0, Axis axis1, double shear)
552 {
553 mMatrix.postShear(axis0, axis1, shear);
554 updateAcceleration();
555 }
557
558
560 void read(std::istream& is) override { mMatrix.read(is); updateAcceleration(); }
562 void write(std::ostream& os) const override { mMatrix.write(os); }
564 std::string str() const override
565 {
566 std::ostringstream buffer;
567 buffer << " - mat4:\n" << mMatrix.str() << std::endl;
568 buffer << " - voxel dimensions: " << mVoxelSize << std::endl;
569 return buffer.str();
570 }
571
573 SharedPtr<FullyDecomposedMap> createDecomposedMap()
574 {
575 return createFullyDecomposedMap(mMatrix);
576 }
577
579 AffineMap::Ptr getAffineMap() const override { return AffineMap::Ptr(new AffineMap(*this)); }
580
582 AffineMap::Ptr inverse() const { return AffineMap::Ptr(new AffineMap(mMatrixInv)); }
583
584
586 MapBase::Ptr preRotate(double radians, Axis axis = X_AXIS) const override
589 {
590 AffineMap::Ptr affineMap = getAffineMap();
591 affineMap->accumPreRotation(axis, radians);
592 return simplify(affineMap);
593 }
594 MapBase::Ptr preTranslate(const Vec3d& t) const override
595 {
596 AffineMap::Ptr affineMap = getAffineMap();
597 affineMap->accumPreTranslation(t);
598 return StaticPtrCast<MapBase, AffineMap>(affineMap);
599 }
600 MapBase::Ptr preScale(const Vec3d& s) const override
601 {
602 AffineMap::Ptr affineMap = getAffineMap();
603 affineMap->accumPreScale(s);
604 return StaticPtrCast<MapBase, AffineMap>(affineMap);
605 }
606 MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
607 {
608 AffineMap::Ptr affineMap = getAffineMap();
609 affineMap->accumPreShear(axis0, axis1, shear);
610 return simplify(affineMap);
611 }
613
614
616 MapBase::Ptr postRotate(double radians, Axis axis = X_AXIS) const override
619 {
620 AffineMap::Ptr affineMap = getAffineMap();
621 affineMap->accumPostRotation(axis, radians);
622 return simplify(affineMap);
623 }
624 MapBase::Ptr postTranslate(const Vec3d& t) const override
625 {
626 AffineMap::Ptr affineMap = getAffineMap();
627 affineMap->accumPostTranslation(t);
628 return StaticPtrCast<MapBase, AffineMap>(affineMap);
629 }
630 MapBase::Ptr postScale(const Vec3d& s) const override
631 {
632 AffineMap::Ptr affineMap = getAffineMap();
633 affineMap->accumPostScale(s);
634 return StaticPtrCast<MapBase, AffineMap>(affineMap);
635 }
636 MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
637 {
638 AffineMap::Ptr affineMap = getAffineMap();
639 affineMap->accumPostShear(axis0, axis1, shear);
640 return simplify(affineMap);
641 }
643
645 Mat4d getMat4() const { return mMatrix;}
646 const Mat4d& getConstMat4() const {return mMatrix;}
647 const Mat3d& getConstJacobianInv() const {return mJacobianInv;}
648
649 private:
650 void updateAcceleration() {
651 Mat3d mat3 = mMatrix.getMat3();
652 mDeterminant = mat3.det();
653
654 if (std::abs(mDeterminant) < (3.0 * math::Tolerance<double>::value())) {
655 OPENVDB_THROW(ArithmeticError,
656 "Tried to initialize an affine transform from a nearly singular matrix");
657 }
658 mMatrixInv = mMatrix.inverse();
659 mJacobianInv = mat3.inverse().transpose();
660 mIsDiagonal = math::isDiagonal(mMatrix);
661 mIsIdentity = math::isIdentity(mMatrix);
662 Vec3d pos = applyMap(Vec3d(0,0,0));
663 mVoxelSize(0) = (applyMap(Vec3d(1,0,0)) - pos).length();
664 mVoxelSize(1) = (applyMap(Vec3d(0,1,0)) - pos).length();
665 mVoxelSize(2) = (applyMap(Vec3d(0,0,1)) - pos).length();
666 }
667
668 // the underlying matrix
669 Mat4d mMatrix;
670
671 // stored for acceleration
672 Mat4d mMatrixInv;
673 Mat3d mJacobianInv;
674 double mDeterminant;
675 Vec3d mVoxelSize;
676 bool mIsDiagonal, mIsIdentity;
677 }; // class AffineMap
678
679
681
682
685 class OPENVDB_API ScaleMap: public MapBase
686 {
687 public:
688 using Ptr = SharedPtr<ScaleMap>;
689 using ConstPtr = SharedPtr<const ScaleMap>;
690
691 ScaleMap(): MapBase(), mScaleValues(Vec3d(1,1,1)), mVoxelSize(Vec3d(1,1,1)),
692 mScaleValuesInverse(Vec3d(1,1,1)),
693 mInvScaleSqr(1,1,1), mInvTwiceScale(0.5,0.5,0.5){}
694
695 ScaleMap(const Vec3d& scale):
696 MapBase(),
697 mScaleValues(scale),
698 mVoxelSize(Vec3d(std::abs(scale(0)),std::abs(scale(1)), std::abs(scale(2))))
699 {
700 double determinant = scale[0]* scale[1] * scale[2];
701 if (std::abs(determinant) < 3.0 * math::Tolerance<double>::value()) {
702 OPENVDB_THROW(ArithmeticError, "Non-zero scale values required");
703 }
704 mScaleValuesInverse = 1.0 / mScaleValues;
705 mInvScaleSqr = mScaleValuesInverse * mScaleValuesInverse;
706 mInvTwiceScale = mScaleValuesInverse / 2;
707 }
708
709 ScaleMap(const ScaleMap& other):
710 MapBase(),
711 mScaleValues(other.mScaleValues),
712 mVoxelSize(other.mVoxelSize),
713 mScaleValuesInverse(other.mScaleValuesInverse),
714 mInvScaleSqr(other.mInvScaleSqr),
715 mInvTwiceScale(other.mInvTwiceScale)
716 {
717 }
718
719 ~ScaleMap() override = default;
720
722 static MapBase::Ptr create() { return MapBase::Ptr(new ScaleMap()); }
724 MapBase::Ptr copy() const override { return MapBase::Ptr(new ScaleMap(*this)); }
725
726 MapBase::Ptr inverseMap() const override {
727 return MapBase::Ptr(new ScaleMap(mScaleValuesInverse));
728 }
729
730 static bool isRegistered() { return MapRegistry::isRegistered(ScaleMap::mapType()); }
731
732 static void registerMap()
733 {
734 MapRegistry::registerMap(
735 ScaleMap::mapType(),
736 ScaleMap::create);
737 }
738
739 Name type() const override { return mapType(); }
740 static Name mapType() { return Name("ScaleMap"); }
741
743 bool isLinear() const override { return true; }
744
746 bool hasUniformScale() const override
747 {
748 bool value = isApproxEqual(
749 std::abs(mScaleValues.x()), std::abs(mScaleValues.y()), double(5e-7));
750 value = value && isApproxEqual(
751 std::abs(mScaleValues.x()), std::abs(mScaleValues.z()), double(5e-7));
752 return value;
753 }
754
756 Vec3d applyMap(const Vec3d& in) const override
757 {
758 return Vec3d(
759 in.x() * mScaleValues.x(),
760 in.y() * mScaleValues.y(),
761 in.z() * mScaleValues.z());
762 }
764 Vec3d applyInverseMap(const Vec3d& in) const override
765 {
766 return Vec3d(
767 in.x() * mScaleValuesInverse.x(),
768 in.y() * mScaleValuesInverse.y(),
769 in.z() * mScaleValuesInverse.z());
770 }
772 Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const override { return applyJacobian(in); }
774 Vec3d applyJacobian(const Vec3d& in) const override { return applyMap(in); }
775
778 Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const override {
779 return applyInverseJacobian(in);
780 }
783 Vec3d applyInverseJacobian(const Vec3d& in) const override { return applyInverseMap(in); }
784
787 Vec3d applyJT(const Vec3d& in, const Vec3d&) const override { return applyJT(in); }
789 Vec3d applyJT(const Vec3d& in) const override { return applyMap(in); }
790
793 Vec3d applyIJT(const Vec3d& in, const Vec3d&) const override { return applyIJT(in);}
795 Vec3d applyIJT(const Vec3d& in) const override { return applyInverseMap(in); }
797 Mat3d applyIJC(const Mat3d& in) const override
798 {
799 Mat3d tmp;
800 for (int i = 0; i < 3; i++) {
801 tmp.setRow(i, in.row(i) * mScaleValuesInverse(i));
802 }
803 for (int i = 0; i < 3; i++) {
804 tmp.setCol(i, tmp.col(i) * mScaleValuesInverse(i));
805 }
806 return tmp;
807 }
808 Mat3d applyIJC(const Mat3d& in, const Vec3d&, const Vec3d&) const override {
809 return applyIJC(in);
810 }
812 double determinant(const Vec3d&) const override { return determinant(); }
814 double determinant() const override {
815 return mScaleValues.x() * mScaleValues.y() * mScaleValues.z();
816 }
817
819 const Vec3d& getScale() const {return mScaleValues;}
820
822 const Vec3d& getInvScaleSqr() const { return mInvScaleSqr; }
824 const Vec3d& getInvTwiceScale() const { return mInvTwiceScale; }
826 const Vec3d& getInvScale() const { return mScaleValuesInverse; }
827
829 Vec3d voxelSize() const override { return mVoxelSize; }
833 Vec3d voxelSize(const Vec3d&) const override { return voxelSize(); }
835
837 void read(std::istream& is) override
838 {
839 mScaleValues.read(is);
840 mVoxelSize.read(is);
841 mScaleValuesInverse.read(is);
842 mInvScaleSqr.read(is);
843 mInvTwiceScale.read(is);
844 }
846 void write(std::ostream& os) const override
847 {
848 mScaleValues.write(os);
849 mVoxelSize.write(os);
850 mScaleValuesInverse.write(os);
851 mInvScaleSqr.write(os);
852 mInvTwiceScale.write(os);
853 }
855 std::string str() const override
856 {
857 std::ostringstream buffer;
858 buffer << " - scale: " << mScaleValues << std::endl;
859 buffer << " - voxel dimensions: " << mVoxelSize << std::endl;
860 return buffer.str();
861 }
862
863 bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
864
865 bool operator==(const ScaleMap& other) const
866 {
867 // ::eq() uses a tolerance
868 if (!mScaleValues.eq(other.mScaleValues)) { return false; }
869 return true;
870 }
871
872 bool operator!=(const ScaleMap& other) const { return !(*this == other); }
873
875 AffineMap::Ptr getAffineMap() const override
876 {
877 return AffineMap::Ptr(new AffineMap(math::scale<Mat4d>(mScaleValues)));
878 }
879
880
881
883 MapBase::Ptr preRotate(double radians, Axis axis) const override
886 {
887 AffineMap::Ptr affineMap = getAffineMap();
888 affineMap->accumPreRotation(axis, radians);
889 return simplify(affineMap);
890 }
891
892 MapBase::Ptr preTranslate(const Vec3d&) const override;
893 MapBase::Ptr preScale(const Vec3d&) const override;
894 MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
895 {
896 AffineMap::Ptr affineMap = getAffineMap();
897 affineMap->accumPreShear(axis0, axis1, shear);
898 return simplify(affineMap);
899 }
901
902
904 MapBase::Ptr postRotate(double radians, Axis axis) const override
907 {
908 AffineMap::Ptr affineMap = getAffineMap();
909 affineMap->accumPostRotation(axis, radians);
910 return simplify(affineMap);
911 }
912 MapBase::Ptr postTranslate(const Vec3d&) const override;
913 MapBase::Ptr postScale(const Vec3d&) const override;
914 MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
915 {
916 AffineMap::Ptr affineMap = getAffineMap();
917 affineMap->accumPostShear(axis0, axis1, shear);
918 return simplify(affineMap);
919 }
921
922 private:
923 Vec3d mScaleValues, mVoxelSize, mScaleValuesInverse, mInvScaleSqr, mInvTwiceScale;
924 }; // class ScaleMap
925
926
929 class OPENVDB_API UniformScaleMap: public ScaleMap
930 {
931 public:
932 using Ptr = SharedPtr<UniformScaleMap>;
933 using ConstPtr = SharedPtr<const UniformScaleMap>;
934
935 UniformScaleMap(): ScaleMap(Vec3d(1,1,1)) {}
936 UniformScaleMap(double scale): ScaleMap(Vec3d(scale, scale, scale)) {}
937 UniformScaleMap(const UniformScaleMap& other): ScaleMap(other) {}
938 ~UniformScaleMap() override = default;
939
941 static MapBase::Ptr create() { return MapBase::Ptr(new UniformScaleMap()); }
943 MapBase::Ptr copy() const override { return MapBase::Ptr(new UniformScaleMap(*this)); }
944
945 MapBase::Ptr inverseMap() const override
946 {
947 const Vec3d& invScale = getInvScale();
948 return MapBase::Ptr(new UniformScaleMap( invScale[0]));
949 }
950
951 static bool isRegistered() { return MapRegistry::isRegistered(UniformScaleMap::mapType()); }
952 static void registerMap()
953 {
954 MapRegistry::registerMap(
955 UniformScaleMap::mapType(),
956 UniformScaleMap::create);
957 }
958
959 Name type() const override { return mapType(); }
960 static Name mapType() { return Name("UniformScaleMap"); }
961
962 bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
963
964 bool operator==(const UniformScaleMap& other) const { return ScaleMap::operator==(other); }
965 bool operator!=(const UniformScaleMap& other) const { return !(*this == other); }
966
969 MapBase::Ptr preTranslate(const Vec3d&) const override;
970
973 MapBase::Ptr postTranslate(const Vec3d&) const override;
974
975 }; // class UniformScaleMap
976
977
979
980
981 inline MapBase::Ptr
982 ScaleMap::preScale(const Vec3d& v) const
983 {
984 const Vec3d new_scale(v * mScaleValues);
985 if (isApproxEqual(new_scale[0],new_scale[1]) && isApproxEqual(new_scale[0],new_scale[2])) {
986 return MapBase::Ptr(new UniformScaleMap(new_scale[0]));
987 } else {
988 return MapBase::Ptr(new ScaleMap(new_scale));
989 }
990 }
991
992
993 inline MapBase::Ptr
994 ScaleMap::postScale(const Vec3d& v) const
995 { // pre-post Scale are the same for a scale map
996 return preScale(v);
997 }
998
999
1001 class OPENVDB_API TranslationMap: public MapBase
1002 {
1003 public:
1004 using Ptr = SharedPtr<TranslationMap>;
1005 using ConstPtr = SharedPtr<const TranslationMap>;
1006
1007 // default constructor is a translation by zero.
1008 TranslationMap(): MapBase(), mTranslation(Vec3d(0,0,0)) {}
1009 TranslationMap(const Vec3d& t): MapBase(), mTranslation(t) {}
1010 TranslationMap(const TranslationMap& other): MapBase(), mTranslation(other.mTranslation) {}
1011
1012 ~TranslationMap() override = default;
1013
1015 static MapBase::Ptr create() { return MapBase::Ptr(new TranslationMap()); }
1017 MapBase::Ptr copy() const override { return MapBase::Ptr(new TranslationMap(*this)); }
1018
1019 MapBase::Ptr inverseMap() const override {
1020 return MapBase::Ptr(new TranslationMap(-mTranslation));
1021 }
1022
1023 static bool isRegistered() { return MapRegistry::isRegistered(TranslationMap::mapType()); }
1024
1025 static void registerMap()
1026 {
1027 MapRegistry::registerMap(
1028 TranslationMap::mapType(),
1029 TranslationMap::create);
1030 }
1031
1032 Name type() const override { return mapType(); }
1033 static Name mapType() { return Name("TranslationMap"); }
1034
1036 bool isLinear() const override { return true; }
1037
1039 bool hasUniformScale() const override { return true; }
1040
1042 Vec3d applyMap(const Vec3d& in) const override { return in + mTranslation; }
1044 Vec3d applyInverseMap(const Vec3d& in) const override { return in - mTranslation; }
1046 Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const override { return applyJacobian(in); }
1048 Vec3d applyJacobian(const Vec3d& in) const override { return in; }
1049
1052 Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const override {
1053 return applyInverseJacobian(in);
1054 }
1057 Vec3d applyInverseJacobian(const Vec3d& in) const override { return in; }
1058
1059
1062 Vec3d applyJT(const Vec3d& in, const Vec3d&) const override { return applyJT(in); }
1064 Vec3d applyJT(const Vec3d& in) const override { return in; }
1065
1068 Vec3d applyIJT(const Vec3d& in, const Vec3d& ) const override { return applyIJT(in);}
1071 Vec3d applyIJT(const Vec3d& in) const override {return in;}
1073 Mat3d applyIJC(const Mat3d& mat) const override {return mat;}
1074 Mat3d applyIJC(const Mat3d& mat, const Vec3d&, const Vec3d&) const override {
1075 return applyIJC(mat);
1076 }
1077
1079 double determinant(const Vec3d& ) const override { return determinant(); }
1081 double determinant() const override { return 1.0; }
1082
1084 Vec3d voxelSize() const override { return Vec3d(1,1,1);}
1086 Vec3d voxelSize(const Vec3d&) const override { return voxelSize();}
1087
1089 const Vec3d& getTranslation() const { return mTranslation; }
1090
1092 void read(std::istream& is) override { mTranslation.read(is); }
1094 void write(std::ostream& os) const override { mTranslation.write(os); }
1096 std::string str() const override
1097 {
1098 std::ostringstream buffer;
1099 buffer << " - translation: " << mTranslation << std::endl;
1100 return buffer.str();
1101 }
1102
1103 bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
1104
1105 bool operator==(const TranslationMap& other) const
1106 {
1107 // ::eq() uses a tolerance
1108 return mTranslation.eq(other.mTranslation);
1109 }
1110
1111 bool operator!=(const TranslationMap& other) const { return !(*this == other); }
1112
1114 AffineMap::Ptr getAffineMap() const override
1115 {
1116 Mat4d matrix(Mat4d::identity());
1117 matrix.setTranslation(mTranslation);
1118
1119 AffineMap::Ptr affineMap(new AffineMap(matrix));
1120 return affineMap;
1121 }
1122
1124 MapBase::Ptr preRotate(double radians, Axis axis) const override
1127 {
1128 AffineMap::Ptr affineMap = getAffineMap();
1129 affineMap->accumPreRotation(axis, radians);
1130 return simplify(affineMap);
1131
1132 }
1133 MapBase::Ptr preTranslate(const Vec3d& t) const override
1134 {
1135 return MapBase::Ptr(new TranslationMap(t + mTranslation));
1136 }
1137
1138 MapBase::Ptr preScale(const Vec3d& v) const override;
1139
1140 MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
1141 {
1142 AffineMap::Ptr affineMap = getAffineMap();
1143 affineMap->accumPreShear(axis0, axis1, shear);
1144 return simplify(affineMap);
1145 }
1147
1149 MapBase::Ptr postRotate(double radians, Axis axis) const override
1152 {
1153 AffineMap::Ptr affineMap = getAffineMap();
1154 affineMap->accumPostRotation(axis, radians);
1155 return simplify(affineMap);
1156
1157 }
1158 MapBase::Ptr postTranslate(const Vec3d& t) const override
1159 { // post and pre are the same for this
1160 return MapBase::Ptr(new TranslationMap(t + mTranslation));
1161 }
1162
1163 MapBase::Ptr postScale(const Vec3d& v) const override;
1164
1165 MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
1166 {
1167 AffineMap::Ptr affineMap = getAffineMap();
1168 affineMap->accumPostShear(axis0, axis1, shear);
1169 return simplify(affineMap);
1170 }
1172
1173 private:
1174 Vec3d mTranslation;
1175 }; // class TranslationMap
1176
1177
1179
1180
1184 class OPENVDB_API ScaleTranslateMap: public MapBase
1185 {
1186 public:
1187 using Ptr = SharedPtr<ScaleTranslateMap>;
1188 using ConstPtr = SharedPtr<const ScaleTranslateMap>;
1189
1190 ScaleTranslateMap():
1191 MapBase(),
1192 mTranslation(Vec3d(0,0,0)),
1193 mScaleValues(Vec3d(1,1,1)),
1194 mVoxelSize(Vec3d(1,1,1)),
1195 mScaleValuesInverse(Vec3d(1,1,1)),
1196 mInvScaleSqr(1,1,1),
1197 mInvTwiceScale(0.5,0.5,0.5)
1198 {
1199 }
1200
1201 ScaleTranslateMap(const Vec3d& scale, const Vec3d& translate):
1202 MapBase(),
1203 mTranslation(translate),
1204 mScaleValues(scale),
1205 mVoxelSize(std::abs(scale(0)), std::abs(scale(1)), std::abs(scale(2)))
1206 {
1207 const double determinant = scale[0]* scale[1] * scale[2];
1208 if (std::abs(determinant) < 3.0 * math::Tolerance<double>::value()) {
1209 OPENVDB_THROW(ArithmeticError, "Non-zero scale values required");
1210 }
1211 mScaleValuesInverse = 1.0 / mScaleValues;
1212 mInvScaleSqr = mScaleValuesInverse * mScaleValuesInverse;
1213 mInvTwiceScale = mScaleValuesInverse / 2;
1214 }
1215
1216 ScaleTranslateMap(const ScaleMap& scale, const TranslationMap& translate):
1217 MapBase(),
1218 mTranslation(translate.getTranslation()),
1219 mScaleValues(scale.getScale()),
1220 mVoxelSize(std::abs(mScaleValues(0)),
1221 std::abs(mScaleValues(1)),
1222 std::abs(mScaleValues(2))),
1223 mScaleValuesInverse(1.0 / scale.getScale())
1224 {
1225 mInvScaleSqr = mScaleValuesInverse * mScaleValuesInverse;
1226 mInvTwiceScale = mScaleValuesInverse / 2;
1227 }
1228
1229 ScaleTranslateMap(const ScaleTranslateMap& other):
1230 MapBase(),
1231 mTranslation(other.mTranslation),
1232 mScaleValues(other.mScaleValues),
1233 mVoxelSize(other.mVoxelSize),
1234 mScaleValuesInverse(other.mScaleValuesInverse),
1235 mInvScaleSqr(other.mInvScaleSqr),
1236 mInvTwiceScale(other.mInvTwiceScale)
1237 {}
1238
1239 ~ScaleTranslateMap() override = default;
1240
1242 static MapBase::Ptr create() { return MapBase::Ptr(new ScaleTranslateMap()); }
1244 MapBase::Ptr copy() const override { return MapBase::Ptr(new ScaleTranslateMap(*this)); }
1245
1246 MapBase::Ptr inverseMap() const override
1247 {
1248 return MapBase::Ptr(new ScaleTranslateMap(
1249 mScaleValuesInverse, -mScaleValuesInverse * mTranslation));
1250 }
1251
1252 static bool isRegistered() { return MapRegistry::isRegistered(ScaleTranslateMap::mapType()); }
1253
1254 static void registerMap()
1255 {
1256 MapRegistry::registerMap(
1257 ScaleTranslateMap::mapType(),
1258 ScaleTranslateMap::create);
1259 }
1260
1261 Name type() const override { return mapType(); }
1262 static Name mapType() { return Name("ScaleTranslateMap"); }
1263
1265 bool isLinear() const override { return true; }
1266
1269 bool hasUniformScale() const override
1270 {
1271 bool value = isApproxEqual(
1272 std::abs(mScaleValues.x()), std::abs(mScaleValues.y()), double(5e-7));
1273 value = value && isApproxEqual(
1274 std::abs(mScaleValues.x()), std::abs(mScaleValues.z()), double(5e-7));
1275 return value;
1276 }
1277
1279 Vec3d applyMap(const Vec3d& in) const override
1280 {
1281 return Vec3d(
1282 in.x() * mScaleValues.x() + mTranslation.x(),
1283 in.y() * mScaleValues.y() + mTranslation.y(),
1284 in.z() * mScaleValues.z() + mTranslation.z());
1285 }
1287 Vec3d applyInverseMap(const Vec3d& in) const override
1288 {
1289 return Vec3d(
1290 (in.x() - mTranslation.x() ) * mScaleValuesInverse.x(),
1291 (in.y() - mTranslation.y() ) * mScaleValuesInverse.y(),
1292 (in.z() - mTranslation.z() ) * mScaleValuesInverse.z());
1293 }
1294
1296 Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const override { return applyJacobian(in); }
1298 Vec3d applyJacobian(const Vec3d& in) const override { return in * mScaleValues; }
1299
1302 Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const override { return applyInverseJacobian(in); }
1305 Vec3d applyInverseJacobian(const Vec3d& in) const override { return in * mScaleValuesInverse; }
1306
1309 Vec3d applyJT(const Vec3d& in, const Vec3d&) const override { return applyJT(in); }
1311 Vec3d applyJT(const Vec3d& in) const override { return applyJacobian(in); }
1312
1315 Vec3d applyIJT(const Vec3d& in, const Vec3d&) const override { return applyIJT(in);}
1317 Vec3d applyIJT(const Vec3d& in) const override
1318 {
1319 return Vec3d(
1320 in.x() * mScaleValuesInverse.x(),
1321 in.y() * mScaleValuesInverse.y(),
1322 in.z() * mScaleValuesInverse.z());
1323 }
1325 Mat3d applyIJC(const Mat3d& in) const override
1326 {
1327 Mat3d tmp;
1328 for (int i=0; i<3; i++){
1329 tmp.setRow(i, in.row(i)*mScaleValuesInverse(i));
1330 }
1331 for (int i=0; i<3; i++){
1332 tmp.setCol(i, tmp.col(i)*mScaleValuesInverse(i));
1333 }
1334 return tmp;
1335 }
1336 Mat3d applyIJC(const Mat3d& in, const Vec3d&, const Vec3d& ) const override {
1337 return applyIJC(in);
1338 }
1339
1341 double determinant(const Vec3d&) const override { return determinant(); }
1343 double determinant() const override {
1344 return mScaleValues.x() * mScaleValues.y() * mScaleValues.z();
1345 }
1347 Vec3d voxelSize() const override { return mVoxelSize;}
1349 Vec3d voxelSize(const Vec3d&) const override { return voxelSize();}
1350
1352 const Vec3d& getScale() const { return mScaleValues; }
1354 const Vec3d& getTranslation() const { return mTranslation; }
1355
1357 const Vec3d& getInvScaleSqr() const {return mInvScaleSqr;}
1359 const Vec3d& getInvTwiceScale() const {return mInvTwiceScale;}
1361 const Vec3d& getInvScale() const {return mScaleValuesInverse; }
1362
1364 void read(std::istream& is) override
1365 {
1366 mTranslation.read(is);
1367 mScaleValues.read(is);
1368 mVoxelSize.read(is);
1369 mScaleValuesInverse.read(is);
1370 mInvScaleSqr.read(is);
1371 mInvTwiceScale.read(is);
1372 }
1374 void write(std::ostream& os) const override
1375 {
1376 mTranslation.write(os);
1377 mScaleValues.write(os);
1378 mVoxelSize.write(os);
1379 mScaleValuesInverse.write(os);
1380 mInvScaleSqr.write(os);
1381 mInvTwiceScale.write(os);
1382 }
1384 std::string str() const override
1385 {
1386 std::ostringstream buffer;
1387 buffer << " - translation: " << mTranslation << std::endl;
1388 buffer << " - scale: " << mScaleValues << std::endl;
1389 buffer << " - voxel dimensions: " << mVoxelSize << std::endl;
1390 return buffer.str();
1391 }
1392
1393 bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
1394
1395 bool operator==(const ScaleTranslateMap& other) const
1396 {
1397 // ::eq() uses a tolerance
1398 if (!mScaleValues.eq(other.mScaleValues)) { return false; }
1399 if (!mTranslation.eq(other.mTranslation)) { return false; }
1400 return true;
1401 }
1402
1403 bool operator!=(const ScaleTranslateMap& other) const { return !(*this == other); }
1404
1406 AffineMap::Ptr getAffineMap() const override
1407 {
1408 AffineMap::Ptr affineMap(new AffineMap(math::scale<Mat4d>(mScaleValues)));
1409 affineMap->accumPostTranslation(mTranslation);
1410 return affineMap;
1411 }
1412
1414 MapBase::Ptr preRotate(double radians, Axis axis) const override
1417 {
1418 AffineMap::Ptr affineMap = getAffineMap();
1419 affineMap->accumPreRotation(axis, radians);
1420 return simplify(affineMap);
1421 }
1422 MapBase::Ptr preTranslate(const Vec3d& t) const override
1423 {
1424 const Vec3d& s = mScaleValues;
1425 const Vec3d scaled_trans( t.x() * s.x(),
1426 t.y() * s.y(),
1427 t.z() * s.z() );
1428 return MapBase::Ptr( new ScaleTranslateMap(mScaleValues, mTranslation + scaled_trans));
1429 }
1430
1431 MapBase::Ptr preScale(const Vec3d& v) const override;
1432
1433 MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
1434 {
1435 AffineMap::Ptr affineMap = getAffineMap();
1436 affineMap->accumPreShear(axis0, axis1, shear);
1437 return simplify(affineMap);
1438 }
1440
1442 MapBase::Ptr postRotate(double radians, Axis axis) const override
1445 {
1446 AffineMap::Ptr affineMap = getAffineMap();
1447 affineMap->accumPostRotation(axis, radians);
1448 return simplify(affineMap);
1449 }
1450 MapBase::Ptr postTranslate(const Vec3d& t) const override
1451 {
1452 return MapBase::Ptr( new ScaleTranslateMap(mScaleValues, mTranslation + t));
1453 }
1454
1455 MapBase::Ptr postScale(const Vec3d& v) const override;
1456
1457 MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
1458 {
1459 AffineMap::Ptr affineMap = getAffineMap();
1460 affineMap->accumPostShear(axis0, axis1, shear);
1461 return simplify(affineMap);
1462 }
1464
1465 private:
1466 Vec3d mTranslation, mScaleValues, mVoxelSize, mScaleValuesInverse,
1467 mInvScaleSqr, mInvTwiceScale;
1468 }; // class ScaleTanslateMap
1469
1470
1471 inline MapBase::Ptr
1472 ScaleMap::postTranslate(const Vec3d& t) const
1473 {
1474 return MapBase::Ptr(new ScaleTranslateMap(mScaleValues, t));
1475 }
1476
1477
1478 inline MapBase::Ptr
1479 ScaleMap::preTranslate(const Vec3d& t) const
1480 {
1481
1482 const Vec3d& s = mScaleValues;
1483 const Vec3d scaled_trans( t.x() * s.x(),
1484 t.y() * s.y(),
1485 t.z() * s.z() );
1486 return MapBase::Ptr(new ScaleTranslateMap(mScaleValues, scaled_trans));
1487 }
1488
1489
1492 class OPENVDB_API UniformScaleTranslateMap: public ScaleTranslateMap
1493 {
1494 public:
1495 using Ptr = SharedPtr<UniformScaleTranslateMap>;
1496 using ConstPtr = SharedPtr<const UniformScaleTranslateMap>;
1497
1498 UniformScaleTranslateMap():ScaleTranslateMap(Vec3d(1,1,1), Vec3d(0,0,0)) {}
1499 UniformScaleTranslateMap(double scale, const Vec3d& translate):
1500 ScaleTranslateMap(Vec3d(scale,scale,scale), translate) {}
1501 UniformScaleTranslateMap(const UniformScaleMap& scale, const TranslationMap& translate):
1502 ScaleTranslateMap(scale.getScale(), translate.getTranslation()) {}
1503
1504 UniformScaleTranslateMap(const UniformScaleTranslateMap& other):ScaleTranslateMap(other) {}
1505 ~UniformScaleTranslateMap() override = default;
1506
1508 static MapBase::Ptr create() { return MapBase::Ptr(new UniformScaleTranslateMap()); }
1510 MapBase::Ptr copy() const override { return MapBase::Ptr(new UniformScaleTranslateMap(*this)); }
1511
1512 MapBase::Ptr inverseMap() const override
1513 {
1514 const Vec3d& scaleInv = getInvScale();
1515 const Vec3d& trans = getTranslation();
1516 return MapBase::Ptr(new UniformScaleTranslateMap(scaleInv[0], -scaleInv[0] * trans));
1517 }
1518
1519 static bool isRegistered()
1520 {
1521 return MapRegistry::isRegistered(UniformScaleTranslateMap::mapType());
1522 }
1523
1524 static void registerMap()
1525 {
1526 MapRegistry::registerMap(
1527 UniformScaleTranslateMap::mapType(), UniformScaleTranslateMap::create);
1528 }
1529
1530 Name type() const override { return mapType(); }
1531 static Name mapType() { return Name("UniformScaleTranslateMap"); }
1532
1533 bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
1534
1535 bool operator==(const UniformScaleTranslateMap& other) const
1536 {
1537 return ScaleTranslateMap::operator==(other);
1538 }
1539 bool operator!=(const UniformScaleTranslateMap& other) const { return !(*this == other); }
1540
1543 MapBase::Ptr preTranslate(const Vec3d& t) const override
1544 {
1545 const double scale = this->getScale().x();
1546 const Vec3d new_trans = this->getTranslation() + scale * t;
1547 return MapBase::Ptr( new UniformScaleTranslateMap(scale, new_trans));
1548 }
1549
1552 MapBase::Ptr postTranslate(const Vec3d& t) const override
1553 {
1554 const double scale = this->getScale().x();
1555 return MapBase::Ptr( new UniformScaleTranslateMap(scale, this->getTranslation() + t));
1556 }
1557 }; // class UniformScaleTanslateMap
1558
1559
1560 inline MapBase::Ptr
1561 UniformScaleMap::postTranslate(const Vec3d& t) const
1562 {
1563 const double scale = this->getScale().x();
1564 return MapBase::Ptr(new UniformScaleTranslateMap(scale, t));
1565 }
1566
1567
1568 inline MapBase::Ptr
1569 UniformScaleMap::preTranslate(const Vec3d& t) const
1570 {
1571 const double scale = this->getScale().x();
1572 return MapBase::Ptr(new UniformScaleTranslateMap(scale, scale*t));
1573 }
1574
1575
1576 inline MapBase::Ptr
1577 TranslationMap::preScale(const Vec3d& v) const
1578 {
1579 if (isApproxEqual(v[0],v[1]) && isApproxEqual(v[0],v[2])) {
1580 return MapBase::Ptr(new UniformScaleTranslateMap(v[0], mTranslation));
1581 } else {
1582 return MapBase::Ptr(new ScaleTranslateMap(v, mTranslation));
1583 }
1584 }
1585
1586
1587 inline MapBase::Ptr
1588 TranslationMap::postScale(const Vec3d& v) const
1589 {
1590 if (isApproxEqual(v[0],v[1]) && isApproxEqual(v[0],v[2])) {
1591 return MapBase::Ptr(new UniformScaleTranslateMap(v[0], v[0]*mTranslation));
1592 } else {
1593 const Vec3d trans(mTranslation.x()*v.x(),
1594 mTranslation.y()*v.y(),
1595 mTranslation.z()*v.z());
1596 return MapBase::Ptr(new ScaleTranslateMap(v, trans));
1597 }
1598 }
1599
1600
1601 inline MapBase::Ptr
1602 ScaleTranslateMap::preScale(const Vec3d& v) const
1603 {
1604 const Vec3d new_scale( v * mScaleValues );
1605 if (isApproxEqual(new_scale[0],new_scale[1]) && isApproxEqual(new_scale[0],new_scale[2])) {
1606 return MapBase::Ptr( new UniformScaleTranslateMap(new_scale[0], mTranslation));
1607 } else {
1608 return MapBase::Ptr( new ScaleTranslateMap(new_scale, mTranslation));
1609 }
1610 }
1611
1612
1613 inline MapBase::Ptr
1614 ScaleTranslateMap::postScale(const Vec3d& v) const
1615 {
1616 const Vec3d new_scale( v * mScaleValues );
1617 const Vec3d new_trans( mTranslation.x()*v.x(),
1618 mTranslation.y()*v.y(),
1619 mTranslation.z()*v.z() );
1620
1621 if (isApproxEqual(new_scale[0],new_scale[1]) && isApproxEqual(new_scale[0],new_scale[2])) {
1622 return MapBase::Ptr( new UniformScaleTranslateMap(new_scale[0], new_trans));
1623 } else {
1624 return MapBase::Ptr( new ScaleTranslateMap(new_scale, new_trans));
1625 }
1626 }
1627
1628
1630
1631
1634 class OPENVDB_API UnitaryMap: public MapBase
1635 {
1636 public:
1637 using Ptr = SharedPtr<UnitaryMap>;
1638 using ConstPtr = SharedPtr<const UnitaryMap>;
1639
1641 UnitaryMap(): mAffineMap(Mat4d::identity())
1642 {
1643 }
1644
1645 UnitaryMap(const Vec3d& axis, double radians)
1646 {
1647 Mat3d matrix;
1648 matrix.setToRotation(axis, radians);
1649 mAffineMap = AffineMap(matrix);
1650 }
1651
1652 UnitaryMap(Axis axis, double radians)
1653 {
1654 Mat4d matrix;
1655 matrix.setToRotation(axis, radians);
1656 mAffineMap = AffineMap(matrix);
1657 }
1658
1659 UnitaryMap(const Mat3d& m)
1660 {
1661 // test that the mat3 is a rotation || reflection
1662 if (!isUnitary(m)) {
1663 OPENVDB_THROW(ArithmeticError, "Matrix initializing unitary map was not unitary");
1664 }
1665
1666 Mat4d matrix(Mat4d::identity());
1667 matrix.setMat3(m);
1668 mAffineMap = AffineMap(matrix);
1669 }
1670
1671 UnitaryMap(const Mat4d& m)
1672 {
1673 if (!isInvertible(m)) {
1674 OPENVDB_THROW(ArithmeticError,
1675 "4x4 Matrix initializing unitary map was not unitary: not invertible");
1676 }
1677
1678 if (!isAffine(m)) {
1679 OPENVDB_THROW(ArithmeticError,
1680 "4x4 Matrix initializing unitary map was not unitary: not affine");
1681 }
1682
1683 if (hasTranslation(m)) {
1684 OPENVDB_THROW(ArithmeticError,
1685 "4x4 Matrix initializing unitary map was not unitary: had translation");
1686 }
1687
1688 if (!isUnitary(m.getMat3())) {
1689 OPENVDB_THROW(ArithmeticError,
1690 "4x4 Matrix initializing unitary map was not unitary");
1691 }
1692
1693 mAffineMap = AffineMap(m);
1694 }
1695
1696 UnitaryMap(const UnitaryMap& other):
1697 MapBase(other),
1698 mAffineMap(other.mAffineMap)
1699 {
1700 }
1701
1702 UnitaryMap(const UnitaryMap& first, const UnitaryMap& second):
1703 mAffineMap(*(first.getAffineMap()), *(second.getAffineMap()))
1704 {
1705 }
1706
1707 ~UnitaryMap() override = default;
1708
1710 static MapBase::Ptr create() { return MapBase::Ptr(new UnitaryMap()); }
1712 MapBase::Ptr copy() const override { return MapBase::Ptr(new UnitaryMap(*this)); }
1713
1714 MapBase::Ptr inverseMap() const override
1715 {
1716 return MapBase::Ptr(new UnitaryMap(mAffineMap.getMat4().inverse()));
1717 }
1718
1719 static bool isRegistered() { return MapRegistry::isRegistered(UnitaryMap::mapType()); }
1720
1721 static void registerMap()
1722 {
1723 MapRegistry::registerMap(
1724 UnitaryMap::mapType(),
1725 UnitaryMap::create);
1726 }
1727
1729 Name type() const override { return mapType(); }
1731 static Name mapType() { return Name("UnitaryMap"); }
1732
1734 bool isLinear() const override { return true; }
1735
1737 bool hasUniformScale() const override { return true; }
1738
1739 bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
1740
1741 bool operator==(const UnitaryMap& other) const
1742 {
1743 // compare underlying linear map.
1744 if (mAffineMap!=other.mAffineMap) return false;
1745 return true;
1746 }
1747
1748 bool operator!=(const UnitaryMap& other) const { return !(*this == other); }
1750 Vec3d applyMap(const Vec3d& in) const override { return mAffineMap.applyMap(in); }
1752 Vec3d applyInverseMap(const Vec3d& in) const override { return mAffineMap.applyInverseMap(in); }
1753
1754 Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const override { return applyJacobian(in); }
1756 Vec3d applyJacobian(const Vec3d& in) const override { return mAffineMap.applyJacobian(in); }
1757
1760 Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const override {
1761 return applyInverseJacobian(in);
1762 }
1765 Vec3d applyInverseJacobian(const Vec3d& in) const override {
1766 return mAffineMap.applyInverseJacobian(in);
1767 }
1768
1771 Vec3d applyJT(const Vec3d& in, const Vec3d&) const override { return applyJT(in); }
1773 Vec3d applyJT(const Vec3d& in) const override {
1774 return applyInverseMap(in); // the transpose of the unitary map is its inverse
1775 }
1776
1777
1780 Vec3d applyIJT(const Vec3d& in, const Vec3d& ) const override { return applyIJT(in);}
1782 Vec3d applyIJT(const Vec3d& in) const override { return mAffineMap.applyIJT(in); }
1784 Mat3d applyIJC(const Mat3d& in) const override { return mAffineMap.applyIJC(in); }
1785 Mat3d applyIJC(const Mat3d& in, const Vec3d&, const Vec3d& ) const override {
1786 return applyIJC(in);
1787 }
1788
1790 double determinant(const Vec3d&) const override { return determinant(); }
1792 double determinant() const override { return mAffineMap.determinant(); }
1793
1794
1798 Vec3d voxelSize() const override { return mAffineMap.voxelSize();}
1799 Vec3d voxelSize(const Vec3d&) const override { return voxelSize();}
1801
1803 void read(std::istream& is) override
1804 {
1805 mAffineMap.read(is);
1806 }
1807
1809 void write(std::ostream& os) const override
1810 {
1811 mAffineMap.write(os);
1812 }
1814 std::string str() const override
1815 {
1816 std::ostringstream buffer;
1817 buffer << mAffineMap.str();
1818 return buffer.str();
1819 }
1821 AffineMap::Ptr getAffineMap() const override {
1822 return AffineMap::Ptr(new AffineMap(mAffineMap));
1823 }
1824
1827 MapBase::Ptr preRotate(double radians, Axis axis) const override
1828 {
1829 UnitaryMap first(axis, radians);
1830 UnitaryMap::Ptr unitaryMap(new UnitaryMap(first, *this));
1831 return StaticPtrCast<MapBase, UnitaryMap>(unitaryMap);
1832 }
1835 MapBase::Ptr preTranslate(const Vec3d& t) const override
1836 {
1837 AffineMap::Ptr affineMap = getAffineMap();
1838 affineMap->accumPreTranslation(t);
1839 return simplify(affineMap);
1840 }
1843 MapBase::Ptr preScale(const Vec3d& v) const override
1844 {
1845 AffineMap::Ptr affineMap = getAffineMap();
1846 affineMap->accumPreScale(v);
1847 return simplify(affineMap);
1848 }
1851 MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
1852 {
1853 AffineMap::Ptr affineMap = getAffineMap();
1854 affineMap->accumPreShear(axis0, axis1, shear);
1855 return simplify(affineMap);
1856 }
1857
1860 MapBase::Ptr postRotate(double radians, Axis axis) const override
1861 {
1862 UnitaryMap second(axis, radians);
1863 UnitaryMap::Ptr unitaryMap(new UnitaryMap(*this, second));
1864 return StaticPtrCast<MapBase, UnitaryMap>(unitaryMap);
1865 }
1868 MapBase::Ptr postTranslate(const Vec3d& t) const override
1869 {
1870 AffineMap::Ptr affineMap = getAffineMap();
1871 affineMap->accumPostTranslation(t);
1872 return simplify(affineMap);
1873 }
1876 MapBase::Ptr postScale(const Vec3d& v) const override
1877 {
1878 AffineMap::Ptr affineMap = getAffineMap();
1879 affineMap->accumPostScale(v);
1880 return simplify(affineMap);
1881 }
1884 MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
1885 {
1886 AffineMap::Ptr affineMap = getAffineMap();
1887 affineMap->accumPostShear(axis0, axis1, shear);
1888 return simplify(affineMap);
1889 }
1890
1891 private:
1892 AffineMap mAffineMap;
1893 }; // class UnitaryMap
1894
1895
1897
1898
1905 class OPENVDB_API NonlinearFrustumMap: public MapBase
1906 {
1907 public:
1908 using Ptr = SharedPtr<NonlinearFrustumMap>;
1909 using ConstPtr = SharedPtr<const NonlinearFrustumMap>;
1910
1911 NonlinearFrustumMap():
1912 MapBase(),
1913 mBBox(Vec3d(0), Vec3d(1)),
1914 mTaper(1),
1915 mDepth(1)
1916 {
1917 init();
1918 }
1919
1923 NonlinearFrustumMap(const BBoxd& bb, double taper, double depth):
1924 MapBase(),mBBox(bb), mTaper(taper), mDepth(depth)
1925 {
1926 init();
1927 }
1928
1934 NonlinearFrustumMap(const BBoxd& bb, double taper, double depth,
1935 const MapBase::Ptr& secondMap):
1936 mBBox(bb), mTaper(taper), mDepth(depth)
1937 {
1938 if (!secondMap->isLinear() ) {
1939 OPENVDB_THROW(ArithmeticError,
1940 "The second map in the Frustum transfrom must be linear");
1941 }
1942 mSecondMap = *( secondMap->getAffineMap() );
1943 init();
1944 }
1945
1946 NonlinearFrustumMap(const NonlinearFrustumMap& other):
1947 MapBase(),
1948 mBBox(other.mBBox),
1949 mTaper(other.mTaper),
1950 mDepth(other.mDepth),
1951 mSecondMap(other.mSecondMap),
1952 mHasSimpleAffine(other.mHasSimpleAffine)
1953 {
1954 init();
1955 }
1956
1972 NonlinearFrustumMap(const Vec3d& position,
1973 const Vec3d& direction,
1974 const Vec3d& up,
1975 double aspect /* width / height */,
1976 double z_near, double depth,
1977 Coord::ValueType x_count, Coord::ValueType z_count) {
1978
1982 if (!(depth > 0)) {
1983 OPENVDB_THROW(ArithmeticError,
1984 "The frustum depth must be non-zero and positive");
1985 }
1986 if (!(up.length() > 0)) {
1987 OPENVDB_THROW(ArithmeticError,
1988 "The frustum height must be non-zero and positive");
1989 }
1990 if (!(aspect > 0)) {
1991 OPENVDB_THROW(ArithmeticError,
1992 "The frustum aspect ratio must be non-zero and positive");
1993 }
1994 if (!(isApproxEqual(up.dot(direction), 0.))) {
1995 OPENVDB_THROW(ArithmeticError,
1996 "The frustum up orientation must be perpendicular to into-frustum direction");
1997 }
1998
1999 double near_plane_height = 2 * up.length();
2000 double near_plane_width = aspect * near_plane_height;
2001
2002 Coord::ValueType y_count = static_cast<int>(Round(x_count / aspect));
2003
2004 mBBox = BBoxd(Vec3d(0,0,0), Vec3d(x_count, y_count, z_count));
2005 mDepth = depth / near_plane_width; // depth non-dimensionalized on width
2006 double gamma = near_plane_width / z_near;
2007 mTaper = 1./(mDepth*gamma + 1.);
2008
2009 Vec3d direction_unit = direction;
2010 direction_unit.normalize();
2011
2012 Mat4d r1(Mat4d::identity());
2013 r1.setToRotation(/*from*/Vec3d(0,0,1), /*to */direction_unit);
2014 Mat4d r2(Mat4d::identity());
2015 Vec3d temp = r1.inverse().transform(up);
2016 r2.setToRotation(/*from*/Vec3d(0,1,0), /*to*/temp );
2017 Mat4d scale = math::scale<Mat4d>(
2018 Vec3d(near_plane_width, near_plane_width, near_plane_width));
2019
2020 // move the near plane to origin, rotate to align with axis, and scale down
2021 // T_inv * R1_inv * R2_inv * scale_inv
2022 Mat4d mat = scale * r2 * r1;
2023 mat.setTranslation(position + z_near*direction_unit);
2024
2025 mSecondMap = AffineMap(mat);
2026
2027 init();
2028 }
2029
2030 ~NonlinearFrustumMap() override = default;
2031
2033 static MapBase::Ptr create() { return MapBase::Ptr(new NonlinearFrustumMap()); }
2035 MapBase::Ptr copy() const override { return MapBase::Ptr(new NonlinearFrustumMap(*this)); }
2036
2040 MapBase::Ptr inverseMap() const override
2041 {
2042 OPENVDB_THROW(NotImplementedError,
2043 "inverseMap() is not implemented for NonlinearFrustumMap");
2044 }
2045 static bool isRegistered() { return MapRegistry::isRegistered(NonlinearFrustumMap::mapType()); }
2046
2047 static void registerMap()
2048 {
2049 MapRegistry::registerMap(
2050 NonlinearFrustumMap::mapType(),
2051 NonlinearFrustumMap::create);
2052 }
2054 Name type() const override { return mapType(); }
2056 static Name mapType() { return Name("NonlinearFrustumMap"); }
2057
2059 bool isLinear() const override { return false; }
2060
2062 bool hasUniformScale() const override { return false; }
2063
2065 bool isIdentity() const
2066 {
2067 // The frustum can only be consistent with a linear map if the taper value is 1
2068 if (!isApproxEqual(mTaper, double(1)) ) return false;
2069
2070 // There are various ways an identity can decomposed between the two parts of the
2071 // map. Best to just check that the principle vectors are stationary.
2072 const Vec3d e1(1,0,0);
2073 if (!applyMap(e1).eq(e1)) return false;
2074
2075 const Vec3d e2(0,1,0);
2076 if (!applyMap(e2).eq(e2)) return false;
2077
2078 const Vec3d e3(0,0,1);
2079 if (!applyMap(e3).eq(e3)) return false;
2080
2081 return true;
2082 }
2083
2084 bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
2085
2086 bool operator==(const NonlinearFrustumMap& other) const
2087 {
2088 if (mBBox!=other.mBBox) return false;
2089 if (!isApproxEqual(mTaper, other.mTaper)) return false;
2090 if (!isApproxEqual(mDepth, other.mDepth)) return false;
2091
2092 // Two linear transforms are equivalent iff they have the same translation
2093 // and have the same affects on orthongal spanning basis check translation
2094 Vec3d e(0,0,0);
2095 if (!mSecondMap.applyMap(e).eq(other.mSecondMap.applyMap(e))) return false;
2097 e(0) = 1;
2098 if (!mSecondMap.applyMap(e).eq(other.mSecondMap.applyMap(e))) return false;
2099 e(0) = 0;
2100 e(1) = 1;
2101 if (!mSecondMap.applyMap(e).eq(other.mSecondMap.applyMap(e))) return false;
2102 e(1) = 0;
2103 e(2) = 1;
2104 if (!mSecondMap.applyMap(e).eq(other.mSecondMap.applyMap(e))) return false;
2105 return true;
2106 }
2107
2108 bool operator!=(const NonlinearFrustumMap& other) const { return !(*this == other); }
2109
2111 Vec3d applyMap(const Vec3d& in) const override
2112 {
2113 return mSecondMap.applyMap(applyFrustumMap(in));
2114 }
2115
2117 Vec3d applyInverseMap(const Vec3d& in) const override
2118 {
2119 return applyFrustumInverseMap(mSecondMap.applyInverseMap(in));
2120 }
2122 Vec3d applyJacobian(const Vec3d& in) const override { return mSecondMap.applyJacobian(in); }
2124 Vec3d applyJacobian(const Vec3d& in, const Vec3d& isloc) const override
2125 {
2126 // Move the center of the x-face of the bbox
2127 // to the origin in index space.
2128 Vec3d centered(isloc);
2129 centered = centered - mBBox.min();
2130 centered.x() -= mXo;
2131 centered.y() -= mYo;
2132
2133 // scale the z-direction on depth / K count
2134 const double zprime = centered.z()*mDepthOnLz;
2135
2136 const double scale = (mGamma * zprime + 1.) / mLx;
2137 const double scale2 = mGamma * mDepthOnLz / mLx;
2138
2139 const Vec3d tmp(scale * in.x() + scale2 * centered.x()* in.z(),
2140 scale * in.y() + scale2 * centered.y()* in.z(),
2141 mDepthOnLz * in.z());
2142
2143 return mSecondMap.applyJacobian(tmp);
2144 }
2145
2146
2149 Vec3d applyInverseJacobian(const Vec3d& in) const override {
2150 return mSecondMap.applyInverseJacobian(in);
2151 }
2153 Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d& isloc) const override {
2154
2155 // Move the center of the x-face of the bbox
2156 // to the origin in index space.
2157 Vec3d centered(isloc);
2158 centered = centered - mBBox.min();
2159 centered.x() -= mXo;
2160 centered.y() -= mYo;
2161
2162 // scale the z-direction on depth / K count
2163 const double zprime = centered.z()*mDepthOnLz;
2164
2165 const double scale = (mGamma * zprime + 1.) / mLx;
2166 const double scale2 = mGamma * mDepthOnLz / mLx;
2167
2168
2169 Vec3d out = mSecondMap.applyInverseJacobian(in);
2170
2171 out.x() = (out.x() - scale2 * centered.x() * out.z() / mDepthOnLz) / scale;
2172 out.y() = (out.y() - scale2 * centered.y() * out.z() / mDepthOnLz) / scale;
2173 out.z() = out.z() / mDepthOnLz;
2174
2175 return out;
2176 }
2177
2180 Vec3d applyJT(const Vec3d& in, const Vec3d& isloc) const override {
2181 const Vec3d tmp = mSecondMap.applyJT(in);
2182 // Move the center of the x-face of the bbox
2183 // to the origin in index space.
2184 Vec3d centered(isloc);
2185 centered = centered - mBBox.min();
2186 centered.x() -= mXo;
2187 centered.y() -= mYo;
2188
2189 // scale the z-direction on depth / K count
2190 const double zprime = centered.z()*mDepthOnLz;
2191
2192 const double scale = (mGamma * zprime + 1.) / mLx;
2193 const double scale2 = mGamma * mDepthOnLz / mLx;
2194
2195 return Vec3d(scale * tmp.x(),
2196 scale * tmp.y(),
2197 scale2 * centered.x()* tmp.x() +
2198 scale2 * centered.y()* tmp.y() +
2199 mDepthOnLz * tmp.z());
2200 }
2202 Vec3d applyJT(const Vec3d& in) const override {
2203 return mSecondMap.applyJT(in);
2204 }
2205
2207 Vec3d applyIJT(const Vec3d& in) const override { return mSecondMap.applyIJT(in); }
2208
2209 // the Jacobian of the nonlinear part of the transform is a sparse matrix
2210 // Jacobian^(-T) =
2211 //
2212 // (Lx)( 1/s 0 0 )
2213 // ( 0 1/s 0 )
2214 // ( -(x-xo)g/(sLx) -(y-yo)g/(sLx) Lz/(Depth Lx) )
2217 Vec3d applyIJT(const Vec3d& d1_is, const Vec3d& ijk) const override
2218 {
2219 const Vec3d loc = applyFrustumMap(ijk);
2220 const double s = mGamma * loc.z() + 1.;
2221
2222 // verify that we aren't at the singularity
2223 if (isApproxEqual(s, 0.)) {
2224 OPENVDB_THROW(ArithmeticError, "Tried to evaluate the frustum transform"
2225 " at the singular focal point (e.g. camera)");
2226 }
2227
2228 const double sinv = 1.0/s; // 1/(z*gamma + 1)
2229 const double pt0 = mLx * sinv; // Lx / (z*gamma +1)
2230 const double pt1 = mGamma * pt0; // gamma * Lx / ( z*gamma +1)
2231 const double pt2 = pt1 * sinv; // gamma * Lx / ( z*gamma +1)**2
2232
2233 const Mat3d& jacinv = mSecondMap.getConstJacobianInv();
2234
2235 // compute \frac{\partial E_i}{\partial x_j}
2236 Mat3d gradE(Mat3d::zero());
2237 for (int j = 0; j < 3; ++j ) {
2238 gradE(0,j) = pt0 * jacinv(0,j) - pt2 * loc.x()*jacinv(2,j);
2239 gradE(1,j) = pt0 * jacinv(1,j) - pt2 * loc.y()*jacinv(2,j);
2240 gradE(2,j) = (1./mDepthOnLz) * jacinv(2,j);
2241 }
2242
2243 Vec3d result;
2244 for (int i = 0; i < 3; ++i) {
2245 result(i) = d1_is(0) * gradE(0,i) + d1_is(1) * gradE(1,i) + d1_is(2) * gradE(2,i);
2246 }
2247
2248 return result;
2249
2250 }
2251
2253 Mat3d applyIJC(const Mat3d& in) const override { return mSecondMap.applyIJC(in); }
2258 Mat3d applyIJC(const Mat3d& d2_is, const Vec3d& d1_is, const Vec3d& ijk) const override
2259 {
2260 const Vec3d loc = applyFrustumMap(ijk);
2261
2262 const double s = mGamma * loc.z() + 1.;
2263
2264 // verify that we aren't at the singularity
2265 if (isApproxEqual(s, 0.)) {
2266 OPENVDB_THROW(ArithmeticError, "Tried to evaluate the frustum transform"
2267 " at the singular focal point (e.g. camera)");
2268 }
2269
2270 // precompute
2271 const double sinv = 1.0/s; // 1/(z*gamma + 1)
2272 const double pt0 = mLx * sinv; // Lx / (z*gamma +1)
2273 const double pt1 = mGamma * pt0; // gamma * Lx / ( z*gamma +1)
2274 const double pt2 = pt1 * sinv; // gamma * Lx / ( z*gamma +1)**2
2275 const double pt3 = pt2 * sinv; // gamma * Lx / ( z*gamma +1)**3
2276
2277 const Mat3d& jacinv = mSecondMap.getConstJacobianInv();
2278
2279 // compute \frac{\partial^2 E_i}{\partial x_j \partial x_k}
2280
2281 Mat3d matE0(Mat3d::zero());
2282 Mat3d matE1(Mat3d::zero()); // matE2 = 0
2283 for(int j = 0; j < 3; j++) {
2284 for (int k = 0; k < 3; k++) {
2285
2286 const double pt4 = 2. * jacinv(2,j) * jacinv(2,k) * pt3;
2287
2288 matE0(j,k) = -(jacinv(0,j) * jacinv(2,k) + jacinv(2,j) * jacinv(0,k)) * pt2 +
2289 pt4 * loc.x();
2290
2291 matE1(j,k) = -(jacinv(1,j) * jacinv(2,k) + jacinv(2,j) * jacinv(1,k)) * pt2 +
2292 pt4 * loc.y();
2293 }
2294 }
2295
2296 // compute \frac{\partial E_i}{\partial x_j}
2297 Mat3d gradE(Mat3d::zero());
2298 for (int j = 0; j < 3; ++j ) {
2299 gradE(0,j) = pt0 * jacinv(0,j) - pt2 * loc.x()*jacinv(2,j);
2300 gradE(1,j) = pt0 * jacinv(1,j) - pt2 * loc.y()*jacinv(2,j);
2301 gradE(2,j) = (1./mDepthOnLz) * jacinv(2,j);
2302 }
2303
2304 Mat3d result(Mat3d::zero());
2305 // compute \fac{\partial E_j}{\partial x_m} \fac{\partial E_i}{\partial x_n}
2306 // \frac{\partial^2 input}{\partial E_i \partial E_j}
2307 for (int m = 0; m < 3; ++m ) {
2308 for ( int n = 0; n < 3; ++n) {
2309 for (int i = 0; i < 3; ++i ) {
2310 for (int j = 0; j < 3; ++j) {
2311 result(m, n) += gradE(j, m) * gradE(i, n) * d2_is(i, j);
2312 }
2313 }
2314 }
2315 }
2316
2317 for (int m = 0; m < 3; ++m ) {
2318 for ( int n = 0; n < 3; ++n) {
2319 result(m, n) +=
2320 matE0(m, n) * d1_is(0) + matE1(m, n) * d1_is(1);// + matE2(m, n) * d1_is(2);
2321 }
2322 }
2323
2324 return result;
2325 }
2326
2328 double determinant() const override {return mSecondMap.determinant();} // no implementation
2329
2332 double determinant(const Vec3d& loc) const override
2333 {
2334 double s = mGamma * loc.z() + 1.0;
2335 double frustum_determinant = s * s * mDepthOnLzLxLx;
2336 return mSecondMap.determinant() * frustum_determinant;
2337 }
2338
2340 Vec3d voxelSize() const override
2341 {
2342 const Vec3d loc( 0.5*(mBBox.min().x() + mBBox.max().x()),
2343 0.5*(mBBox.min().y() + mBBox.max().y()),
2344 mBBox.min().z());
2345
2346 return voxelSize(loc);
2347
2348 }
2349
2354 Vec3d voxelSize(const Vec3d& loc) const override
2355 {
2356 Vec3d out, pos = applyMap(loc);
2357 out(0) = (applyMap(loc + Vec3d(1,0,0)) - pos).length();
2358 out(1) = (applyMap(loc + Vec3d(0,1,0)) - pos).length();
2359 out(2) = (applyMap(loc + Vec3d(0,0,1)) - pos).length();
2360 return out;
2361 }
2362
2363 AffineMap::Ptr getAffineMap() const override { return mSecondMap.getAffineMap(); }
2364
2366 void setTaper(double t) { mTaper = t; init();}
2368 double getTaper() const { return mTaper; }
2370 void setDepth(double d) { mDepth = d; init();}
2372 double getDepth() const { return mDepth; }
2373 // gamma a non-dimensional number: nearplane x-width / camera to near plane distance
2374 double getGamma() const { return mGamma; }
2375
2377 const BBoxd& getBBox() const { return mBBox; }
2378
2380 const AffineMap& secondMap() const { return mSecondMap; }
2383 bool isValid() const { return !mBBox.empty();}
2384
2386 bool hasSimpleAffine() const { return mHasSimpleAffine; }
2387
2389 void read(std::istream& is) override
2390 {
2391 // for backward compatibility with earlier version
2392 if (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_FLOAT_FRUSTUM_BBOX ) {
2393 CoordBBox bb;
2394 bb.read(is);
2395 mBBox = BBoxd(bb.min().asVec3d(), bb.max().asVec3d());
2396 } else {
2397 mBBox.read(is);
2398 }
2399
2400 is.read(reinterpret_cast<char*>(&mTaper), sizeof(double));
2401 is.read(reinterpret_cast<char*>(&mDepth), sizeof(double));
2402
2403 // Read the second maps type.
2404 Name type = readString(is);
2405
2406 // Check if the map has been registered.
2407 if(!MapRegistry::isRegistered(type)) {
2408 OPENVDB_THROW(KeyError, "Map " << type << " is not registered");
2409 }
2410
2411 // Create the second map of the type and then read it in.
2412 MapBase::Ptr proxy = math::MapRegistry::createMap(type);
2413 proxy->read(is);
2414 mSecondMap = *(proxy->getAffineMap());
2415 init();
2416 }
2417
2419 void write(std::ostream& os) const override
2420 {
2421 mBBox.write(os);
2422 os.write(reinterpret_cast<const char*>(&mTaper), sizeof(double));
2423 os.write(reinterpret_cast<const char*>(&mDepth), sizeof(double));
2424
2425 writeString(os, mSecondMap.type());
2426 mSecondMap.write(os);
2427 }
2428
2430 std::string str() const override
2431 {
2432 std::ostringstream buffer;
2433 buffer << " - taper: " << mTaper << std::endl;
2434 buffer << " - depth: " << mDepth << std::endl;
2435 buffer << " SecondMap: "<< mSecondMap.type() << std::endl;
2436 buffer << mSecondMap.str() << std::endl;
2437 return buffer.str();
2438 }
2439
2442 MapBase::Ptr preRotate(double radians, Axis axis = X_AXIS) const override
2443 {
2444 return MapBase::Ptr(
2445 new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.preRotate(radians, axis)));
2446 }
2449 MapBase::Ptr preTranslate(const Vec3d& t) const override
2450 {
2451 return MapBase::Ptr(
2452 new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.preTranslate(t)));
2453 }
2456 MapBase::Ptr preScale(const Vec3d& s) const override
2457 {
2458 return MapBase::Ptr(
2459 new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.preScale(s)));
2460 }
2463 MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
2464 {
2465 return MapBase::Ptr(new NonlinearFrustumMap(
2466 mBBox, mTaper, mDepth, mSecondMap.preShear(shear, axis0, axis1)));
2467 }
2468
2471 MapBase::Ptr postRotate(double radians, Axis axis = X_AXIS) const override
2472 {
2473 return MapBase::Ptr(
2474 new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.postRotate(radians, axis)));
2475 }
2478 MapBase::Ptr postTranslate(const Vec3d& t) const override
2479 {
2480 return MapBase::Ptr(
2481 new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.postTranslate(t)));
2482 }
2485 MapBase::Ptr postScale(const Vec3d& s) const override
2486 {
2487 return MapBase::Ptr(
2488 new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.postScale(s)));
2489 }
2492 MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
2493 {
2494 return MapBase::Ptr(new NonlinearFrustumMap(
2495 mBBox, mTaper, mDepth, mSecondMap.postShear(shear, axis0, axis1)));
2496 }
2497
2498 private:
2499 void init()
2500 {
2501 // set up as a frustum
2502 mLx = mBBox.extents().x();
2503 mLy = mBBox.extents().y();
2504 mLz = mBBox.extents().z();
2505
2506 if (isApproxEqual(mLx,0.) || isApproxEqual(mLy,0.) || isApproxEqual(mLz,0.) ) {
2507 OPENVDB_THROW(ArithmeticError, "The index space bounding box"
2508 " must have at least two index points in each direction.");
2509 }
2510
2511 mXo = 0.5* mLx;
2512 mYo = 0.5* mLy;
2513
2514 // mDepth is non-dimensionalized on near
2515 mGamma = (1./mTaper - 1) / mDepth;
2516
2517 mDepthOnLz = mDepth/mLz;
2518 mDepthOnLzLxLx = mDepthOnLz/(mLx * mLx);
2519
2521 mHasSimpleAffine = true;
2522 Vec3d tmp = mSecondMap.voxelSize();
2523
2525 if (!isApproxEqual(tmp(0), tmp(1))) { mHasSimpleAffine = false; return; }
2526 if (!isApproxEqual(tmp(0), tmp(2))) { mHasSimpleAffine = false; return; }
2527
2528 Vec3d trans = mSecondMap.applyMap(Vec3d(0,0,0));
2530 Vec3d tmp1 = mSecondMap.applyMap(Vec3d(1,0,0)) - trans;
2531 Vec3d tmp2 = mSecondMap.applyMap(Vec3d(0,1,0)) - trans;
2532 Vec3d tmp3 = mSecondMap.applyMap(Vec3d(0,0,1)) - trans;
2533
2535 if (!isApproxEqual(tmp1.dot(tmp2), 0., 1.e-7)) { mHasSimpleAffine = false; return; }
2536 if (!isApproxEqual(tmp2.dot(tmp3), 0., 1.e-7)) { mHasSimpleAffine = false; return; }
2537 if (!isApproxEqual(tmp3.dot(tmp1), 0., 1.e-7)) { mHasSimpleAffine = false; return; }
2538 }
2539
2540 Vec3d applyFrustumMap(const Vec3d& in) const
2541 {
2542
2543 // Move the center of the x-face of the bbox
2544 // to the origin in index space.
2545 Vec3d out(in);
2546 out = out - mBBox.min();
2547 out.x() -= mXo;
2548 out.y() -= mYo;
2549
2550 // scale the z-direction on depth / K count
2551 out.z() *= mDepthOnLz;
2552
2553 double scale = (mGamma * out.z() + 1.)/ mLx;
2554
2555 // scale the x-y on the length I count and apply tapper
2556 out.x() *= scale ;
2557 out.y() *= scale ;
2558
2559 return out;
2560 }
2561
2562 Vec3d applyFrustumInverseMap(const Vec3d& in) const
2563 {
2564 // invert taper and resize: scale = 1/( (z+1)/2 (mt-1) + 1)
2565 Vec3d out(in);
2566 double invScale = mLx / (mGamma * out.z() + 1.);
2567 out.x() *= invScale;
2568 out.y() *= invScale;
2569
2570 out.x() += mXo;
2571 out.y() += mYo;
2572
2573 out.z() /= mDepthOnLz;
2574
2575 // move back
2576 out = out + mBBox.min();
2577 return out;
2578 }
2579
2580 // bounding box in index space used in Frustum transforms.
2581 BBoxd mBBox;
2582
2583 // taper value used in constructing Frustums.
2584 double mTaper;
2585 double mDepth;
2586
2587 // defines the second map
2588 AffineMap mSecondMap;
2589
2590 // these are derived from the above.
2591 double mLx, mLy, mLz;
2592 double mXo, mYo, mGamma, mDepthOnLz, mDepthOnLzLxLx;
2593
2594 // true: if the mSecondMap is linear and has no shear, and has no non-uniform scale
2595 bool mHasSimpleAffine;
2596 }; // class NonlinearFrustumMap
2597
2598
2600
2601
2605 template<typename FirstMapType, typename SecondMapType>
2606 class CompoundMap
2607 {
2608 public:
2609 using MyType = CompoundMap<FirstMapType, SecondMapType>;
2610
2611 using Ptr = SharedPtr<MyType>;
2612 using ConstPtr = SharedPtr<const MyType>;
2613
2614
2615 CompoundMap() { updateAffineMatrix(); }
2616
2617 CompoundMap(const FirstMapType& f, const SecondMapType& s): mFirstMap(f), mSecondMap(s)
2618 {
2619 updateAffineMatrix();
2620 }
2621
2622 CompoundMap(const MyType& other):
2623 mFirstMap(other.mFirstMap),
2624 mSecondMap(other.mSecondMap),
2625 mAffineMap(other.mAffineMap)
2626 {}
2627
2628 Name type() const { return mapType(); }
2629 static Name mapType()
2630 {
2631 return (FirstMapType::mapType() + Name(":") + SecondMapType::mapType());
2632 }
2633
2634 bool operator==(const MyType& other) const
2635 {
2636 if (mFirstMap != other.mFirstMap) return false;
2637 if (mSecondMap != other.mSecondMap) return false;
2638 if (mAffineMap != other.mAffineMap) return false;
2639 return true;
2640 }
2641
2642 bool operator!=(const MyType& other) const { return !(*this == other); }
2643
2644 MyType& operator=(const MyType& other)
2645 {
2646 mFirstMap = other.mFirstMap;
2647 mSecondMap = other.mSecondMap;
2648 mAffineMap = other.mAffineMap;
2649 return *this;
2650 }
2651
2652 bool isIdentity() const
2653 {
2654 if (is_linear<MyType>::value) {
2655 return mAffineMap.isIdentity();
2656 } else {
2657 return mFirstMap.isIdentity()&&mSecondMap.isIdentity();
2658 }
2659 }
2660
2661 bool isDiagonal() const {
2662 if (is_linear<MyType>::value) {
2663 return mAffineMap.isDiagonal();
2664 } else {
2665 return mFirstMap.isDiagonal()&&mSecondMap.isDiagonal();
2666 }
2667 }
2668
2669 AffineMap::Ptr getAffineMap() const
2670 {
2671 if (is_linear<MyType>::value) {
2672 AffineMap::Ptr affine(new AffineMap(mAffineMap));
2673 return affine;
2674 } else {
2675 OPENVDB_THROW(ArithmeticError,
2676 "Constant affine matrix representation not possible for this nonlinear map");
2677 }
2678 }
2679
2680 // direct decompotion
2681 const FirstMapType& firstMap() const { return mFirstMap; }
2682 const SecondMapType& secondMap() const {return mSecondMap; }
2683
2684 void setFirstMap(const FirstMapType& first) { mFirstMap = first; updateAffineMatrix(); }
2685 void setSecondMap(const SecondMapType& second) { mSecondMap = second; updateAffineMatrix(); }
2686
2687 void read(std::istream& is)
2688 {
2689 mAffineMap.read(is);
2690 mFirstMap.read(is);
2691 mSecondMap.read(is);
2692 }
2693 void write(std::ostream& os) const
2694 {
2695 mAffineMap.write(os);
2696 mFirstMap.write(os);
2697 mSecondMap.write(os);
2698 }
2699
2700 private:
2701 void updateAffineMatrix()
2702 {
2703 if (is_linear<MyType>::value) {
2704 // both maps need to be linear, these methods are only defined for linear maps
2705 AffineMap::Ptr first = mFirstMap.getAffineMap();
2706 AffineMap::Ptr second= mSecondMap.getAffineMap();
2707 mAffineMap = AffineMap(*first, *second);
2708 }
2709 }
2710
2711 FirstMapType mFirstMap;
2712 SecondMapType mSecondMap;
2713 // used for acceleration
2714 AffineMap mAffineMap;
2715 }; // class CompoundMap
2716
2717 } // namespace math
2718 } // namespace OPENVDB_VERSION_NAME
2719 } // namespace openvdb
2720
2721 #endif // OPENVDB_MATH_MAPS_HAS_BEEN_INCLUDED
2722
2723 // Copyright (c) 2012-2018 DreamWorks Animation LLC
2724 // All rights reserved. This software is distributed under the
2725 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v6_0::math::ScaleTranslateMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return AffineMap::Ptr to an AffineMap equivalent to *this.
Definition: Maps.h:1406
openvdb::v6_0::math::ScaleTranslateMap::ScaleTranslateMap
ScaleTranslateMap(const Vec3d &scale, const Vec3d &translate)
Definition: Maps.h:1201
openvdb::v6_0::math::AffineMap::AffineMap
AffineMap()
Definition: Maps.h:333
openvdb::v6_0::math::ScaleMap::applyJT
Vec3d applyJT(const Vec3d &in, const Vec3d &) const override
Return the Jacobian Transpose of the map applied to in.
Definition: Maps.h:787
openvdb::v6_0::math::is_uniform_scale
Definition: Maps.h:96
openvdb::v6_0::math::AffineMap::preScale
MapBase::Ptr preScale(const Vec3d &s) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropraite operation.
Definition: Maps.h:600
openvdb::v6_0::math::UniformScaleTranslateMap::mapType
static Name mapType()
Definition: Maps.h:1531
openvdb::v6_0::math::ScaleTranslateMap::applyIJC
Mat3d applyIJC(const Mat3d &in) const override
Return the Jacobian Curvature: zero for a linear map.
Definition: Maps.h:1325
openvdb::v6_0::math::TranslationMap::getTranslation
const Vec3d & getTranslation() const
Return the translation vector.
Definition: Maps.h:1089
openvdb::v6_0::math::Vec3::dot
T dot(const Vec3< T > &v) const
Dot product.
Definition: Vec3.h:216
openvdb::v6_0::math::Vec3::normalize
bool normalize(T eps=T(1.0e-7))
this = normalized this
Definition: Vec3.h:377
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:194
openvdb::v6_0::math::AffineMap::operator=
AffineMap & operator=(const AffineMap &other)
Definition: Maps.h:430
openvdb::v6_0::math::TranslationMap::determinant
double determinant(const Vec3d &) const override
Return 1.
Definition: Maps.h:1079
openvdb::v6_0::math::X_AXIS
Definition: Math.h:857
openvdb::v6_0::math::AffineMap::accumPreScale
void accumPreScale(const Vec3d &v)
Modify the existing affine map by pre-applying the given operation.
Definition: Maps.h:516
openvdb::v6_0::math::ScaleTranslateMap::isEqual
bool isEqual(const MapBase &other) const override
Return true if this map is equal to the given map.
Definition: Maps.h:1393
openvdb::v6_0::math::Round
float Round(float x)
Return x rounded to the nearest integer.
Definition: Math.h:773
openvdb::v6_0::math::UnitaryMap::type
Name type() const override
Return UnitaryMap.
Definition: Maps.h:1729
openvdb::v6_0::math::Mat4< double >
Types.h
openvdb::v6_0::math::ScaleTranslateMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new ScaleTranslateMap.
Definition: Maps.h:1242
openvdb::v6_0::math::UnitaryMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in, const Vec3d &) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:1760
openvdb::v6_0::math::isInvertible
bool isInvertible(const MatType &m)
Determine if a matrix is invertible.
Definition: Mat.h:901
openvdb::v6_0::math::AffineMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new AffineMap.
Definition: Maps.h:384
openvdb::v6_0::math::CompoundMap::getAffineMap
AffineMap::Ptr getAffineMap() const
Definition: Maps.h:2669
openvdb::v6_0::math::CompoundMap::setFirstMap
void setFirstMap(const FirstMapType &first)
Definition: Maps.h:2684
openvdb::v6_0::math::UnitaryMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const override
Return the Jacobian of the map applied to in.
Definition: Maps.h:1756
openvdb::v6_0::math::NonlinearFrustumMap::postRotate
MapBase::Ptr postRotate(double radians, Axis axis=X_AXIS) const override
Return a MapBase::Ptr to a new map that is the result of appending the given rotation to the linear p...
Definition: Maps.h:2471
openvdb::v6_0::math::ScaleTranslateMap::read
void read(std::istream &is) override
read serialization
Definition: Maps.h:1364
openvdb::v6_0::math::AffineMap::registerMap
static void registerMap()
Definition: Maps.h:392
Vec3.h
openvdb::v6_0::math::UnitaryMap::UnitaryMap
UnitaryMap()
default constructor makes an Idenity.
Definition: Maps.h:1641
openvdb::v6_0::math::CompoundMap::setSecondMap
void setSecondMap(const SecondMapType &second)
Definition: Maps.h:2685
openvdb::v6_0::math::ScaleMap::getInvScaleSqr
const Vec3d & getInvScaleSqr() const
Return the square of the scale. Used to optimize some finite difference calculations.
Definition: Maps.h:822
openvdb::v6_0::math::isDiagonal
bool isDiagonal(const MatType &mat)
Determine if a matrix is diagonal.
Definition: Mat.h:934
openvdb::v6_0::math::ScaleTranslateMap::write
void write(std::ostream &os) const override
write serialization
Definition: Maps.h:1374
openvdb::v6_0::math::TranslationMap::applyJT
Vec3d applyJT(const Vec3d &in) const override
Return the Jacobian Transpose of the map applied to in.
Definition: Maps.h:1064
openvdb::v6_0::math::NonlinearFrustumMap::voxelSize
Vec3d voxelSize() const override
Return the size of a voxel at the center of the near plane.
Definition: Maps.h:2340
openvdb::v6_0::math::NonlinearFrustumMap::setTaper
void setTaper(double t)
set the taper value, the ratio of nearplane width / far plane width
Definition: Maps.h:2366
openvdb::v6_0::math::ScaleTranslateMap::applyIJC
Mat3d applyIJC(const Mat3d &in, const Vec3d &, const Vec3d &) const override
Definition: Maps.h:1336
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v6_0::math::AffineMap::operator!=
bool operator!=(const AffineMap &other) const
Definition: Maps.h:428
openvdb::v6_0::math::UniformScaleMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition: Maps.h:959
openvdb::v6_0::math::TranslationMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in, const Vec3d &) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:1052
openvdb::v6_0::math::UnitaryMap::determinant
double determinant(const Vec3d &) const override
Return the determinant of the Jacobian, ignores argument.
Definition: Maps.h:1790
openvdb::v6_0::math::CompoundMap::write
void write(std::ostream &os) const
Definition: Maps.h:2693
openvdb::v6_0::math::ScaleTranslateMap
A specialized Affine transform that scales along the principal axis the scaling need not be uniform i...
Definition: Maps.h:1184
openvdb::v6_0::math::TranslationMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition: Maps.h:1017
openvdb::v6_0::math::TranslationMap::write
void write(std::ostream &os) const override
write serialization
Definition: Maps.h:1094
openvdb::v6_0::math::UnitaryMap::isRegistered
static bool isRegistered()
Definition: Maps.h:1719
openvdb::v6_0::math::AffineMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropraite operation.
Definition: Maps.h:606
openvdb::v6_0::math::createSymmetricMap
OPENVDB_API SharedPtr< SymmetricMap > createSymmetricMap(const Mat3d &m)
Utility methods.
openvdb::v6_0::math::NonlinearFrustumMap::type
Name type() const override
Return NonlinearFrustumMap.
Definition: Maps.h:2054
openvdb::v6_0::math::NonlinearFrustumMap::preRotate
MapBase::Ptr preRotate(double radians, Axis axis=X_AXIS) const override
Return a MapBase::Ptr to a new map that is the result of prepending the given rotation to the linear ...
Definition: Maps.h:2442
openvdb::v6_0::math::NonlinearFrustumMap::applyIJT
Vec3d applyIJT(const Vec3d &d1_is, const Vec3d &ijk) const override
Definition: Maps.h:2217
openvdb::v6_0::math::MapBase::MapFactory
Ptr(*)() MapFactory
Definition: Maps.h:166
openvdb::v6_0::math::is_uniform_diagonal_jacobian
Definition: Maps.h:113
openvdb::v6_0::math::AffineMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition: Maps.h:386
openvdb::v6_0::math::CompoundMap::read
void read(std::istream &is)
Definition: Maps.h:2687
openvdb::v6_0::math::ScaleTranslateMap::applyJT
Vec3d applyJT(const Vec3d &in) const override
Return the Jacobian Transpose of the map applied to in.
Definition: Maps.h:1311
openvdb::v6_0::math::ScaleMap::determinant
double determinant() const override
Return the product of the scale values.
Definition: Maps.h:814
openvdb::v6_0::math::NonlinearFrustumMap::mapType
static Name mapType()
Return NonlinearFrustumMap.
Definition: Maps.h:2056
openvdb::v6_0::math::hasTranslation
bool hasTranslation(const Mat4< T > &m)
Definition: Mat4.h:1355
Coord.h
openvdb::v6_0::math::AffineMap::read
void read(std::istream &is) override
read serialization
Definition: Maps.h:560
openvdb::v6_0::math::Mat4::getMat3
Mat3< T > getMat3() const
Definition: Mat4.h:343
openvdb::v6_0::math::AffineMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const override
Return the Jacobian of the map applied to in.
Definition: Maps.h:450
openvdb::v6_0::math::ScaleMap::getScale
const Vec3d & getScale() const
Return the scale values that define the map.
Definition: Maps.h:819
openvdb::v6_0::math::ScaleMap::ScaleMap
ScaleMap()
Definition: Maps.h:691
openvdb::v6_0::math::ScaleMap::ScaleMap
ScaleMap(const ScaleMap &other)
Definition: Maps.h:709
openvdb::v6_0::math::Mat3::setToRotation
void setToRotation(const Quat< T > &q)
Set this matrix to the rotation matrix specified by the quaternion.
Definition: Mat3.h:301
openvdb::v6_0::math::Mat4d
Mat4< double > Mat4d
Definition: Mat4.h:1361
openvdb::v6_0::math::TranslationMap::voxelSize
Vec3d voxelSize(const Vec3d &) const override
Return (1,1,1).
Definition: Maps.h:1086
openvdb::v6_0::math::NonlinearFrustumMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const override
Return the Jacobian of the linear second map applied to in.
Definition: Maps.h:2122
openvdb::v6_0::math::is_linear
Map traits.
Definition: Maps.h:82
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
openvdb::v6_0::math::ScaleMap::isRegistered
static bool isRegistered()
Definition: Maps.h:730
openvdb::v6_0::math::UniformScaleTranslateMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition: Maps.h:1510
openvdb::v6_0::math::AffineMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition: Maps.h:399
openvdb::v6_0::math::UnitaryMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition: Maps.h:1714
openvdb::v6_0::math::UniformScaleTranslateMap::operator!=
bool operator!=(const UniformScaleTranslateMap &other) const
Definition: Maps.h:1539
openvdb::v6_0::math::AffineMap::applyIJT
Vec3d applyIJT(const Vec3d &in) const override
Return the transpose of the inverse Jacobian of the map applied to in.
Definition: Maps.h:477
openvdb::v6_0::math::TranslationMap::determinant
double determinant() const override
Return 1.
Definition: Maps.h:1081
openvdb::v6_0::math::Vec3d
Vec3< double > Vec3d
Definition: Vec3.h:679
openvdb::v6_0::math::Mat3::row
Vec3< T > row(int i) const
Get ith row, e.g. Vec3d v = m.row(1);.
Definition: Mat3.h:186
openvdb::v6_0::math::NonlinearFrustumMap
This map is composed of three steps. First it will take a box of size (Lx X Ly X Lz) defined by a mem...
Definition: Maps.h:1905
openvdb::v6_0::math::CompoundMap::CompoundMap
CompoundMap(const FirstMapType &f, const SecondMapType &s)
Definition: Maps.h:2617
openvdb::v6_0::math::UniformScaleTranslateMap::UniformScaleTranslateMap
UniformScaleTranslateMap(double scale, const Vec3d &translate)
Definition: Maps.h:1499
openvdb::v6_0::math::TranslationMap::registerMap
static void registerMap()
Definition: Maps.h:1025
openvdb::v6_0::math::Vec3< double >
openvdb::v6_0::math::ScaleTranslateMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition: Maps.h:1244
openvdb::v6_0::math::CoordBBox::max
const Coord & max() const
Definition: Coord.h:338
openvdb::v6_0::math::NonlinearFrustumMap::operator!=
bool operator!=(const NonlinearFrustumMap &other) const
Definition: Maps.h:2108
openvdb::v6_0::math::UnitaryMap::str
std::string str() const override
string serialization, useful for debuging
Definition: Maps.h:1814
openvdb::v6_0::math::AffineMap::accumPostTranslation
void accumPostTranslation(const Vec3d &v)
Modify the existing affine map by post-applying the given operation.
Definition: Maps.h:546
openvdb::v6_0::math::ScaleMap::applyIJC
Mat3d applyIJC(const Mat3d &in, const Vec3d &, const Vec3d &) const override
Definition: Maps.h:808
openvdb::v6_0::math::TranslationMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new TranslationMap.
Definition: Maps.h:1015
openvdb::v6_0::math::ScaleMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition: Maps.h:724
openvdb::v6_0::math::AffineMap::mapType
static Name mapType()
Definition: Maps.h:400
Mat4.h
openvdb::v6_0::math::MapBase::Ptr
SharedPtr< MapBase > Ptr
Definition: Maps.h:164
openvdb::v6_0::math::ScaleTranslateMap::ScaleTranslateMap
ScaleTranslateMap()
Definition: Maps.h:1190
openvdb::v6_0::math::ScaleTranslateMap::ScaleTranslateMap
ScaleTranslateMap(const ScaleTranslateMap &other)
Definition: Maps.h:1229
openvdb::v6_0::math::NonlinearFrustumMap::inverseMap
MapBase::Ptr inverseMap() const override
Not implemented, since there is currently no map type that can represent the inverse of a frustum.
Definition: Maps.h:2040
openvdb::v6_0::math::AffineMap::determinant
double determinant(const Vec3d &) const override
Return the determinant of the Jacobian, ignores argument.
Definition: Maps.h:486
openvdb::v6_0::math::AffineMap::AffineMap
AffineMap(const Mat3d &m)
Definition: Maps.h:345
openvdb::v6_0::math::ScaleMap::applyJT
Vec3d applyJT(const Vec3d &in) const override
Return the Jacobian Transpose of the map applied to in.
Definition: Maps.h:789
openvdb::v6_0::math::UnitaryMap::operator!=
bool operator!=(const UnitaryMap &other) const
Definition: Maps.h:1748
openvdb::v6_0::math::TranslationMap
A specialized linear transform that performs a translation.
Definition: Maps.h:1001
openvdb::v6_0::math::UnitaryMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return AffineMap::Ptr to an AffineMap equivalent to *this.
Definition: Maps.h:1821
openvdb::v6_0::math::ScaleTranslateMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in, const Vec3d &) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:1302
openvdb::v6_0::math::UnitaryMap::applyJT
Vec3d applyJT(const Vec3d &in) const override
Return the Jacobian Transpose of the map applied to in.
Definition: Maps.h:1773
openvdb::v6_0::math::UniformScaleTranslateMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new UniformScaleTranslateMap.
Definition: Maps.h:1508
openvdb::v6_0::math::UnitaryMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition: Maps.h:1750
openvdb::v6_0::math::NonlinearFrustumMap::determinant
double determinant(const Vec3d &loc) const override
Definition: Maps.h:2332
openvdb::v6_0::math::ScaleMap::isEqual
bool isEqual(const MapBase &other) const override
Return true if this map is equal to the given map.
Definition: Maps.h:863
openvdb::v6_0::math::ScaleMap::operator==
bool operator==(const ScaleMap &other) const
Definition: Maps.h:865
openvdb::v6_0::math::NonlinearFrustumMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of prepending the given translation to the line...
Definition: Maps.h:2449
openvdb::v6_0::math::UniformScaleTranslateMap
A specialized Affine transform that uniformaly scales along the principal axis and then translates th...
Definition: Maps.h:1492
openvdb::v6_0::math::Mat3::setRow
void setRow(int i, const Vec3< T > &v)
Set ith row to vector v.
Definition: Mat3.h:175
openvdb::v6_0::math::UnitaryMap::applyIJT
Vec3d applyIJT(const Vec3d &in) const override
Return the transpose of the inverse Jacobian of the map applied to in.
Definition: Maps.h:1782
openvdb::v6_0::math::UnitaryMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of prepending the given translation.
Definition: Maps.h:1835
openvdb::v6_0::math::AffineMap::hasUniformScale
bool hasUniformScale() const override
Return false ( test if this is unitary with translation )
Definition: Maps.h:406
openvdb::v6_0::math::UnitaryMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new UnitaryMap.
Definition: Maps.h:1710
openvdb::v6_0::math::CompoundMap::operator==
bool operator==(const MyType &other) const
Definition: Maps.h:2634
openvdb::v6_0::math::UnitaryMap::mapType
static Name mapType()
Return UnitaryMap.
Definition: Maps.h:1731
openvdb::v6_0::math::Mat3< double >
openvdb::v6_0::math::ScaleTranslateMap::isRegistered
static bool isRegistered()
Definition: Maps.h:1252
openvdb::v6_0::math::Mat3::setCol
void setCol(int j, const Vec3< T > &v)
Set jth column to vector v.
Definition: Mat3.h:193
openvdb::v6_0::math::is_uniform_scale_translate
Definition: Maps.h:99
openvdb::v6_0::math::AffineMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of postfixing the appropraite operation.
Definition: Maps.h:636
openvdb::v6_0::math::TranslationMap::operator!=
bool operator!=(const TranslationMap &other) const
Definition: Maps.h:1111
openvdb::v6_0::math::Mat3d
Mat3< double > Mat3d
Definition: Mat3.h:843
openvdb::v6_0::math::NonlinearFrustumMap::hasUniformScale
bool hasUniformScale() const override
Return false (by convention false)
Definition: Maps.h:2062
openvdb::v6_0::math::TranslationMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:1057
openvdb::v6_0::math::ScaleMap::getInvScale
const Vec3d & getInvScale() const
Return 1/(scale)
Definition: Maps.h:826
openvdb::v6_0::math::ScaleMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const override
Return the Jacobian of the map applied to in.
Definition: Maps.h:774
openvdb::v6_0::math::NonlinearFrustumMap::setDepth
void setDepth(double d)
set the frustum depth: distance between near and far plane = frustm depth * frustm x-width
Definition: Maps.h:2370
openvdb::v6_0::math::isUnitary
bool isUnitary(const MatType &m)
Determine if a matrix is unitary (i.e., rotation or reflection).
Definition: Mat.h:921
BBox.h
openvdb::v6_0::math::UnitaryMap::read
void read(std::istream &is) override
read serialization
Definition: Maps.h:1803
openvdb::v6_0::math::TranslationMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropriate operation.
Definition: Maps.h:1133
openvdb::v6_0::math::TranslationMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition: Maps.h:1042
io.h
openvdb::v6_0::math::AffineMap::write
void write(std::ostream &os) const override
write serialization
Definition: Maps.h:562
openvdb::v6_0::math::NonlinearFrustumMap::getTaper
double getTaper() const
Return the taper value.
Definition: Maps.h:2368
openvdb::v6_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const Mat4d &m)
Definition: Maps.h:1671
openvdb::v6_0::math::CompoundMap::CompoundMap
CompoundMap(const MyType &other)
Definition: Maps.h:2622
openvdb::v6_0::math::CompoundMap::isIdentity
bool isIdentity() const
Definition: Maps.h:2652
openvdb::v6_0::KeyError
Definition: Exceptions.h:86
openvdb::v6_0::math::UniformScaleMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new UniformScaleMap.
Definition: Maps.h:941
openvdb::v6_0::math::NonlinearFrustumMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of prepending the given shear to the linear par...
Definition: Maps.h:2463
openvdb::v6_0::math::NonlinearFrustumMap::applyJT
Vec3d applyJT(const Vec3d &in) const override
Return the Jacobian Transpose of the second map applied to in.
Definition: Maps.h:2202
openvdb::v6_0::math::UniformScaleTranslateMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a UniformScaleTranslateMap that is the result of prepending translation on t...
Definition: Maps.h:1543
openvdb::v6_0::math::ScaleTranslateMap::isLinear
bool isLinear() const override
Return true (a ScaleTranslateMap is always linear).
Definition: Maps.h:1265
openvdb::v6_0::math::UnitaryMap::applyIJC
Mat3d applyIJC(const Mat3d &in, const Vec3d &, const Vec3d &) const override
Definition: Maps.h:1785
openvdb::v6_0::math::ScaleMap::applyIJT
Vec3d applyIJT(const Vec3d &in) const override
Return the transpose of the inverse Jacobian of the map applied to in.
Definition: Maps.h:795
openvdb::v6_0::math::createPolarDecomposedMap
OPENVDB_API SharedPtr< PolarDecomposedMap > createPolarDecomposedMap(const Mat3d &m)
Decomposes a general linear into translation following polar decomposition.
openvdb::v6_0::math::TranslationMap::applyIJC
Mat3d applyIJC(const Mat3d &mat, const Vec3d &, const Vec3d &) const override
Definition: Maps.h:1074
openvdb::v6_0::math::ScaleMap::getInvTwiceScale
const Vec3d & getInvTwiceScale() const
Return 1/(2 scale). Used to optimize some finite difference calculations.
Definition: Maps.h:824
openvdb::v6_0::math::Vec3::asPointer
T * asPointer()
Definition: Vec3.h:119
openvdb::v6_0::math::NonlinearFrustumMap::voxelSize
Vec3d voxelSize(const Vec3d &loc) const override
Returns the lengths of the images of the three segments from loc to loc + (1,0,0),...
Definition: Maps.h:2354
openvdb::v6_0::math::AffineMap::Ptr
SharedPtr< AffineMap > Ptr
Definition: Maps.h:330
openvdb::v6_0::math::TranslationMap::mapType
static Name mapType()
Definition: Maps.h:1033
openvdb::v6_0::math::TranslationMap::isEqual
bool isEqual(const MapBase &other) const override
Return true if this map is equal to the given map.
Definition: Maps.h:1103
openvdb::v6_0::math::ScaleTranslateMap::str
std::string str() const override
string serialization, useful for debuging
Definition: Maps.h:1384
openvdb::v6_0::math::ScaleMap::operator!=
bool operator!=(const ScaleMap &other) const
Definition: Maps.h:872
openvdb::v6_0::math::ScaleMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropraite operation to the ...
Definition: Maps.h:914
openvdb::v6_0::math::ScaleMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition: Maps.h:726
openvdb::v6_0::math::NonlinearFrustumMap::read
void read(std::istream &is) override
read serialization
Definition: Maps.h:2389
openvdb::v6_0::math::UnitaryMap::applyIJC
Mat3d applyIJC(const Mat3d &in) const override
Return the Jacobian Curvature: zero for a linear map.
Definition: Maps.h:1784
openvdb::v6_0::math::UniformScaleTranslateMap::UniformScaleTranslateMap
UniformScaleTranslateMap(const UniformScaleMap &scale, const TranslationMap &translate)
Definition: Maps.h:1501
openvdb::v6_0::math::UniformScaleMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition: Maps.h:945
openvdb::v6_0::math::AffineMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition: Maps.h:445
openvdb::v6_0::math::AffineMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropraite operation.
Definition: Maps.h:594
openvdb::v6_0::math::NonlinearFrustumMap::NonlinearFrustumMap
NonlinearFrustumMap()
Definition: Maps.h:1911
openvdb::v6_0::math::AffineMap::operator==
bool operator==(const AffineMap &other) const
Definition: Maps.h:420
openvdb::v6_0::math::isIdentity
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition: Mat.h:892
openvdb::v6_0::math::AffineMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return AffineMap::Ptr to a deep copy of the current AffineMap.
Definition: Maps.h:579
openvdb::v6_0::math::TranslationMap::applyIJT
Vec3d applyIJT(const Vec3d &in) const override
Return the transpose of the inverse Jacobian (Identity for TranslationMap) of the map applied to in.
Definition: Maps.h:1071
openvdb::v6_0::math::ScaleMap::ScaleMap
ScaleMap(const Vec3d &scale)
Definition: Maps.h:695
openvdb::v6_0::math::TranslationMap::applyJT
Vec3d applyJT(const Vec3d &in, const Vec3d &) const override
Return the Jacobian Transpose of the map applied to in.
Definition: Maps.h:1062
openvdb::v6_0::math::UnitaryMap::voxelSize
Vec3d voxelSize() const override
Returns the lengths of the images of the segments (0,0,0) − (1,0,0), (0,0,0) − (0,...
Definition: Maps.h:1798
openvdb::v6_0::math::UnitaryMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in, const Vec3d &) const override
Apply the Jacobian of this map to a vector. For a linear map this is equivalent to applying the map e...
Definition: Maps.h:1754
openvdb::v6_0::math::ScaleMap::registerMap
static void registerMap()
Definition: Maps.h:732
openvdb::v6_0::math::AffineMap::getMat4
Mat4d getMat4() const
Return the matrix representation of this AffineMap.
Definition: Maps.h:645
openvdb::v6_0::math::AffineMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition: Maps.h:443
openvdb::v6_0::math::NonlinearFrustumMap::applyJT
Vec3d applyJT(const Vec3d &in, const Vec3d &isloc) const override
Return the Jacobian Transpose of the map applied to vector in at indexloc.
Definition: Maps.h:2180
openvdb::v6_0::math::UnitaryMap::operator==
bool operator==(const UnitaryMap &other) const
Definition: Maps.h:1741
openvdb::v6_0::math::NonlinearFrustumMap::applyIJT
Vec3d applyIJT(const Vec3d &in) const override
Return the transpose of the inverse Jacobian of the linear second map applied to in.
Definition: Maps.h:2207
openvdb::v6_0::math::NonlinearFrustumMap::determinant
double determinant() const override
Return the determinant of the Jacobian of linear second map.
Definition: Maps.h:2328
openvdb::v6_0::writeString
void writeString(std::ostream &os, const Name &name)
Definition: Name.h:58
openvdb::v6_0::math::TranslationMap::operator==
bool operator==(const TranslationMap &other) const
Definition: Maps.h:1105
openvdb::v6_0::math::TranslationMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition: Maps.h:1032
openvdb::v6_0::math::NonlinearFrustumMap::NonlinearFrustumMap
NonlinearFrustumMap(const BBoxd &bb, double taper, double depth, const MapBase::Ptr &secondMap)
Constructor that takes an index-space bounding box to be mapped into a frustum with a given depth and...
Definition: Maps.h:1934
openvdb::v6_0::math::AffineMap::isRegistered
static bool isRegistered()
Definition: Maps.h:390
openvdb::v6_0::math::UnitaryMap::applyIJT
Vec3d applyIJT(const Vec3d &in, const Vec3d &) const override
Return the transpose of the inverse Jacobian of the map applied to in.
Definition: Maps.h:1780
openvdb::v6_0::math::operator==
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:488
openvdb::v6_0::math::ScaleMap::str
std::string str() const override
string serialization, useful for debuging
Definition: Maps.h:855
openvdb::v6_0::math::AffineMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of postfixing the appropraite operation.
Definition: Maps.h:624
openvdb::v6_0::math::SpectralDecomposedMap
CompoundMap< CompoundMap< UnitaryMap, ScaleMap >, UnitaryMap > SpectralDecomposedMap
Definition: Maps.h:72
openvdb::v6_0::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v6_0::math::TranslationMap::hasUniformScale
bool hasUniformScale() const override
Return false (by convention true)
Definition: Maps.h:1039
openvdb::v6_0::math::Axis
Axis
Definition: Math.h:856
openvdb::v6_0::math::UniformScaleTranslateMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a UniformScaleTranslateMap that is the result of postfixing translation on t...
Definition: Maps.h:1552
openvdb::v6_0::math::UnitaryMap::write
void write(std::ostream &os) const override
write serialization
Definition: Maps.h:1809
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
openvdb::v6_0::math::isAffine
bool isAffine(const Mat4< T > &m)
Definition: Mat4.h:1350
openvdb::v6_0::math::UnitaryMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of prepending the given shear.
Definition: Maps.h:1851
openvdb::v6_0::math::AffineMap::isIdentity
bool isIdentity() const
Return true if the underlying matrix is approximately an identity.
Definition: Maps.h:498
openvdb::v6_0::math::NonlinearFrustumMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition: Maps.h:2117
openvdb::v6_0::math::CompoundMap::Ptr
SharedPtr< MyType > Ptr
Definition: Maps.h:2611
openvdb::v6_0::math::UniformScaleMap::mapType
static Name mapType()
Definition: Maps.h:960
openvdb::v6_0::math::ScaleTranslateMap::getInvTwiceScale
const Vec3d & getInvTwiceScale() const
Return 1/(2 scale). Used to optimize some finite difference calculations.
Definition: Maps.h:1359
openvdb::v6_0::math::NonlinearFrustumMap::isIdentity
bool isIdentity() const
Return true if the map is equivalent to an identity.
Definition: Maps.h:2065
openvdb::v6_0::math::CompoundMap::secondMap
const SecondMapType & secondMap() const
Definition: Maps.h:2682
openvdb::v6_0::math::TranslationMap::read
void read(std::istream &is) override
read serialization
Definition: Maps.h:1092
openvdb::v6_0::math::NonlinearFrustumMap::NonlinearFrustumMap
NonlinearFrustumMap(const Vec3d &position, const Vec3d &direction, const Vec3d &up, double aspect, double z_near, double depth, Coord::ValueType x_count, Coord::ValueType z_count)
Constructor from a camera frustum.
Definition: Maps.h:1972
openvdb::v6_0::math::UniformScaleTranslateMap::registerMap
static void registerMap()
Definition: Maps.h:1524
openvdb::v6_0::math::NonlinearFrustumMap::getBBox
const BBoxd & getBBox() const
Return the bounding box that defines the frustum in pre-image space.
Definition: Maps.h:2377
openvdb::v6_0::math::ScaleTranslateMap::voxelSize
Vec3d voxelSize(const Vec3d &) const override
Return the absolute values of the scale values, ignores argument.
Definition: Maps.h:1349
openvdb::v6_0::math::TranslationMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return AffineMap::Ptr to an AffineMap equivalent to *this.
Definition: Maps.h:1114
openvdb::v6_0::math::UnitaryMap::isLinear
bool isLinear() const override
Return true (a UnitaryMap is always linear).
Definition: Maps.h:1734
openvdb::v6_0::math::ScaleTranslateMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropraite operation.
Definition: Maps.h:1422
openvdb::v6_0::math::AffineMap::applyJT
Vec3d applyJT(const Vec3d &in) const override
Return the Jacobian Transpose of the map applied to in.
Definition: Maps.h:467
openvdb::v6_0::math::CompoundMap::mapType
static Name mapType()
Definition: Maps.h:2629
openvdb::v6_0::math::UnitaryMap::copy
MapBase::Ptr copy() const override
Returns a MapBase::Ptr to a deep copy of *this.
Definition: Maps.h:1712
openvdb::v6_0::math::AffineMap::inverse
AffineMap::Ptr inverse() const
Return AffineMap::Ptr to the inverse of this map.
Definition: Maps.h:582
openvdb::v6_0::math::CoordBBox::read
void read(std::istream &is)
Unserialize this bounding box from the given stream.
Definition: Coord.h:494
openvdb::v6_0::math::AffineMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition: Maps.h:388
openvdb::v6_0::math::AffineMap::applyIJT
Vec3d applyIJT(const Vec3d &in, const Vec3d &) const override
Return the transpose of the inverse Jacobian of the map applied to in.
Definition: Maps.h:475
openvdb::v6_0::math::ScaleTranslateMap::applyIJT
Vec3d applyIJT(const Vec3d &in) const override
Return the transpose of the inverse Jacobian of the map applied to in.
Definition: Maps.h:1317
openvdb::v6_0::math::ScaleTranslateMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const override
Return the Jacobian of the map applied to in.
Definition: Maps.h:1298
openvdb::v6_0::math::AffineMap::AffineMap
AffineMap(const AffineMap &other)
Definition: Maps.h:362
openvdb::v6_0::math::AffineMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in, const Vec3d &) const override
Return the Jacobian of the map applied to in.
Definition: Maps.h:448
openvdb::v6_0::math::Coord::asVec3d
Vec3d asVec3d() const
Definition: Coord.h:170
openvdb::v6_0::math::NonlinearFrustumMap::registerMap
static void registerMap()
Definition: Maps.h:2047
openvdb::v6_0::math::ScaleMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in, const Vec3d &) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:778
openvdb::v6_0::math::UniformScaleMap::registerMap
static void registerMap()
Definition: Maps.h:952
openvdb::v6_0::math::UniformScaleTranslateMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition: Maps.h:1512
openvdb::v6_0::math::ScaleTranslateMap::getTranslation
const Vec3d & getTranslation() const
Returns the translation.
Definition: Maps.h:1354
openvdb::v6_0::math::Mat4::transform
Vec4< T0 > transform(const Vec4< T0 > &v) const
Transform a Vec4 by post-multiplication.
Definition: Mat4.h:1044
openvdb::v6_0::math::AffineMap::applyJT
Vec3d applyJT(const Vec3d &in, const Vec3d &) const override
Definition: Maps.h:465
openvdb::v6_0::math::ScaleTranslateMap::voxelSize
Vec3d voxelSize() const override
Return the absolute values of the scale values.
Definition: Maps.h:1347
openvdb::v6_0::math::AffineMap::isEqual
bool isEqual(const MapBase &other) const override
Return true if this map is equal to the given map.
Definition: Maps.h:418
openvdb::v6_0::math::NonlinearFrustumMap::hasSimpleAffine
bool hasSimpleAffine() const
Return true if the second map is a uniform scale, Rotation and translation.
Definition: Maps.h:2386
openvdb::v6_0::math::ScaleMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:783
openvdb::v6_0::math::TranslationMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of postfixing the appropriate operation.
Definition: Maps.h:1165
openvdb::v6_0::math::Vec3::z
T & z()
Definition: Vec3.h:112
openvdb::v6_0::math::CoordBBox::min
const Coord & min() const
Definition: Coord.h:337
openvdb::v6_0::math::NonlinearFrustumMap::applyIJC
Mat3d applyIJC(const Mat3d &in) const override
Return the Jacobian Curvature for the linear second map.
Definition: Maps.h:2253
openvdb::v6_0::math::TranslationMap::voxelSize
Vec3d voxelSize() const override
Return (1,1,1).
Definition: Maps.h:1084
openvdb::v6_0::math::TranslationMap::TranslationMap
TranslationMap()
Definition: Maps.h:1008
openvdb::v6_0::math::AffineMap::getConstJacobianInv
const Mat3d & getConstJacobianInv() const
Definition: Maps.h:647
openvdb::v6_0::math::AffineMap::accumPostScale
void accumPostScale(const Vec3d &v)
Modify the existing affine map by post-applying the given operation.
Definition: Maps.h:541
openvdb::v6_0::math::MapBase::ConstPtr
SharedPtr< const MapBase > ConstPtr
Definition: Maps.h:165
openvdb::v6_0::math::BBox::read
void read(std::istream &is)
Unserialize this bounding box from the given stream.
Definition: BBox.h:161
openvdb::v6_0::math::ScaleTranslateMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of postfixing the appropraite operation.
Definition: Maps.h:1450
openvdb::v6_0::math::ScaleTranslateMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of postfixing the appropraite operation.
Definition: Maps.h:1457
openvdb::v6_0::math::UniformScaleMap
A specialized Affine transform that scales along the principal axis the scaling is uniform in the thr...
Definition: Maps.h:929
openvdb::v6_0::math::Vec3::y
T & y()
Definition: Vec3.h:111
openvdb::v6_0::math::ScaleMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition: Maps.h:764
openvdb::v6_0::math::CompoundMap::isDiagonal
bool isDiagonal() const
Definition: Maps.h:2661
openvdb::v6_0::math::ScaleTranslateMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition: Maps.h:1246
openvdb
Definition: Exceptions.h:40
openvdb::v6_0::math::ScaleMap::determinant
double determinant(const Vec3d &) const override
Return the product of the scale values, ignores argument.
Definition: Maps.h:812
openvdb::v6_0::math::is_diagonal_jacobian
Definition: Maps.h:117
openvdb::v6_0::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:264
openvdb::v6_0::math::ScaleTranslateMap::getInvScaleSqr
const Vec3d & getInvScaleSqr() const
Return the square of the scale. Used to optimize some finite difference calculations.
Definition: Maps.h:1357
openvdb::v6_0::math::UnitaryMap::postRotate
MapBase::Ptr postRotate(double radians, Axis axis) const override
Return a MapBase::Ptr to a new map that is the result of appending the given rotation.
Definition: Maps.h:1860
openvdb::v6_0::math::UnitaryMap::Ptr
SharedPtr< UnitaryMap > Ptr
Definition: Maps.h:1637
openvdb::v6_0::math::AffineMap::voxelSize
Vec3d voxelSize(const Vec3d &) const override
Return the lengths of the images of the segments (0,0,0)-(1,0,0), (0,0,0)-(0,1,0) and (0,...
Definition: Maps.h:494
openvdb::v6_0::math::ScaleTranslateMap::determinant
double determinant(const Vec3d &) const override
Return the product of the scale values, ignores argument.
Definition: Maps.h:1341
openvdb::v6_0::math::Mat3::col
Vec3< T > col(int j) const
Get jth column, e.g. Vec3d v = m.col(0);.
Definition: Mat3.h:202
openvdb::v6_0::math::TranslationMap::str
std::string str() const override
string serialization, useful for debuging
Definition: Maps.h:1096
openvdb::v6_0::math::CompoundMap::firstMap
const FirstMapType & firstMap() const
Definition: Maps.h:2681
openvdb::v6_0::math::UniformScaleTranslateMap::UniformScaleTranslateMap
UniformScaleTranslateMap(const UniformScaleTranslateMap &other)
Definition: Maps.h:1504
openvdb::v6_0::math::ScaleTranslateMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:1305
openvdb::v6_0::math::AffineMap::accumPostShear
void accumPostShear(Axis axis0, Axis axis1, double shear)
Modify the existing affine map by post-applying the given operation.
Definition: Maps.h:551
openvdb::v6_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const UnitaryMap &other)
Definition: Maps.h:1696
openvdb::v6_0::math::TranslationMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition: Maps.h:1019
openvdb::v6_0::math::TranslationMap::applyIJT
Vec3d applyIJT(const Vec3d &in, const Vec3d &) const override
Return the transpose of the inverse Jacobian (Identity for TranslationMap) of the map applied to in,...
Definition: Maps.h:1068
openvdb::v6_0::math::ScaleMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropraite operation to the ...
Definition: Maps.h:894
openvdb::v6_0::math::NonlinearFrustumMap::preScale
MapBase::Ptr preScale(const Vec3d &s) const override
Return a MapBase::Ptr to a new map that is the result of prepending the given scale to the linear par...
Definition: Maps.h:2456
openvdb::v6_0::math::AffineMap::applyIJC
Mat3d applyIJC(const Mat3d &in, const Vec3d &, const Vec3d &) const override
Definition: Maps.h:482
openvdb::v6_0::math::NonlinearFrustumMap::str
std::string str() const override
string serialization, useful for debuging
Definition: Maps.h:2430
openvdb::v6_0::math::NonlinearFrustumMap::NonlinearFrustumMap
NonlinearFrustumMap(const BBoxd &bb, double taper, double depth)
Constructor that takes an index-space bounding box to be mapped into a frustum with a given depth and...
Definition: Maps.h:1923
openvdb::v6_0::math::UnitaryMap::preScale
MapBase::Ptr preScale(const Vec3d &v) const override
Return a MapBase::Ptr to a new map that is the result of prepending the given scale.
Definition: Maps.h:1843
openvdb::v6_0::math::CompoundMap::ConstPtr
SharedPtr< const MyType > ConstPtr
Definition: Maps.h:2612
openvdb::v6_0::math::Coord::ValueType
Int32 ValueType
Definition: Coord.h:59
openvdb::v6_0::math::ScaleTranslateMap::hasUniformScale
bool hasUniformScale() const override
Return true if the scale values have the same magnitude (eg. -1, 1, -1 would be a rotation).
Definition: Maps.h:1269
openvdb::v6_0::math::TranslationMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in, const Vec3d &) const override
Return the Jacobian of the map applied to in.
Definition: Maps.h:1046
openvdb::v6_0::math::MapBase
Abstract base class for maps.
Definition: Maps.h:161
openvdb::v6_0::math::ScaleTranslateMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of under the map.
Definition: Maps.h:1279
openvdb::v6_0::math::MapRegistry::MapDictionary
std::map< Name, MapBase::MapFactory > MapDictionary
Definition: Maps.h:292
openvdb::v6_0::math::UniformScaleMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition: Maps.h:943
openvdb::v6_0::math::AffineMap::accumPreShear
void accumPreShear(Axis axis0, Axis axis1, double shear)
Modify the existing affine map by pre-applying the given operation.
Definition: Maps.h:526
openvdb::v6_0::math::AffineMap::str
std::string str() const override
string serialization, useful for debugging
Definition: Maps.h:564
openvdb::v6_0::math::ScaleMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new ScaleMap.
Definition: Maps.h:722
openvdb::v6_0::math::UnitaryMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:1765
openvdb::v6_0::math::isApproxEqual
bool isApproxEqual(const Type &a, const Type &b)
Return true if a is equal to b to within the default floating-point comparison tolerance.
Definition: Math.h:358
openvdb::v6_0::math::UniformScaleMap::isEqual
bool isEqual(const MapBase &other) const override
Return true if this map is equal to the given map.
Definition: Maps.h:962
openvdb::v6_0::math::NonlinearFrustumMap::write
void write(std::ostream &os) const override
write serialization
Definition: Maps.h:2419
openvdb::v6_0::math::UniformScaleTranslateMap::isEqual
bool isEqual(const MapBase &other) const override
Return true if this map is equal to the given map.
Definition: Maps.h:1533
openvdb::v6_0::math::ScaleMap::read
void read(std::istream &is) override
read serialization
Definition: Maps.h:837
openvdb::v6_0::math::ScaleTranslateMap::ScaleTranslateMap
ScaleTranslateMap(const ScaleMap &scale, const TranslationMap &translate)
Definition: Maps.h:1216
openvdb::v6_0::math::NonlinearFrustumMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in, const Vec3d &isloc) const override
Return the Jacobian defined at isloc applied to in.
Definition: Maps.h:2124
openvdb::v6_0::math::Tolerance
Tolerance for floating-point comparison.
Definition: Math.h:117
openvdb::v6_0::math::UniformScaleTranslateMap::isRegistered
static bool isRegistered()
Definition: Maps.h:1519
openvdb::v6_0::math::TranslationMap::applyIJC
Mat3d applyIJC(const Mat3d &mat) const override
Return the Jacobian Curvature: zero for a linear map.
Definition: Maps.h:1073
openvdb::v6_0::math::NonlinearFrustumMap::applyIJC
Mat3d applyIJC(const Mat3d &d2_is, const Vec3d &d1_is, const Vec3d &ijk) const override
Definition: Maps.h:2258
openvdb::v6_0::math::AffineMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in, const Vec3d &) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:454
openvdb::v6_0::math::UnitaryMap::determinant
double determinant() const override
Return the determinant of the Jacobian.
Definition: Maps.h:1792
openvdb::v6_0::math::ScaleTranslateMap::getInvScale
const Vec3d & getInvScale() const
Return 1/(scale)
Definition: Maps.h:1361
openvdb::v6_0::OPENVDB_FILE_VERSION_FLOAT_FRUSTUM_BBOX
Definition: version.h:228
openvdb::v6_0::math::scale
MatType scale(const Vec3< typename MatType::value_type > &s)
Return a matrix that scales by s.
Definition: Mat.h:647
openvdb::v6_0::math::NonlinearFrustumMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of appending the given translation to the linea...
Definition: Maps.h:2478
openvdb::v6_0::math::Vec3::length
T length() const
Length of the vector.
Definition: Vec3.h:225
openvdb::v6_0::math::AffineMap::applyIJC
Mat3d applyIJC(const Mat3d &m) const override
Return the Jacobian Curvature: zero for a linear map.
Definition: Maps.h:479
openvdb::v6_0::math::shear
MatType shear(Axis axis0, Axis axis1, typename MatType::value_type shear)
Set the matrix to a shear along axis0 by a fraction of axis1.
Definition: Mat.h:720
openvdb::v6_0::math::UnitaryMap::applyJT
Vec3d applyJT(const Vec3d &in, const Vec3d &) const override
Return the Jacobian Transpose of the map applied to in.
Definition: Maps.h:1771
openvdb::v6_0::math::AffineMap::isScale
bool isScale() const
Return true if the map is equivalent to a ScaleMap.
Definition: Maps.h:502
openvdb::v6_0::math::Mat3::transpose
Mat3 transpose() const
returns transpose of this
Definition: Mat3.h:502
openvdb::v6_0::math::ScaleMap
A specialized Affine transform that scales along the principal axis the scaling need not be uniform i...
Definition: Maps.h:685
openvdb::v6_0::math::ScaleMap::hasUniformScale
bool hasUniformScale() const override
Return true if the values have the same magitude (eg. -1, 1, -1 would be a rotation).
Definition: Maps.h:746
openvdb::v6_0::math::ScaleMap::voxelSize
Vec3d voxelSize(const Vec3d &) const override
Return the lengths of the images of the segments (0,0,0) − 1,0,0), (0,0,0) − (0,...
Definition: Maps.h:833
openvdb::v6_0::math::UnitaryMap::voxelSize
Vec3d voxelSize(const Vec3d &) const override
Returns the lengths of the images of the segments (0,0,0) − (1,0,0), (0,0,0) − (0,...
Definition: Maps.h:1799
openvdb::v6_0::math::is_scale_translate
Definition: Maps.h:109
openvdb::v6_0::math::BBox< Vec3d >
openvdb::v6_0::math::NonlinearFrustumMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new NonlinearFrustumMap.
Definition: Maps.h:2033
openvdb::v6_0::math::MapBase::isEqualBase
static bool isEqualBase(const MapT &self, const MapBase &other)
Definition: Maps.h:277
openvdb::v6_0::math::UniformScaleTranslateMap::operator==
bool operator==(const UniformScaleTranslateMap &other) const
Definition: Maps.h:1535
openvdb::v6_0::math::CompoundMap
Creates the composition of two maps, each of which could be a composition. In the case that each comp...
Definition: Maps.h:69
openvdb::v6_0::math::UniformScaleMap::UniformScaleMap
UniformScaleMap()
Definition: Maps.h:935
openvdb::v6_0::math::ScaleTranslateMap::operator==
bool operator==(const ScaleTranslateMap &other) const
Definition: Maps.h:1395
openvdb::v6_0::math::ScaleMap::applyIJT
Vec3d applyIJT(const Vec3d &in, const Vec3d &) const override
Return the transpose of the inverse Jacobian of the map applied to in.
Definition: Maps.h:793
openvdb::v6_0::math::AffineMap::accumPreTranslation
void accumPreTranslation(const Vec3d &v)
Modify the existing affine map by pre-applying the given operation.
Definition: Maps.h:521
openvdb::v6_0::SharedPtr
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
openvdb::v6_0::math::ScaleMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in, const Vec3d &) const override
Return the Jacobian of the map applied to in.
Definition: Maps.h:772
openvdb::v6_0::math::NonlinearFrustumMap::isRegistered
static bool isRegistered()
Definition: Maps.h:2045
openvdb::v6_0::math::ScaleTranslateMap::getScale
const Vec3d & getScale() const
Returns the scale values.
Definition: Maps.h:1352
openvdb::v6_0::math::TranslationMap::isRegistered
static bool isRegistered()
Definition: Maps.h:1023
openvdb::v6_0::math::TranslationMap::TranslationMap
TranslationMap(const TranslationMap &other)
Definition: Maps.h:1010
openvdb::v6_0::math::UnitaryMap::isEqual
bool isEqual(const MapBase &other) const override
Return true if this map is equal to the given map.
Definition: Maps.h:1739
openvdb::v6_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const UnitaryMap &first, const UnitaryMap &second)
Definition: Maps.h:1702
openvdb::v6_0::math::NonlinearFrustumMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition: Maps.h:2035
openvdb::v6_0::math::AffineMap::postScale
MapBase::Ptr postScale(const Vec3d &s) const override
Return a MapBase::Ptr to a new map that is the result of postfixing the appropraite operation.
Definition: Maps.h:630
openvdb::v6_0::math::AffineMap::isScaleTranslate
bool isScaleTranslate() const
Return true if the map is equivalent to a ScaleTranslateMap.
Definition: Maps.h:504
openvdb::v6_0::math::CompoundMap::CompoundMap
CompoundMap()
Definition: Maps.h:2615
openvdb::v6_0::math::NonlinearFrustumMap::isLinear
bool isLinear() const override
Return false (a NonlinearFrustumMap is never linear).
Definition: Maps.h:2059
openvdb::v6_0::BBoxd
math::BBox< Vec3d > BBoxd
Definition: Types.h:91
openvdb::v6_0::math::NonlinearFrustumMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Definition: Maps.h:2363
openvdb::v6_0::math::NonlinearFrustumMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition: Maps.h:2111
openvdb::v6_0::math::UnitaryMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of appending the given shear.
Definition: Maps.h:1884
openvdb::v6_0::math::ScaleMap::write
void write(std::ostream &os) const override
write serialization
Definition: Maps.h:846
openvdb::v6_0::math::MapBase::MapBase
MapBase()
Definition: Maps.h:274
openvdb::v6_0::math::UniformScaleTranslateMap::UniformScaleTranslateMap
UniformScaleTranslateMap()
Definition: Maps.h:1498
openvdb::v6_0::math::AffineMap::getConstMat4
const Mat4d & getConstMat4() const
Definition: Maps.h:646
openvdb::v6_0::math::AffineMap::determinant
double determinant() const override
Return the determinant of the Jacobian.
Definition: Maps.h:488
openvdb::v6_0::math::UnitaryMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition: Maps.h:1752
openvdb::v6_0::math::Mat3::det
T det() const
Determinant of matrix.
Definition: Mat3.h:527
openvdb::v6_0::math::TranslationMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition: Maps.h:1044
openvdb::v6_0::math::ScaleTranslateMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropraite operation.
Definition: Maps.h:1433
openvdb::v6_0::math::ScaleTranslateMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of under the map.
Definition: Maps.h:1287
openvdb::v6_0::math::ScaleMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition: Maps.h:756
openvdb::v6_0::math::AffineMap::AffineMap
AffineMap(const AffineMap &first, const AffineMap &second)
constructor that merges the matrixes for two affine maps
Definition: Maps.h:375
openvdb::v6_0::math::UniformScaleMap::operator==
bool operator==(const UniformScaleMap &other) const
Definition: Maps.h:964
openvdb::v6_0::math::UniformScaleTranslateMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition: Maps.h:1530
openvdb::v6_0::math::AffineMap::AffineMap
AffineMap(const Mat4d &m)
Definition: Maps.h:353
openvdb::v6_0::math::UniformScaleMap::isRegistered
static bool isRegistered()
Definition: Maps.h:951
openvdb::v6_0::math::Mat4::setTranslation
void setTranslation(const Vec3< T > &t)
Definition: Mat4.h:360
openvdb::v6_0::math::Mat4::inverse
Mat4 inverse(T tolerance=0) const
Definition: Mat4.h:531
openvdb::v6_0::readString
Name readString(std::istream &is)
Definition: Name.h:47
openvdb::v6_0::math::ScaleTranslateMap::applyIJT
Vec3d applyIJT(const Vec3d &in, const Vec3d &) const override
Return the transpose of the inverse Jacobian of the map applied to in.
Definition: Maps.h:1315
openvdb::v6_0::math::UnitaryMap::hasUniformScale
bool hasUniformScale() const override
Return false (by convention true)
Definition: Maps.h:1737
openvdb::v6_0::math::ScaleMap::isLinear
bool isLinear() const override
Return true (a ScaleMap is always linear).
Definition: Maps.h:743
openvdb::v6_0::math::ScaleMap::applyIJC
Mat3d applyIJC(const Mat3d &in) const override
Return the Jacobian Curvature: zero for a linear map.
Definition: Maps.h:797
openvdb::v6_0::math::TranslationMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of postfixing the appropriate operation.
Definition: Maps.h:1158
openvdb::v6_0::math::NonlinearFrustumMap::secondMap
const AffineMap & secondMap() const
Return MapBase::Ptr& to the second map.
Definition: Maps.h:2380
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
openvdb::v6_0::math::NonlinearFrustumMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of appending the given shear to the linear part...
Definition: Maps.h:2492
openvdb::v6_0::math::NonlinearFrustumMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in, const Vec3d &isloc) const override
Return the Inverse Jacobian defined at isloc of the map applied to in.
Definition: Maps.h:2153
openvdb::v6_0::math::ScaleTranslateMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition: Maps.h:1261
openvdb::v6_0::math::UnitaryMap::preRotate
MapBase::Ptr preRotate(double radians, Axis axis) const override
Return a MapBase::Ptr to a new map that is the result of prepending the given rotation.
Definition: Maps.h:1827
openvdb::v6_0::math::Mat3::inverse
Mat3 inverse(T tolerance=0) const
Definition: Mat3.h:513
openvdb::v6_0::math::TranslationMap::isLinear
bool isLinear() const override
Return true (a TranslationMap is always linear).
Definition: Maps.h:1036
openvdb::v6_0::math::TranslationMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropriate operation.
Definition: Maps.h:1140
openvdb::v6_0::math::NonlinearFrustumMap::isEqual
bool isEqual(const MapBase &other) const override
Return true if this map is equal to the given map.
Definition: Maps.h:2084
openvdb::v6_0::math::NonlinearFrustumMap::operator==
bool operator==(const NonlinearFrustumMap &other) const
Definition: Maps.h:2086
openvdb::v6_0::math::ScaleMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition: Maps.h:739
openvdb::v6_0::math::ScaleTranslateMap::operator!=
bool operator!=(const ScaleTranslateMap &other) const
Definition: Maps.h:1403
openvdb::v6_0::math::ScaleTranslateMap::applyJT
Vec3d applyJT(const Vec3d &in, const Vec3d &) const override
Return the Jacobian Transpose of the map applied to in.
Definition: Maps.h:1309
openvdb::v6_0::math::NonlinearFrustumMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:2149
openvdb::v6_0::math::UniformScaleMap::UniformScaleMap
UniformScaleMap(double scale)
Definition: Maps.h:936
openvdb::v6_0::math::ScaleTranslateMap::mapType
static Name mapType()
Definition: Maps.h:1262
openvdb::v6_0::math::AffineMap::isDiagonal
bool isDiagonal() const
Return true if the underylying matrix is diagonal.
Definition: Maps.h:500
openvdb::v6_0::math::NonlinearFrustumMap::getGamma
double getGamma() const
Definition: Maps.h:2374
openvdb::v6_0::math::ScaleMap::mapType
static Name mapType()
Definition: Maps.h:740
openvdb::v6_0::math::AffineMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in) const override
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation)
Definition: Maps.h:459
openvdb::v6_0::math::TranslationMap::TranslationMap
TranslationMap(const Vec3d &t)
Definition: Maps.h:1009
openvdb::v6_0::math::UnitaryMap
A specialized linear transform that performs a unitary maping i.e. rotation and or reflection.
Definition: Maps.h:1634
openvdb::v6_0::math::UnitaryMap::postScale
MapBase::Ptr postScale(const Vec3d &v) const override
Return a MapBase::Ptr to a new map that is the result of appending the given scale.
Definition: Maps.h:1876
openvdb::v6_0::math::ScaleTranslateMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in, const Vec3d &) const override
Return the Jacobian of the map applied to in.
Definition: Maps.h:1296
openvdb::v6_0::math::MapRegistry
Threadsafe singleton object for accessing the map type-name dictionary. Associates a map type-name wi...
Definition: Maps.h:289
openvdb::v6_0::math::UnitaryMap::UnitaryMap
UnitaryMap(Axis axis, double radians)
Definition: Maps.h:1652
openvdb::v6_0::Name
std::string Name
Definition: Name.h:44
openvdb::v6_0::math::MapBase::isType
bool isType() const
Return true if this map is of concrete type MapT (e.g., AffineMap).
Definition: Maps.h:177
openvdb::v6_0::NotImplementedError
Definition: Exceptions.h:88
openvdb::v6_0::math::TranslationMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const override
Return the Jacobian of the map applied to in.
Definition: Maps.h:1048
openvdb::v6_0::math::UniformScaleMap::UniformScaleMap
UniformScaleMap(const UniformScaleMap &other)
Definition: Maps.h:937
openvdb::v6_0::math::AffineMap
A general linear transform using homogeneous coordinates to perform rotation, scaling,...
Definition: Maps.h:327
openvdb::v6_0::math::Mat4::setToRotation
void setToRotation(Axis axis, T angle)
Sets the matrix to a rotation about the given axis.
Definition: Mat4.h:829
openvdb::v6_0::math::NonlinearFrustumMap::NonlinearFrustumMap
NonlinearFrustumMap(const NonlinearFrustumMap &other)
Definition: Maps.h:1946
openvdb::v6_0::math::ScaleTranslateMap::determinant
double determinant() const override
Return the product of the scale values.
Definition: Maps.h:1343
openvdb::v6_0::math::approxInverse
OPENVDB_API Mat4d approxInverse(const Mat4d &mat)
Returns the left pseudoInverse of the input matrix when the 3x3 part is symmetric otherwise it zeros ...
openvdb::v6_0::math::CompoundMap::type
Name type() const
Definition: Maps.h:2628
openvdb::v6_0::math::UnitaryMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &t) const override
Return a MapBase::Ptr to a new map that is the result of appending the given translation.
Definition: Maps.h:1868
openvdb::v6_0::math::CompoundMap::operator=
MyType & operator=(const MyType &other)
Definition: Maps.h:2644
openvdb::v6_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const Vec3d &axis, double radians)
Definition: Maps.h:1645
openvdb::v6_0::math::AffineMap::createDecomposedMap
SharedPtr< FullyDecomposedMap > createDecomposedMap()
on-demand decomposition of the affine map
Definition: Maps.h:573
openvdb::v6_0::math::CompoundMap::operator!=
bool operator!=(const MyType &other) const
Definition: Maps.h:2642
openvdb::v6_0::math::Mat4::setMat3
void setMat3(const Mat3< T > &m)
Set upper left to a Mat3.
Definition: Mat4.h:336
openvdb::v6_0::math::simplify
OPENVDB_API SharedPtr< MapBase > simplify(SharedPtr< AffineMap > affine)
reduces an AffineMap to a ScaleMap or a ScaleTranslateMap when it can
openvdb::v6_0::math::NonlinearFrustumMap::isValid
bool isValid() const
Definition: Maps.h:2383
openvdb::v6_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const Mat3d &m)
Definition: Maps.h:1659
openvdb::v6_0::math::NonlinearFrustumMap::getDepth
double getDepth() const
Return the unscaled frustm depth.
Definition: Maps.h:2372
openvdb::v6_0::math::UnitaryMap::registerMap
static void registerMap()
Definition: Maps.h:1721
openvdb::v6_0::math::getScale
Vec3< typename MatType::value_type > getScale(const MatType &mat)
Return a Vec3 representing the lengths of the passed matrix's upper 3×3's rows.
Definition: Mat.h:665
openvdb::v6_0::ArithmeticError
Definition: Exceptions.h:83
openvdb::v6_0::math::AffineMap::isLinear
bool isLinear() const override
Return true (an AffineMap is always linear).
Definition: Maps.h:403
openvdb::v6_0::math::UniformScaleMap::operator!=
bool operator!=(const UniformScaleMap &other) const
Definition: Maps.h:965
Name.h
openvdb::v6_0::math::is_scale
Definition: Maps.h:106
openvdb::v6_0::math::createFullyDecomposedMap
OPENVDB_API SharedPtr< FullyDecomposedMap > createFullyDecomposedMap(const Mat4d &m)
General decomposition of a Matrix into a Unitary (e.g. rotation) following a Symmetric (e....
openvdb::v6_0::math::Vec3::x
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition: Vec3.h:110
openvdb::v6_0::math::ScaleMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return a AffineMap equivalent to this map.
Definition: Maps.h:875
openvdb::v6_0::math::ScaleTranslateMap::registerMap
static void registerMap()
Definition: Maps.h:1254
openvdb::v6_0::math::NonlinearFrustumMap::postScale
MapBase::Ptr postScale(const Vec3d &s) const override
Return a MapBase::Ptr to a new map that is the result of appending the given scale to the linear part...
Definition: Maps.h:2485