Loading...
Searching...
No Matches
Maps.h
Go to the documentation of this file.
// Copyright Contributors to the OpenVDB Project
// SPDX-License-Identifier: MPL-2.0
/// @file math/Maps.h
#ifndef OPENVDB_MATH_MAPS_HAS_BEEN_INCLUDED
#define OPENVDB_MATH_MAPS_HAS_BEEN_INCLUDED
#include "Math.h"
#include "Mat4.h"
#include "Vec3.h"
#include "BBox.h"
#include "Coord.h"
#include <openvdb/io/io.h> // for io::getFormatVersion()
#include <openvdb/util/Name.h>
#include <openvdb/Types.h>
#include <cmath> // for std::abs()
#include <iostream>
#include <map>
#include <string>
namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
namespace OPENVDB_VERSION_NAME {
namespace math {
////////////////////////////////////////
/// Forward declarations of the different map types
class MapBase;
class ScaleMap;
class TranslationMap;
class ScaleTranslateMap;
class UniformScaleMap;
class UniformScaleTranslateMap;
class AffineMap;
class UnitaryMap;
class NonlinearFrustumMap;
template<typename T1, typename T2> class CompoundMap;
using UnitaryAndTranslationMap = CompoundMap<UnitaryMap, TranslationMap>;
using SpectralDecomposedMap = CompoundMap<CompoundMap<UnitaryMap, ScaleMap>, UnitaryMap>;
using SymmetricMap = SpectralDecomposedMap;
using FullyDecomposedMap = CompoundMap<SymmetricMap, UnitaryAndTranslationMap>;
using PolarDecomposedMap = CompoundMap<SymmetricMap, UnitaryMap>;
////////////////////////////////////////
/// Map traits
template<typename T> struct is_linear { static const bool value = false; };
template<> struct is_linear<AffineMap> { static const bool value = true; };
template<> struct is_linear<ScaleMap> { static const bool value = true; };
template<> struct is_linear<UniformScaleMap> { static const bool value = true; };
template<> struct is_linear<UnitaryMap> { static const bool value = true; };
template<> struct is_linear<TranslationMap> { static const bool value = true; };
template<> struct is_linear<ScaleTranslateMap> { static const bool value = true; };
template<> struct is_linear<UniformScaleTranslateMap> { static const bool value = true; };
template<typename T1, typename T2> struct is_linear<CompoundMap<T1, T2> > {
static const bool value = is_linear<T1>::value && is_linear<T2>::value;
};
template<typename T> struct is_uniform_scale { static const bool value = false; };
template<> struct is_uniform_scale<UniformScaleMap> { static const bool value = true; };
template<typename T> struct is_uniform_scale_translate { static const bool value = false; };
template<> struct is_uniform_scale_translate<TranslationMap> { static const bool value = true; };
template<> struct is_uniform_scale_translate<UniformScaleTranslateMap> {
static const bool value = true;
};
template<typename T> struct is_scale { static const bool value = false; };
template<> struct is_scale<ScaleMap> { static const bool value = true; };
template<typename T> struct is_scale_translate { static const bool value = false; };
template<> struct is_scale_translate<ScaleTranslateMap> { static const bool value = true; };
template<typename T> struct is_uniform_diagonal_jacobian {
static const bool value = is_uniform_scale<T>::value || is_uniform_scale_translate<T>::value;
};
template<typename T> struct is_diagonal_jacobian {
static const bool value = is_scale<T>::value || is_scale_translate<T>::value;
};
////////////////////////////////////////
/// Utility methods
/// @brief Create a SymmetricMap from a symmetric matrix.
/// Decomposes the map into Rotation Diagonal Rotation^T
OPENVDB_API SharedPtr<SymmetricMap> createSymmetricMap(const Mat3d& m);
/// @brief General decomposition of a Matrix into a Unitary (e.g. rotation)
/// following a Symmetric (e.g. stretch & shear)
OPENVDB_API SharedPtr<FullyDecomposedMap> createFullyDecomposedMap(const Mat4d& m);
/// @brief Decomposes a general linear into translation following polar decomposition.
///
/// T U S where:
///
/// T: Translation
/// U: Unitary (rotation or reflection)
/// S: Symmetric
///
/// @note: the Symmetric is automatically decomposed into Q D Q^T, where
/// Q is rotation and D is diagonal.
OPENVDB_API SharedPtr<PolarDecomposedMap> createPolarDecomposedMap(const Mat3d& m);
/// @brief reduces an AffineMap to a ScaleMap or a ScaleTranslateMap when it can
OPENVDB_API SharedPtr<MapBase> simplify(SharedPtr<AffineMap> affine);
/// @brief Returns the left pseudoInverse of the input matrix when the 3x3 part is symmetric
/// otherwise it zeros the 3x3 and reverses the translation.
OPENVDB_API Mat4d approxInverse(const Mat4d& mat);
////////////////////////////////////////
/// @brief Abstract base class for maps
class OPENVDB_API MapBase
{
public:
using Ptr = SharedPtr<MapBase>;
using ConstPtr = SharedPtr<const MapBase>;
using MapFactory = Ptr (*)();
MapBase(const MapBase&) = default;
virtual ~MapBase() = default;
virtual SharedPtr<AffineMap> getAffineMap() const = 0;
/// Return the name of this map's concrete type (e.g., @c "AffineMap").
virtual Name type() const = 0;
/// Return @c true if this map is of concrete type @c MapT (e.g., AffineMap).
template<typename MapT> bool isType() const { return this->type() == MapT::mapType(); }
/// Return @c true if this map is equal to the given map.
virtual bool isEqual(const MapBase& other) const = 0;
/// Return @c true if this map is linear.
virtual bool isLinear() const = 0;
/// Return @c true if the spacing between the image of latice is uniform in all directions
virtual bool hasUniformScale() const = 0;
virtual Vec3d applyMap(const Vec3d& in) const = 0;
virtual Vec3d applyInverseMap(const Vec3d& in) const = 0;
//@{
/// @brief Apply the Inverse Jacobian Transpose of this map to a vector.
/// For a linear map this is equivalent to applying the transpose of
/// inverse map excluding translation.
virtual Vec3d applyIJT(const Vec3d& in) const = 0;
virtual Vec3d applyIJT(const Vec3d& in, const Vec3d& domainPos) const = 0;
//@}
virtual Mat3d applyIJC(const Mat3d& m) const = 0;
virtual Mat3d applyIJC(const Mat3d& m, const Vec3d& v, const Vec3d& domainPos) const = 0;
virtual double determinant() const = 0;
virtual double determinant(const Vec3d&) const = 0;
//@{
/// @brief Method to return the local size of a voxel.
/// When a location is specified as an argument, it is understood to be
/// be in the domain of the map (i.e. index space)
virtual Vec3d voxelSize() const = 0;
virtual Vec3d voxelSize(const Vec3d&) const = 0;
//@}
virtual void read(std::istream&) = 0;
virtual void write(std::ostream&) const = 0;
virtual std::string str() const = 0;
virtual MapBase::Ptr copy() const = 0;
//@{
/// @brief Methods to update the map
virtual MapBase::Ptr preRotate(double radians, Axis axis = X_AXIS) const = 0;
virtual MapBase::Ptr preTranslate(const Vec3d&) const = 0;
virtual MapBase::Ptr preScale(const Vec3d&) const = 0;
virtual MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const = 0;
virtual MapBase::Ptr postRotate(double radians, Axis axis = X_AXIS) const = 0;
virtual MapBase::Ptr postTranslate(const Vec3d&) const = 0;
virtual MapBase::Ptr postScale(const Vec3d&) const = 0;
virtual MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const = 0;
//@}
//@{
/// @brief Apply the Jacobian of this map to a vector.
/// For a linear map this is equivalent to applying the map excluding translation.
/// @warning Houdini 12.5 uses an earlier version of OpenVDB, and maps created
/// with that version lack a virtual table entry for this method. Do not call
/// this method from Houdini 12.5.
virtual Vec3d applyJacobian(const Vec3d& in) const = 0;
virtual Vec3d applyJacobian(const Vec3d& in, const Vec3d& domainPos) const = 0;
//@}
//@{
/// @brief Apply the InverseJacobian of this map to a vector.
/// For a linear map this is equivalent to applying the map inverse excluding translation.
/// @warning Houdini 12.5 uses an earlier version of OpenVDB, and maps created
/// with that version lack a virtual table entry for this method. Do not call
/// this method from Houdini 12.5.
virtual Vec3d applyInverseJacobian(const Vec3d& in) const = 0;
virtual Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d& domainPos) const = 0;
//@}
//@{
/// @brief Apply the Jacobian transpose of this map to a vector.
/// For a linear map this is equivalent to applying the transpose of the map
/// excluding translation.
/// @warning Houdini 12.5 uses an earlier version of OpenVDB, and maps created
/// with that version lack a virtual table entry for this method. Do not call
/// this method from Houdini 12.5.
virtual Vec3d applyJT(const Vec3d& in) const = 0;
virtual Vec3d applyJT(const Vec3d& in, const Vec3d& domainPos) const = 0;
//@}
/// @brief Return a new map representing the inverse of this map.
/// @throw NotImplementedError if the map is a NonlinearFrustumMap.
/// @warning Houdini 12.5 uses an earlier version of OpenVDB, and maps created
/// with that version lack a virtual table entry for this method. Do not call
/// this method from Houdini 12.5.
virtual MapBase::Ptr inverseMap() const = 0;
protected:
MapBase() {}
template<typename MapT>
static bool isEqualBase(const MapT& self, const MapBase& other)
{
return other.isType<MapT>() && (self == *static_cast<const MapT*>(&other));
}
};
////////////////////////////////////////
/// @brief Threadsafe singleton object for accessing the map type-name dictionary.
/// Associates a map type-name with a factory function.
class OPENVDB_API MapRegistry
{
public:
using MapDictionary = std::map<Name, MapBase::MapFactory>;
static MapRegistry* instance();
/// Create a new map of the given (registered) type name.
static MapBase::Ptr createMap(const Name&);
/// Return @c true if the given map type name is registered.
static bool isRegistered(const Name&);
/// Register a map type along with a factory function.
static void registerMap(const Name&, MapBase::MapFactory);
/// Remove a map type from the registry.
static void unregisterMap(const Name&);
/// Clear the map type registry.
static void clear();
private:
MapRegistry() {}
static MapRegistry* staticInstance();
MapDictionary mMap;
};
////////////////////////////////////////
/// @brief A general linear transform using homogeneous coordinates to perform
/// rotation, scaling, shear and translation
class OPENVDB_API AffineMap final: public MapBase
{
public:
using Ptr = SharedPtr<AffineMap>;
using ConstPtr = SharedPtr<const AffineMap>;
AffineMap():
mMatrix(Mat4d::identity()),
mMatrixInv(Mat4d::identity()),
mJacobianInv(Mat3d::identity()),
mDeterminant(1),
mVoxelSize(Vec3d(1,1,1)),
mIsDiagonal(true),
mIsIdentity(true)
// the default constructor for translation is zero
{
}
AffineMap(const Mat3d& m)
{
Mat4d mat4(Mat4d::identity());
mat4.setMat3(m);
mMatrix = mat4;
updateAcceleration();
}
AffineMap(const Mat4d& m): mMatrix(m)
{
if (!isAffine(m)) {
OPENVDB_THROW(ArithmeticError,
"Tried to initialize an affine transform from a non-affine 4x4 matrix");
}
updateAcceleration();
}
AffineMap(const AffineMap& other):
MapBase(other),
mMatrix(other.mMatrix),
mMatrixInv(other.mMatrixInv),
mJacobianInv(other.mJacobianInv),
mDeterminant(other.mDeterminant),
mVoxelSize(other.mVoxelSize),
mIsDiagonal(other.mIsDiagonal),
mIsIdentity(other.mIsIdentity)
{
}
/// @brief constructor that merges the matrixes for two affine maps
AffineMap(const AffineMap& first, const AffineMap& second):
mMatrix(first.mMatrix * second.mMatrix)
{
updateAcceleration();
}
~AffineMap() override = default;
/// Return a MapBase::Ptr to a new AffineMap
static MapBase::Ptr create() { return MapBase::Ptr(new AffineMap()); }
/// Return a MapBase::Ptr to a deep copy of this map
MapBase::Ptr copy() const override { return MapBase::Ptr(new AffineMap(*this)); }
MapBase::Ptr inverseMap() const override { return MapBase::Ptr(new AffineMap(mMatrixInv)); }
static bool isRegistered() { return MapRegistry::isRegistered(AffineMap::mapType()); }
static void registerMap()
{
MapRegistry::registerMap(
AffineMap::mapType(),
AffineMap::create);
}
Name type() const override { return mapType(); }
static Name mapType() { return Name("AffineMap"); }
/// Return @c true (an AffineMap is always linear).
bool isLinear() const override { return true; }
/// Return @c false ( test if this is unitary with translation )
bool hasUniformScale() const override
{
Mat3d mat = mMatrix.getMat3();
const double det = mat.det();
if (isApproxEqual(det, double(0))) {
return false;
} else {
mat *= (1.0 / pow(std::abs(det), 1.0/3.0));
return isUnitary(mat);
}
}
bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
bool operator==(const AffineMap& other) const
{
// the Mat.eq() is approximate
if (!mMatrix.eq(other.mMatrix)) { return false; }
if (!mMatrixInv.eq(other.mMatrixInv)) { return false; }
return true;
}
bool operator!=(const AffineMap& other) const { return !(*this == other); }
AffineMap& operator=(const AffineMap& other)
{
mMatrix = other.mMatrix;
mMatrixInv = other.mMatrixInv;
mJacobianInv = other.mJacobianInv;
mDeterminant = other.mDeterminant;
mVoxelSize = other.mVoxelSize;
mIsDiagonal = other.mIsDiagonal;
mIsIdentity = other.mIsIdentity;
return *this;
}
/// Return the image of @c in under the map
Vec3d applyMap(const Vec3d& in) const override { return in * mMatrix; }
/// Return the pre-image of @c in under the map
Vec3d applyInverseMap(const Vec3d& in) const override {return in * mMatrixInv; }
/// Return the Jacobian of the map applied to @a in.
Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const override { return applyJacobian(in); }
/// Return the Jacobian of the map applied to @a in.
Vec3d applyJacobian(const Vec3d& in) const override { return mMatrix.transform3x3(in); }
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const override {
return applyInverseJacobian(in);
}
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in) const override {
return mMatrixInv.transform3x3(in);
}
/// Return the Jacobian Transpose of the map applied to @a in.
/// This tranforms range-space gradients to domain-space gradients
Vec3d applyJT(const Vec3d& in, const Vec3d&) const override { return applyJT(in); }
/// Return the Jacobian Transpose of the map applied to @a in.
Vec3d applyJT(const Vec3d& in) const override {
const double* m = mMatrix.asPointer();
return Vec3d( m[ 0] * in[0] + m[ 1] * in[1] + m[ 2] * in[2],
m[ 4] * in[0] + m[ 5] * in[1] + m[ 6] * in[2],
m[ 8] * in[0] + m[ 9] * in[1] + m[10] * in[2] );
}
/// Return the transpose of the inverse Jacobian of the map applied to @a in.
Vec3d applyIJT(const Vec3d& in, const Vec3d&) const override { return applyIJT(in); }
/// Return the transpose of the inverse Jacobian of the map applied to @c in
Vec3d applyIJT(const Vec3d& in) const override { return in * mJacobianInv; }
/// Return the Jacobian Curvature: zero for a linear map
Mat3d applyIJC(const Mat3d& m) const override {
return mJacobianInv.transpose()* m * mJacobianInv;
}
Mat3d applyIJC(const Mat3d& in, const Vec3d& , const Vec3d& ) const override {
return applyIJC(in);
}
/// Return the determinant of the Jacobian, ignores argument
double determinant(const Vec3d& ) const override { return determinant(); }
/// Return the determinant of the Jacobian
double determinant() const override { return mDeterminant; }
//@{
/// @brief Return the lengths of the images of the segments
/// (0,0,0)-(1,0,0), (0,0,0)-(0,1,0) and (0,0,0)-(0,0,1).
Vec3d voxelSize() const override { return mVoxelSize; }
Vec3d voxelSize(const Vec3d&) const override { return voxelSize(); }
//@}
/// Return @c true if the underlying matrix is approximately an identity
bool isIdentity() const { return mIsIdentity; }
/// Return @c true if the underylying matrix is diagonal
bool isDiagonal() const { return mIsDiagonal; }
/// Return @c true if the map is equivalent to a ScaleMap
bool isScale() const { return isDiagonal(); }
/// Return @c true if the map is equivalent to a ScaleTranslateMap
bool isScaleTranslate() const { return math::isDiagonal(mMatrix.getMat3()); }
// Methods that modify the existing affine map
//@{
/// @brief Modify the existing affine map by pre-applying the given operation.
void accumPreRotation(Axis axis, double radians)
{
mMatrix.preRotate(axis, radians);
updateAcceleration();
}
void accumPreScale(const Vec3d& v)
{
mMatrix.preScale(v);
updateAcceleration();
}
void accumPreTranslation(const Vec3d& v)
{
mMatrix.preTranslate(v);
updateAcceleration();
}
void accumPreShear(Axis axis0, Axis axis1, double shear)
{
mMatrix.preShear(axis0, axis1, shear);
updateAcceleration();
}
//@}
//@{
/// @brief Modify the existing affine map by post-applying the given operation.
void accumPostRotation(Axis axis, double radians)
{
mMatrix.postRotate(axis, radians);
updateAcceleration();
}
void accumPostScale(const Vec3d& v)
{
mMatrix.postScale(v);
updateAcceleration();
}
void accumPostTranslation(const Vec3d& v)
{
mMatrix.postTranslate(v);
updateAcceleration();
}
void accumPostShear(Axis axis0, Axis axis1, double shear)
{
mMatrix.postShear(axis0, axis1, shear);
updateAcceleration();
}
//@}
/// read serialization
void read(std::istream& is) override { mMatrix.read(is); updateAcceleration(); }
/// write serialization
void write(std::ostream& os) const override { mMatrix.write(os); }
/// string serialization, useful for debugging
std::string str() const override
{
std::ostringstream buffer;
buffer << " - mat4:\n" << mMatrix.str() << std::endl;
buffer << " - voxel dimensions: " << mVoxelSize << std::endl;
return buffer.str();
}
/// on-demand decomposition of the affine map
SharedPtr<FullyDecomposedMap> createDecomposedMap()
{
return createFullyDecomposedMap(mMatrix);
}
/// Return AffineMap::Ptr to a deep copy of the current AffineMap
AffineMap::Ptr getAffineMap() const override { return AffineMap::Ptr(new AffineMap(*this)); }
/// Return AffineMap::Ptr to the inverse of this map
AffineMap::Ptr inverse() const { return AffineMap::Ptr(new AffineMap(mMatrixInv)); }
//@{
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the appropraite operation.
MapBase::Ptr preRotate(double radians, Axis axis = X_AXIS) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreRotation(axis, radians);
return simplify(affineMap);
}
MapBase::Ptr preTranslate(const Vec3d& t) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreTranslation(t);
return StaticPtrCast<MapBase, AffineMap>(affineMap);
}
MapBase::Ptr preScale(const Vec3d& s) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreScale(s);
return StaticPtrCast<MapBase, AffineMap>(affineMap);
}
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreShear(axis0, axis1, shear);
return simplify(affineMap);
}
//@}
//@{
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of postfixing the appropraite operation.
MapBase::Ptr postRotate(double radians, Axis axis = X_AXIS) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostRotation(axis, radians);
return simplify(affineMap);
}
MapBase::Ptr postTranslate(const Vec3d& t) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostTranslation(t);
return StaticPtrCast<MapBase, AffineMap>(affineMap);
}
MapBase::Ptr postScale(const Vec3d& s) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostScale(s);
return StaticPtrCast<MapBase, AffineMap>(affineMap);
}
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostShear(axis0, axis1, shear);
return simplify(affineMap);
}
//@}
/// Return the matrix representation of this AffineMap
Mat4d getMat4() const { return mMatrix;}
const Mat4d& getConstMat4() const {return mMatrix;}
const Mat3d& getConstJacobianInv() const {return mJacobianInv;}
private:
void updateAcceleration() {
Mat3d mat3 = mMatrix.getMat3();
mDeterminant = mat3.det();
if (std::abs(mDeterminant) < (3.0 * math::Tolerance<double>::value())) {
OPENVDB_THROW(ArithmeticError,
"Tried to initialize an affine transform from a nearly singular matrix");
}
mMatrixInv = mMatrix.inverse();
mJacobianInv = mat3.inverse().transpose();
mIsDiagonal = math::isDiagonal(mMatrix);
mIsIdentity = math::isIdentity(mMatrix);
Vec3d pos = applyMap(Vec3d(0,0,0));
mVoxelSize(0) = (applyMap(Vec3d(1,0,0)) - pos).length();
mVoxelSize(1) = (applyMap(Vec3d(0,1,0)) - pos).length();
mVoxelSize(2) = (applyMap(Vec3d(0,0,1)) - pos).length();
}
// the underlying matrix
Mat4d mMatrix;
// stored for acceleration
Mat4d mMatrixInv;
Mat3d mJacobianInv;
double mDeterminant;
Vec3d mVoxelSize;
bool mIsDiagonal, mIsIdentity;
}; // class AffineMap
////////////////////////////////////////
/// @brief A specialized Affine transform that scales along the principal axis
/// the scaling need not be uniform in the three-directions
/// @note This class is not marked final because UniformScaleMap inherits from it,
/// so some of the member methods are marked final instead.
class OPENVDB_API ScaleMap: public MapBase
{
public:
using Ptr = SharedPtr<ScaleMap>;
using ConstPtr = SharedPtr<const ScaleMap>;
ScaleMap(): MapBase(), mScaleValues(Vec3d(1,1,1)), mVoxelSize(Vec3d(1,1,1)),
mScaleValuesInverse(Vec3d(1,1,1)),
mInvScaleSqr(1,1,1), mInvTwiceScale(0.5,0.5,0.5){}
ScaleMap(const Vec3d& scale):
MapBase(),
mScaleValues(scale),
mVoxelSize(Vec3d(std::abs(scale(0)),std::abs(scale(1)), std::abs(scale(2))))
{
double determinant = scale[0]* scale[1] * scale[2];
if (std::abs(determinant) < 3.0 * math::Tolerance<double>::value()) {
OPENVDB_THROW(ArithmeticError, "Non-zero scale values required");
}
mScaleValuesInverse = 1.0 / mScaleValues;
mInvScaleSqr = mScaleValuesInverse * mScaleValuesInverse;
mInvTwiceScale = mScaleValuesInverse / 2;
}
ScaleMap(const ScaleMap& other):
MapBase(),
mScaleValues(other.mScaleValues),
mVoxelSize(other.mVoxelSize),
mScaleValuesInverse(other.mScaleValuesInverse),
mInvScaleSqr(other.mInvScaleSqr),
mInvTwiceScale(other.mInvTwiceScale)
{
}
~ScaleMap() override = default;
/// Return a MapBase::Ptr to a new ScaleMap
static MapBase::Ptr create() { return MapBase::Ptr(new ScaleMap()); }
/// Return a MapBase::Ptr to a deep copy of this map
MapBase::Ptr copy() const override { return MapBase::Ptr(new ScaleMap(*this)); }
MapBase::Ptr inverseMap() const override {
return MapBase::Ptr(new ScaleMap(mScaleValuesInverse));
}
static bool isRegistered() { return MapRegistry::isRegistered(ScaleMap::mapType()); }
static void registerMap()
{
MapRegistry::registerMap(
ScaleMap::mapType(),
ScaleMap::create);
}
Name type() const override { return mapType(); }
static Name mapType() { return Name("ScaleMap"); }
/// Return @c true (a ScaleMap is always linear).
bool isLinear() const final { return true; }
/// Return @c true if the values have the same magitude (eg. -1, 1, -1 would be a rotation).
bool hasUniformScale() const final
{
bool value = isApproxEqual(
std::abs(mScaleValues.x()), std::abs(mScaleValues.y()), double(5e-7));
value = value && isApproxEqual(
std::abs(mScaleValues.x()), std::abs(mScaleValues.z()), double(5e-7));
return value;
}
/// Return the image of @c in under the map
Vec3d applyMap(const Vec3d& in) const final
{
return Vec3d(
in.x() * mScaleValues.x(),
in.y() * mScaleValues.y(),
in.z() * mScaleValues.z());
}
/// Return the pre-image of @c in under the map
Vec3d applyInverseMap(const Vec3d& in) const final
{
return Vec3d(
in.x() * mScaleValuesInverse.x(),
in.y() * mScaleValuesInverse.y(),
in.z() * mScaleValuesInverse.z());
}
/// Return the Jacobian of the map applied to @a in.
Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const final {
return applyJacobian(in);
}
/// Return the Jacobian of the map applied to @a in.
Vec3d applyJacobian(const Vec3d& in) const final { return applyMap(in); }
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const final {
return applyInverseJacobian(in);
}
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in) const final {
return applyInverseMap(in);
}
/// @brief Return the Jacobian Transpose of the map applied to @a in.
/// @details This tranforms range-space gradients to domain-space gradients
Vec3d applyJT(const Vec3d& in, const Vec3d&) const final { return applyJT(in); }
/// Return the Jacobian Transpose of the map applied to @a in.
Vec3d applyJT(const Vec3d& in) const final { return applyMap(in); }
/// @brief Return the transpose of the inverse Jacobian of the map applied to @a in.
/// @details Ignores second argument
Vec3d applyIJT(const Vec3d& in, const Vec3d&) const final {
return applyIJT(in);
}
/// Return the transpose of the inverse Jacobian of the map applied to @c in
Vec3d applyIJT(const Vec3d& in) const final { return applyInverseMap(in); }
/// Return the Jacobian Curvature: zero for a linear map
Mat3d applyIJC(const Mat3d& in) const final
{
Mat3d tmp;
for (int i = 0; i < 3; i++) {
tmp.setRow(i, in.row(i) * mScaleValuesInverse(i));
}
for (int i = 0; i < 3; i++) {
tmp.setCol(i, tmp.col(i) * mScaleValuesInverse(i));
}
return tmp;
}
Mat3d applyIJC(const Mat3d& in, const Vec3d&, const Vec3d&) const final {
return applyIJC(in);
}
/// Return the product of the scale values, ignores argument
double determinant(const Vec3d&) const final { return determinant(); }
/// Return the product of the scale values
double determinant() const final {
return mScaleValues.x() * mScaleValues.y() * mScaleValues.z();
}
/// Return the scale values that define the map
const Vec3d& getScale() const {return mScaleValues;}
/// Return the square of the scale. Used to optimize some finite difference calculations
const Vec3d& getInvScaleSqr() const { return mInvScaleSqr; }
/// Return 1/(2 scale). Used to optimize some finite difference calculations
const Vec3d& getInvTwiceScale() const { return mInvTwiceScale; }
/// Return 1/(scale)
const Vec3d& getInvScale() const { return mScaleValuesInverse; }
//@{
/// @brief Return the lengths of the images of the segments
/// (0,0,0) &minus; 1,0,0), (0,0,0) &minus; (0,1,0) and (0,0,0) &minus; (0,0,1).
/// @details This is equivalent to the absolute values of the scale values
Vec3d voxelSize() const final { return mVoxelSize; }
Vec3d voxelSize(const Vec3d&) const final { return voxelSize(); }
//@}
/// read serialization
void read(std::istream& is) override
{
mScaleValues.read(is);
mVoxelSize.read(is);
mScaleValuesInverse.read(is);
mInvScaleSqr.read(is);
mInvTwiceScale.read(is);
}
/// write serialization
void write(std::ostream& os) const override
{
mScaleValues.write(os);
mVoxelSize.write(os);
mScaleValuesInverse.write(os);
mInvScaleSqr.write(os);
mInvTwiceScale.write(os);
}
/// string serialization, useful for debuging
std::string str() const override
{
std::ostringstream buffer;
buffer << " - scale: " << mScaleValues << std::endl;
buffer << " - voxel dimensions: " << mVoxelSize << std::endl;
return buffer.str();
}
bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
bool operator==(const ScaleMap& other) const
{
// ::eq() uses a tolerance
if (!mScaleValues.eq(other.mScaleValues)) { return false; }
return true;
}
bool operator!=(const ScaleMap& other) const { return !(*this == other); }
/// Return a AffineMap equivalent to this map
AffineMap::Ptr getAffineMap() const override
{
return AffineMap::Ptr(new AffineMap(math::scale<Mat4d>(mScaleValues)));
}
//@{
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the appropraite operation to the existing map
MapBase::Ptr preRotate(double radians, Axis axis) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreRotation(axis, radians);
return simplify(affineMap);
}
MapBase::Ptr preTranslate(const Vec3d&) const override;
MapBase::Ptr preScale(const Vec3d&) const override;
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreShear(axis0, axis1, shear);
return simplify(affineMap);
}
//@}
//@{
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the appropraite operation to the existing map.
MapBase::Ptr postRotate(double radians, Axis axis) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostRotation(axis, radians);
return simplify(affineMap);
}
MapBase::Ptr postTranslate(const Vec3d&) const override;
MapBase::Ptr postScale(const Vec3d&) const override;
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostShear(axis0, axis1, shear);
return simplify(affineMap);
}
//@}
private:
Vec3d mScaleValues, mVoxelSize, mScaleValuesInverse, mInvScaleSqr, mInvTwiceScale;
}; // class ScaleMap
/// @brief A specialized Affine transform that scales along the principal axis
/// the scaling is uniform in the three-directions
class OPENVDB_API UniformScaleMap final: public ScaleMap
{
public:
using Ptr = SharedPtr<UniformScaleMap>;
using ConstPtr = SharedPtr<const UniformScaleMap>;
UniformScaleMap(): ScaleMap(Vec3d(1,1,1)) {}
UniformScaleMap(double scale): ScaleMap(Vec3d(scale, scale, scale)) {}
UniformScaleMap(const UniformScaleMap& other): ScaleMap(other) {}
~UniformScaleMap() override = default;
/// Return a MapBase::Ptr to a new UniformScaleMap
static MapBase::Ptr create() { return MapBase::Ptr(new UniformScaleMap()); }
/// Return a MapBase::Ptr to a deep copy of this map
MapBase::Ptr copy() const override { return MapBase::Ptr(new UniformScaleMap(*this)); }
MapBase::Ptr inverseMap() const override
{
const Vec3d& invScale = getInvScale();
return MapBase::Ptr(new UniformScaleMap( invScale[0]));
}
static bool isRegistered() { return MapRegistry::isRegistered(UniformScaleMap::mapType()); }
static void registerMap()
{
MapRegistry::registerMap(
UniformScaleMap::mapType(),
UniformScaleMap::create);
}
Name type() const override { return mapType(); }
static Name mapType() { return Name("UniformScaleMap"); }
bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
bool operator==(const UniformScaleMap& other) const { return ScaleMap::operator==(other); }
bool operator!=(const UniformScaleMap& other) const { return !(*this == other); }
/// @brief Return a MapBase::Ptr to a UniformScaleTraslateMap that is the result of
/// pre-translation on this map
MapBase::Ptr preTranslate(const Vec3d&) const override;
/// @brief Return a MapBase::Ptr to a UniformScaleTraslateMap that is the result of
/// post-translation on this map
MapBase::Ptr postTranslate(const Vec3d&) const override;
}; // class UniformScaleMap
////////////////////////////////////////
inline MapBase::Ptr
ScaleMap::preScale(const Vec3d& v) const
{
const Vec3d new_scale(v * mScaleValues);
if (isApproxEqual(new_scale[0],new_scale[1]) && isApproxEqual(new_scale[0],new_scale[2])) {
return MapBase::Ptr(new UniformScaleMap(new_scale[0]));
} else {
return MapBase::Ptr(new ScaleMap(new_scale));
}
}
inline MapBase::Ptr
ScaleMap::postScale(const Vec3d& v) const
{ // pre-post Scale are the same for a scale map
return preScale(v);
}
/// @brief A specialized linear transform that performs a translation
class OPENVDB_API TranslationMap final: public MapBase
{
public:
using Ptr = SharedPtr<TranslationMap>;
using ConstPtr = SharedPtr<const TranslationMap>;
// default constructor is a translation by zero.
TranslationMap(): MapBase(), mTranslation(Vec3d(0,0,0)) {}
TranslationMap(const Vec3d& t): MapBase(), mTranslation(t) {}
TranslationMap(const TranslationMap& other): MapBase(), mTranslation(other.mTranslation) {}
~TranslationMap() override = default;
/// Return a MapBase::Ptr to a new TranslationMap
static MapBase::Ptr create() { return MapBase::Ptr(new TranslationMap()); }
/// Return a MapBase::Ptr to a deep copy of this map
MapBase::Ptr copy() const override { return MapBase::Ptr(new TranslationMap(*this)); }
MapBase::Ptr inverseMap() const override {
return MapBase::Ptr(new TranslationMap(-mTranslation));
}
static bool isRegistered() { return MapRegistry::isRegistered(TranslationMap::mapType()); }
static void registerMap()
{
MapRegistry::registerMap(
TranslationMap::mapType(),
TranslationMap::create);
}
Name type() const override { return mapType(); }
static Name mapType() { return Name("TranslationMap"); }
/// Return @c true (a TranslationMap is always linear).
bool isLinear() const override { return true; }
/// Return @c false (by convention true)
bool hasUniformScale() const override { return true; }
/// Return the image of @c in under the map
Vec3d applyMap(const Vec3d& in) const override { return in + mTranslation; }
/// Return the pre-image of @c in under the map
Vec3d applyInverseMap(const Vec3d& in) const override { return in - mTranslation; }
/// Return the Jacobian of the map applied to @a in.
Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const override { return applyJacobian(in); }
/// Return the Jacobian of the map applied to @a in.
Vec3d applyJacobian(const Vec3d& in) const override { return in; }
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const override {
return applyInverseJacobian(in);
}
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in) const override { return in; }
/// @brief Return the Jacobian Transpose of the map applied to @a in.
/// @details This tranforms range-space gradients to domain-space gradients
Vec3d applyJT(const Vec3d& in, const Vec3d&) const override { return applyJT(in); }
/// Return the Jacobian Transpose of the map applied to @a in.
Vec3d applyJT(const Vec3d& in) const override { return in; }
/// @brief Return the transpose of the inverse Jacobian (Identity for TranslationMap)
/// of the map applied to @c in, ignores second argument
Vec3d applyIJT(const Vec3d& in, const Vec3d& ) const override { return applyIJT(in);}
/// @brief Return the transpose of the inverse Jacobian (Identity for TranslationMap)
/// of the map applied to @c in
Vec3d applyIJT(const Vec3d& in) const override {return in;}
/// Return the Jacobian Curvature: zero for a linear map
Mat3d applyIJC(const Mat3d& mat) const override {return mat;}
Mat3d applyIJC(const Mat3d& mat, const Vec3d&, const Vec3d&) const override {
return applyIJC(mat);
}
/// Return @c 1
double determinant(const Vec3d& ) const override { return determinant(); }
/// Return @c 1
double determinant() const override { return 1.0; }
/// Return (1,1,1).
Vec3d voxelSize() const override { return Vec3d(1,1,1);}
/// Return (1,1,1).
Vec3d voxelSize(const Vec3d&) const override { return voxelSize();}
/// Return the translation vector
const Vec3d& getTranslation() const { return mTranslation; }
/// read serialization
void read(std::istream& is) override { mTranslation.read(is); }
/// write serialization
void write(std::ostream& os) const override { mTranslation.write(os); }
/// string serialization, useful for debuging
std::string str() const override
{
std::ostringstream buffer;
buffer << " - translation: " << mTranslation << std::endl;
return buffer.str();
}
bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
bool operator==(const TranslationMap& other) const
{
// ::eq() uses a tolerance
return mTranslation.eq(other.mTranslation);
}
bool operator!=(const TranslationMap& other) const { return !(*this == other); }
/// Return AffineMap::Ptr to an AffineMap equivalent to *this
AffineMap::Ptr getAffineMap() const override
{
Mat4d matrix(Mat4d::identity());
matrix.setTranslation(mTranslation);
AffineMap::Ptr affineMap(new AffineMap(matrix));
return affineMap;
}
//@{
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the appropriate operation.
MapBase::Ptr preRotate(double radians, Axis axis) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreRotation(axis, radians);
return simplify(affineMap);
}
MapBase::Ptr preTranslate(const Vec3d& t) const override
{
return MapBase::Ptr(new TranslationMap(t + mTranslation));
}
MapBase::Ptr preScale(const Vec3d& v) const override;
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreShear(axis0, axis1, shear);
return simplify(affineMap);
}
//@}
//@{
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of postfixing the appropriate operation.
MapBase::Ptr postRotate(double radians, Axis axis) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostRotation(axis, radians);
return simplify(affineMap);
}
MapBase::Ptr postTranslate(const Vec3d& t) const override
{ // post and pre are the same for this
return MapBase::Ptr(new TranslationMap(t + mTranslation));
}
MapBase::Ptr postScale(const Vec3d& v) const override;
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostShear(axis0, axis1, shear);
return simplify(affineMap);
}
//@}
private:
Vec3d mTranslation;
}; // class TranslationMap
////////////////////////////////////////
/// @brief A specialized Affine transform that scales along the principal axis
/// the scaling need not be uniform in the three-directions, and then
/// translates the result.
/// @note This class is not marked final because UniformScaleMap inherits from it,
/// so some of the member methods are marked final instead.
class OPENVDB_API ScaleTranslateMap: public MapBase
{
public:
using Ptr = SharedPtr<ScaleTranslateMap>;
using ConstPtr = SharedPtr<const ScaleTranslateMap>;
ScaleTranslateMap():
MapBase(),
mTranslation(Vec3d(0,0,0)),
mScaleValues(Vec3d(1,1,1)),
mVoxelSize(Vec3d(1,1,1)),
mScaleValuesInverse(Vec3d(1,1,1)),
mInvScaleSqr(1,1,1),
mInvTwiceScale(0.5,0.5,0.5)
{
}
ScaleTranslateMap(const Vec3d& scale, const Vec3d& translate):
MapBase(),
mTranslation(translate),
mScaleValues(scale),
mVoxelSize(std::abs(scale(0)), std::abs(scale(1)), std::abs(scale(2)))
{
const double determinant = scale[0]* scale[1] * scale[2];
if (std::abs(determinant) < 3.0 * math::Tolerance<double>::value()) {
OPENVDB_THROW(ArithmeticError, "Non-zero scale values required");
}
mScaleValuesInverse = 1.0 / mScaleValues;
mInvScaleSqr = mScaleValuesInverse * mScaleValuesInverse;
mInvTwiceScale = mScaleValuesInverse / 2;
}
ScaleTranslateMap(const ScaleMap& scale, const TranslationMap& translate):
MapBase(),
mTranslation(translate.getTranslation()),
mScaleValues(scale.getScale()),
mVoxelSize(std::abs(mScaleValues(0)),
std::abs(mScaleValues(1)),
std::abs(mScaleValues(2))),
mScaleValuesInverse(1.0 / scale.getScale())
{
mInvScaleSqr = mScaleValuesInverse * mScaleValuesInverse;
mInvTwiceScale = mScaleValuesInverse / 2;
}
ScaleTranslateMap(const ScaleTranslateMap& other):
MapBase(),
mTranslation(other.mTranslation),
mScaleValues(other.mScaleValues),
mVoxelSize(other.mVoxelSize),
mScaleValuesInverse(other.mScaleValuesInverse),
mInvScaleSqr(other.mInvScaleSqr),
mInvTwiceScale(other.mInvTwiceScale)
{}
~ScaleTranslateMap() override = default;
/// Return a MapBase::Ptr to a new ScaleTranslateMap
static MapBase::Ptr create() { return MapBase::Ptr(new ScaleTranslateMap()); }
/// Return a MapBase::Ptr to a deep copy of this map
MapBase::Ptr copy() const override { return MapBase::Ptr(new ScaleTranslateMap(*this)); }
MapBase::Ptr inverseMap() const override
{
return MapBase::Ptr(new ScaleTranslateMap(
mScaleValuesInverse, -mScaleValuesInverse * mTranslation));
}
static bool isRegistered() { return MapRegistry::isRegistered(ScaleTranslateMap::mapType()); }
static void registerMap()
{
MapRegistry::registerMap(
ScaleTranslateMap::mapType(),
ScaleTranslateMap::create);
}
Name type() const override { return mapType(); }
static Name mapType() { return Name("ScaleTranslateMap"); }
/// Return @c true (a ScaleTranslateMap is always linear).
bool isLinear() const final { return true; }
/// @brief Return @c true if the scale values have the same magnitude
/// (eg. -1, 1, -1 would be a rotation).
bool hasUniformScale() const final
{
bool value = isApproxEqual(
std::abs(mScaleValues.x()), std::abs(mScaleValues.y()), double(5e-7));
value = value && isApproxEqual(
std::abs(mScaleValues.x()), std::abs(mScaleValues.z()), double(5e-7));
return value;
}
/// Return the image of @c under the map
Vec3d applyMap(const Vec3d& in) const final
{
return Vec3d(
in.x() * mScaleValues.x() + mTranslation.x(),
in.y() * mScaleValues.y() + mTranslation.y(),
in.z() * mScaleValues.z() + mTranslation.z());
}
/// Return the pre-image of @c under the map
Vec3d applyInverseMap(const Vec3d& in) const final
{
return Vec3d(
(in.x() - mTranslation.x() ) * mScaleValuesInverse.x(),
(in.y() - mTranslation.y() ) * mScaleValuesInverse.y(),
(in.z() - mTranslation.z() ) * mScaleValuesInverse.z());
}
/// Return the Jacobian of the map applied to @a in.
Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const final {
return applyJacobian(in);
}
/// Return the Jacobian of the map applied to @a in.
Vec3d applyJacobian(const Vec3d& in) const final { return in * mScaleValues; }
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const final {
return applyInverseJacobian(in);
}
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in) const final {
return in * mScaleValuesInverse;
}
/// @brief Return the Jacobian Transpose of the map applied to @a in.
/// @details This tranforms range-space gradients to domain-space gradients
Vec3d applyJT(const Vec3d& in, const Vec3d&) const final { return applyJT(in); }
/// Return the Jacobian Transpose of the map applied to @a in.
Vec3d applyJT(const Vec3d& in) const final { return applyJacobian(in); }
/// @brief Return the transpose of the inverse Jacobian of the map applied to @a in
/// @details Ignores second argument
Vec3d applyIJT(const Vec3d& in, const Vec3d&) const final {
return applyIJT(in);
}
/// Return the transpose of the inverse Jacobian of the map applied to @c in
Vec3d applyIJT(const Vec3d& in) const final
{
return Vec3d(
in.x() * mScaleValuesInverse.x(),
in.y() * mScaleValuesInverse.y(),
in.z() * mScaleValuesInverse.z());
}
/// Return the Jacobian Curvature: zero for a linear map
Mat3d applyIJC(const Mat3d& in) const final
{
Mat3d tmp;
for (int i=0; i<3; i++){
tmp.setRow(i, in.row(i)*mScaleValuesInverse(i));
}
for (int i=0; i<3; i++){
tmp.setCol(i, tmp.col(i)*mScaleValuesInverse(i));
}
return tmp;
}
Mat3d applyIJC(const Mat3d& in, const Vec3d&, const Vec3d& ) const final {
return applyIJC(in);
}
/// Return the product of the scale values, ignores argument
double determinant(const Vec3d&) const final { return determinant(); }
/// Return the product of the scale values
double determinant() const final {
return mScaleValues.x() * mScaleValues.y() * mScaleValues.z();
}
/// Return the absolute values of the scale values
Vec3d voxelSize() const final { return mVoxelSize;}
/// Return the absolute values of the scale values, ignores argument
Vec3d voxelSize(const Vec3d&) const final { return voxelSize();}
/// Returns the scale values
const Vec3d& getScale() const { return mScaleValues; }
/// Returns the translation
const Vec3d& getTranslation() const { return mTranslation; }
/// Return the square of the scale. Used to optimize some finite difference calculations
const Vec3d& getInvScaleSqr() const {return mInvScaleSqr;}
/// Return 1/(2 scale). Used to optimize some finite difference calculations
const Vec3d& getInvTwiceScale() const {return mInvTwiceScale;}
/// Return 1/(scale)
const Vec3d& getInvScale() const {return mScaleValuesInverse; }
/// read serialization
void read(std::istream& is) override
{
mTranslation.read(is);
mScaleValues.read(is);
mVoxelSize.read(is);
mScaleValuesInverse.read(is);
mInvScaleSqr.read(is);
mInvTwiceScale.read(is);
}
/// write serialization
void write(std::ostream& os) const override
{
mTranslation.write(os);
mScaleValues.write(os);
mVoxelSize.write(os);
mScaleValuesInverse.write(os);
mInvScaleSqr.write(os);
mInvTwiceScale.write(os);
}
/// string serialization, useful for debuging
std::string str() const override
{
std::ostringstream buffer;
buffer << " - translation: " << mTranslation << std::endl;
buffer << " - scale: " << mScaleValues << std::endl;
buffer << " - voxel dimensions: " << mVoxelSize << std::endl;
return buffer.str();
}
bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
bool operator==(const ScaleTranslateMap& other) const
{
// ::eq() uses a tolerance
if (!mScaleValues.eq(other.mScaleValues)) { return false; }
if (!mTranslation.eq(other.mTranslation)) { return false; }
return true;
}
bool operator!=(const ScaleTranslateMap& other) const { return !(*this == other); }
/// Return AffineMap::Ptr to an AffineMap equivalent to *this
AffineMap::Ptr getAffineMap() const override
{
AffineMap::Ptr affineMap(new AffineMap(math::scale<Mat4d>(mScaleValues)));
affineMap->accumPostTranslation(mTranslation);
return affineMap;
}
//@{
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the appropraite operation.
MapBase::Ptr preRotate(double radians, Axis axis) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreRotation(axis, radians);
return simplify(affineMap);
}
MapBase::Ptr preTranslate(const Vec3d& t) const override
{
const Vec3d& s = mScaleValues;
const Vec3d scaled_trans( t.x() * s.x(),
t.y() * s.y(),
t.z() * s.z() );
return MapBase::Ptr( new ScaleTranslateMap(mScaleValues, mTranslation + scaled_trans));
}
MapBase::Ptr preScale(const Vec3d& v) const override;
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreShear(axis0, axis1, shear);
return simplify(affineMap);
}
//@}
//@{
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of postfixing the appropraite operation.
MapBase::Ptr postRotate(double radians, Axis axis) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostRotation(axis, radians);
return simplify(affineMap);
}
MapBase::Ptr postTranslate(const Vec3d& t) const override
{
return MapBase::Ptr( new ScaleTranslateMap(mScaleValues, mTranslation + t));
}
MapBase::Ptr postScale(const Vec3d& v) const override;
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostShear(axis0, axis1, shear);
return simplify(affineMap);
}
//@}
private:
Vec3d mTranslation, mScaleValues, mVoxelSize, mScaleValuesInverse,
mInvScaleSqr, mInvTwiceScale;
}; // class ScaleTanslateMap
inline MapBase::Ptr
ScaleMap::postTranslate(const Vec3d& t) const
{
return MapBase::Ptr(new ScaleTranslateMap(mScaleValues, t));
}
inline MapBase::Ptr
ScaleMap::preTranslate(const Vec3d& t) const
{
const Vec3d& s = mScaleValues;
const Vec3d scaled_trans( t.x() * s.x(),
t.y() * s.y(),
t.z() * s.z() );
return MapBase::Ptr(new ScaleTranslateMap(mScaleValues, scaled_trans));
}
/// @brief A specialized Affine transform that uniformaly scales along the principal axis
/// and then translates the result.
class OPENVDB_API UniformScaleTranslateMap final: public ScaleTranslateMap
{
public:
using Ptr = SharedPtr<UniformScaleTranslateMap>;
using ConstPtr = SharedPtr<const UniformScaleTranslateMap>;
UniformScaleTranslateMap():ScaleTranslateMap(Vec3d(1,1,1), Vec3d(0,0,0)) {}
UniformScaleTranslateMap(double scale, const Vec3d& translate):
ScaleTranslateMap(Vec3d(scale,scale,scale), translate) {}
UniformScaleTranslateMap(const UniformScaleMap& scale, const TranslationMap& translate):
ScaleTranslateMap(scale.getScale(), translate.getTranslation()) {}
UniformScaleTranslateMap(const UniformScaleTranslateMap& other):ScaleTranslateMap(other) {}
~UniformScaleTranslateMap() override = default;
/// Return a MapBase::Ptr to a new UniformScaleTranslateMap
static MapBase::Ptr create() { return MapBase::Ptr(new UniformScaleTranslateMap()); }
/// Return a MapBase::Ptr to a deep copy of this map
MapBase::Ptr copy() const override { return MapBase::Ptr(new UniformScaleTranslateMap(*this)); }
MapBase::Ptr inverseMap() const override
{
const Vec3d& scaleInv = getInvScale();
const Vec3d& trans = getTranslation();
return MapBase::Ptr(new UniformScaleTranslateMap(scaleInv[0], -scaleInv[0] * trans));
}
static bool isRegistered()
{
return MapRegistry::isRegistered(UniformScaleTranslateMap::mapType());
}
static void registerMap()
{
MapRegistry::registerMap(
UniformScaleTranslateMap::mapType(), UniformScaleTranslateMap::create);
}
Name type() const override { return mapType(); }
static Name mapType() { return Name("UniformScaleTranslateMap"); }
bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
bool operator==(const UniformScaleTranslateMap& other) const
{
return ScaleTranslateMap::operator==(other);
}
bool operator!=(const UniformScaleTranslateMap& other) const { return !(*this == other); }
/// @brief Return a MapBase::Ptr to a UniformScaleTranslateMap that is
/// the result of prepending translation on this map.
MapBase::Ptr preTranslate(const Vec3d& t) const override
{
const double scale = this->getScale().x();
const Vec3d new_trans = this->getTranslation() + scale * t;
return MapBase::Ptr( new UniformScaleTranslateMap(scale, new_trans));
}
/// @brief Return a MapBase::Ptr to a UniformScaleTranslateMap that is
/// the result of postfixing translation on this map.
MapBase::Ptr postTranslate(const Vec3d& t) const override
{
const double scale = this->getScale().x();
return MapBase::Ptr( new UniformScaleTranslateMap(scale, this->getTranslation() + t));
}
}; // class UniformScaleTanslateMap
inline MapBase::Ptr
UniformScaleMap::postTranslate(const Vec3d& t) const
{
const double scale = this->getScale().x();
return MapBase::Ptr(new UniformScaleTranslateMap(scale, t));
}
inline MapBase::Ptr
UniformScaleMap::preTranslate(const Vec3d& t) const
{
const double scale = this->getScale().x();
return MapBase::Ptr(new UniformScaleTranslateMap(scale, scale*t));
}
inline MapBase::Ptr
TranslationMap::preScale(const Vec3d& v) const
{
if (isApproxEqual(v[0],v[1]) && isApproxEqual(v[0],v[2])) {
return MapBase::Ptr(new UniformScaleTranslateMap(v[0], mTranslation));
} else {
return MapBase::Ptr(new ScaleTranslateMap(v, mTranslation));
}
}
inline MapBase::Ptr
TranslationMap::postScale(const Vec3d& v) const
{
if (isApproxEqual(v[0],v[1]) && isApproxEqual(v[0],v[2])) {
return MapBase::Ptr(new UniformScaleTranslateMap(v[0], v[0]*mTranslation));
} else {
const Vec3d trans(mTranslation.x()*v.x(),
mTranslation.y()*v.y(),
mTranslation.z()*v.z());
return MapBase::Ptr(new ScaleTranslateMap(v, trans));
}
}
inline MapBase::Ptr
ScaleTranslateMap::preScale(const Vec3d& v) const
{
const Vec3d new_scale( v * mScaleValues );
if (isApproxEqual(new_scale[0],new_scale[1]) && isApproxEqual(new_scale[0],new_scale[2])) {
return MapBase::Ptr( new UniformScaleTranslateMap(new_scale[0], mTranslation));
} else {
return MapBase::Ptr( new ScaleTranslateMap(new_scale, mTranslation));
}
}
inline MapBase::Ptr
ScaleTranslateMap::postScale(const Vec3d& v) const
{
const Vec3d new_scale( v * mScaleValues );
const Vec3d new_trans( mTranslation.x()*v.x(),
mTranslation.y()*v.y(),
mTranslation.z()*v.z() );
if (isApproxEqual(new_scale[0],new_scale[1]) && isApproxEqual(new_scale[0],new_scale[2])) {
return MapBase::Ptr( new UniformScaleTranslateMap(new_scale[0], new_trans));
} else {
return MapBase::Ptr( new ScaleTranslateMap(new_scale, new_trans));
}
}
////////////////////////////////////////
/// @brief A specialized linear transform that performs a unitary maping
/// i.e. rotation and or reflection.
class OPENVDB_API UnitaryMap final: public MapBase
{
public:
using Ptr = SharedPtr<UnitaryMap>;
using ConstPtr = SharedPtr<const UnitaryMap>;
/// default constructor makes an Idenity.
UnitaryMap(): mAffineMap(Mat4d::identity())
{
}
UnitaryMap(const Vec3d& axis, double radians)
{
Mat3d matrix;
matrix.setToRotation(axis, radians);
mAffineMap = AffineMap(matrix);
}
UnitaryMap(Axis axis, double radians)
{
Mat4d matrix;
matrix.setToRotation(axis, radians);
mAffineMap = AffineMap(matrix);
}
UnitaryMap(const Mat3d& m)
{
// test that the mat3 is a rotation || reflection
if (!isUnitary(m)) {
OPENVDB_THROW(ArithmeticError, "Matrix initializing unitary map was not unitary");
}
Mat4d matrix(Mat4d::identity());
matrix.setMat3(m);
mAffineMap = AffineMap(matrix);
}
UnitaryMap(const Mat4d& m)
{
if (!isInvertible(m)) {
OPENVDB_THROW(ArithmeticError,
"4x4 Matrix initializing unitary map was not unitary: not invertible");
}
if (!isAffine(m)) {
OPENVDB_THROW(ArithmeticError,
"4x4 Matrix initializing unitary map was not unitary: not affine");
}
if (hasTranslation(m)) {
OPENVDB_THROW(ArithmeticError,
"4x4 Matrix initializing unitary map was not unitary: had translation");
}
if (!isUnitary(m.getMat3())) {
OPENVDB_THROW(ArithmeticError,
"4x4 Matrix initializing unitary map was not unitary");
}
mAffineMap = AffineMap(m);
}
UnitaryMap(const UnitaryMap& other):
MapBase(other),
mAffineMap(other.mAffineMap)
{
}
UnitaryMap(const UnitaryMap& first, const UnitaryMap& second):
mAffineMap(*(first.getAffineMap()), *(second.getAffineMap()))
{
}
~UnitaryMap() override = default;
/// Return a MapBase::Ptr to a new UnitaryMap
static MapBase::Ptr create() { return MapBase::Ptr(new UnitaryMap()); }
/// Returns a MapBase::Ptr to a deep copy of *this
MapBase::Ptr copy() const override { return MapBase::Ptr(new UnitaryMap(*this)); }
MapBase::Ptr inverseMap() const override
{
return MapBase::Ptr(new UnitaryMap(mAffineMap.getMat4().inverse()));
}
static bool isRegistered() { return MapRegistry::isRegistered(UnitaryMap::mapType()); }
static void registerMap()
{
MapRegistry::registerMap(
UnitaryMap::mapType(),
UnitaryMap::create);
}
/// Return @c UnitaryMap
Name type() const override { return mapType(); }
/// Return @c UnitaryMap
static Name mapType() { return Name("UnitaryMap"); }
/// Return @c true (a UnitaryMap is always linear).
bool isLinear() const override { return true; }
/// Return @c false (by convention true)
bool hasUniformScale() const override { return true; }
bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
bool operator==(const UnitaryMap& other) const
{
// compare underlying linear map.
if (mAffineMap!=other.mAffineMap) return false;
return true;
}
bool operator!=(const UnitaryMap& other) const { return !(*this == other); }
/// Return the image of @c in under the map
Vec3d applyMap(const Vec3d& in) const override { return mAffineMap.applyMap(in); }
/// Return the pre-image of @c in under the map
Vec3d applyInverseMap(const Vec3d& in) const override { return mAffineMap.applyInverseMap(in); }
Vec3d applyJacobian(const Vec3d& in, const Vec3d&) const override { return applyJacobian(in); }
/// Return the Jacobian of the map applied to @a in.
Vec3d applyJacobian(const Vec3d& in) const override { return mAffineMap.applyJacobian(in); }
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d&) const override {
return applyInverseJacobian(in);
}
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in) const override {
return mAffineMap.applyInverseJacobian(in);
}
/// @brief Return the Jacobian Transpose of the map applied to @a in.
/// @details This tranforms range-space gradients to domain-space gradients
Vec3d applyJT(const Vec3d& in, const Vec3d&) const override { return applyJT(in); }
/// Return the Jacobian Transpose of the map applied to @a in.
Vec3d applyJT(const Vec3d& in) const override {
return applyInverseMap(in); // the transpose of the unitary map is its inverse
}
/// @brief Return the transpose of the inverse Jacobian of the map applied to @a in
/// @details Ignores second argument
Vec3d applyIJT(const Vec3d& in, const Vec3d& ) const override { return applyIJT(in);}
/// Return the transpose of the inverse Jacobian of the map applied to @c in
Vec3d applyIJT(const Vec3d& in) const override { return mAffineMap.applyIJT(in); }
/// Return the Jacobian Curvature: zero for a linear map
Mat3d applyIJC(const Mat3d& in) const override { return mAffineMap.applyIJC(in); }
Mat3d applyIJC(const Mat3d& in, const Vec3d&, const Vec3d& ) const override {
return applyIJC(in);
}
/// Return the determinant of the Jacobian, ignores argument
double determinant(const Vec3d&) const override { return determinant(); }
/// Return the determinant of the Jacobian
double determinant() const override { return mAffineMap.determinant(); }
/// @{
/// @brief Returns the lengths of the images of the segments
/// (0,0,0) &minus; (1,0,0), (0,0,0) &minus; (0,1,0) and (0,0,0) &minus; (0,0,1).
Vec3d voxelSize() const override { return mAffineMap.voxelSize();}
Vec3d voxelSize(const Vec3d&) const override { return voxelSize();}
/// @}
/// read serialization
void read(std::istream& is) override
{
mAffineMap.read(is);
}
/// write serialization
void write(std::ostream& os) const override
{
mAffineMap.write(os);
}
/// string serialization, useful for debuging
std::string str() const override
{
std::ostringstream buffer;
buffer << mAffineMap.str();
return buffer.str();
}
/// Return AffineMap::Ptr to an AffineMap equivalent to *this
AffineMap::Ptr getAffineMap() const override {
return AffineMap::Ptr(new AffineMap(mAffineMap));
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the given rotation.
MapBase::Ptr preRotate(double radians, Axis axis) const override
{
UnitaryMap first(axis, radians);
UnitaryMap::Ptr unitaryMap(new UnitaryMap(first, *this));
return StaticPtrCast<MapBase, UnitaryMap>(unitaryMap);
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the given translation.
MapBase::Ptr preTranslate(const Vec3d& t) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreTranslation(t);
return simplify(affineMap);
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the given scale.
MapBase::Ptr preScale(const Vec3d& v) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreScale(v);
return simplify(affineMap);
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the given shear.
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPreShear(axis0, axis1, shear);
return simplify(affineMap);
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of appending the given rotation.
MapBase::Ptr postRotate(double radians, Axis axis) const override
{
UnitaryMap second(axis, radians);
UnitaryMap::Ptr unitaryMap(new UnitaryMap(*this, second));
return StaticPtrCast<MapBase, UnitaryMap>(unitaryMap);
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of appending the given translation.
MapBase::Ptr postTranslate(const Vec3d& t) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostTranslation(t);
return simplify(affineMap);
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of appending the given scale.
MapBase::Ptr postScale(const Vec3d& v) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostScale(v);
return simplify(affineMap);
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of appending the given shear.
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
{
AffineMap::Ptr affineMap = getAffineMap();
affineMap->accumPostShear(axis0, axis1, shear);
return simplify(affineMap);
}
private:
AffineMap mAffineMap;
}; // class UnitaryMap
////////////////////////////////////////
/// @brief This map is composed of three steps.
/// First it will take a box of size (Lx X Ly X Lz) defined by a member data bounding box
/// and map it into a frustum with near plane (1 X Ly/Lx) and prescribed depth
/// Then this frustum is transformed by an internal second map: most often a uniform scale,
/// but other effects can be achieved by accumulating translation, shear and rotation: these
/// are all applied to the second map
class OPENVDB_API NonlinearFrustumMap final: public MapBase
{
public:
using Ptr = SharedPtr<NonlinearFrustumMap>;
using ConstPtr = SharedPtr<const NonlinearFrustumMap>;
NonlinearFrustumMap():
MapBase(),
mBBox(Vec3d(0), Vec3d(1)),
mTaper(1),
mDepth(1)
{
init();
}
/// @brief Constructor that takes an index-space bounding box
/// to be mapped into a frustum with a given @a depth and @a taper
/// (defined as ratio of nearplane/farplane).
NonlinearFrustumMap(const BBoxd& bb, double taper, double depth):
MapBase(),mBBox(bb), mTaper(taper), mDepth(depth)
{
init();
}
/// @brief Constructor that takes an index-space bounding box
/// to be mapped into a frustum with a given @a depth and @a taper
/// (defined as ratio of nearplane/farplane).
/// @details This frustum is further modifed by the @a secondMap,
/// intended to be a simple translation and rotation and uniform scale
NonlinearFrustumMap(const BBoxd& bb, double taper, double depth,
const MapBase::Ptr& secondMap):
mBBox(bb), mTaper(taper), mDepth(depth)
{
if (!secondMap->isLinear() ) {
OPENVDB_THROW(ArithmeticError,
"The second map in the Frustum transfrom must be linear");
}
mSecondMap = *( secondMap->getAffineMap() );
init();
}
NonlinearFrustumMap(const NonlinearFrustumMap& other):
MapBase(),
mBBox(other.mBBox),
mTaper(other.mTaper),
mDepth(other.mDepth),
mSecondMap(other.mSecondMap),
mHasSimpleAffine(other.mHasSimpleAffine)
{
init();
}
/// @brief Constructor from a camera frustum
///
/// @param position the tip of the frustum (i.e., the camera's position).
/// @param direction a vector pointing from @a position toward the near plane.
/// @param up a non-unit vector describing the direction and extent of
/// the frustum's intersection on the near plane. Together,
/// @a up must be orthogonal to @a direction.
/// @param aspect the aspect ratio of the frustum intersection with near plane
/// defined as width / height
/// @param z_near,depth the distance from @a position along @a direction to the
/// near and far planes of the frustum.
/// @param x_count the number of voxels, aligned with @a left,
/// across the face of the frustum
/// @param z_count the number of voxels, aligned with @a direction,
/// between the near and far planes
NonlinearFrustumMap(const Vec3d& position,
const Vec3d& direction,
const Vec3d& up,
double aspect /* width / height */,
double z_near, double depth,
Coord::ValueType x_count, Coord::ValueType z_count) {
/// @todo check that depth > 0
/// @todo check up.length > 0
/// @todo check that direction dot up = 0
if (!(depth > 0)) {
OPENVDB_THROW(ArithmeticError,
"The frustum depth must be non-zero and positive");
}
if (!(up.length() > 0)) {
OPENVDB_THROW(ArithmeticError,
"The frustum height must be non-zero and positive");
}
if (!(aspect > 0)) {
OPENVDB_THROW(ArithmeticError,
"The frustum aspect ratio must be non-zero and positive");
}
if (!(isApproxEqual(up.dot(direction), 0.))) {
OPENVDB_THROW(ArithmeticError,
"The frustum up orientation must be perpendicular to into-frustum direction");
}
double near_plane_height = 2 * up.length();
double near_plane_width = aspect * near_plane_height;
Coord::ValueType y_count = static_cast<int>(Round(x_count / aspect));
mBBox = BBoxd(Vec3d(0,0,0), Vec3d(x_count, y_count, z_count));
mDepth = depth / near_plane_width; // depth non-dimensionalized on width
double gamma = near_plane_width / z_near;
mTaper = 1./(mDepth*gamma + 1.);
Vec3d direction_unit = direction;
direction_unit.normalize();
Mat4d r1(Mat4d::identity());
r1.setToRotation(/*from*/Vec3d(0,0,1), /*to */direction_unit);
Mat4d r2(Mat4d::identity());
Vec3d temp = r1.inverse().transform(up);
r2.setToRotation(/*from*/Vec3d(0,1,0), /*to*/temp );
Mat4d scale = math::scale<Mat4d>(
Vec3d(near_plane_width, near_plane_width, near_plane_width));
// move the near plane to origin, rotate to align with axis, and scale down
// T_inv * R1_inv * R2_inv * scale_inv
Mat4d mat = scale * r2 * r1;
mat.setTranslation(position + z_near*direction_unit);
mSecondMap = AffineMap(mat);
init();
}
~NonlinearFrustumMap() override = default;
/// Return a MapBase::Ptr to a new NonlinearFrustumMap
static MapBase::Ptr create() { return MapBase::Ptr(new NonlinearFrustumMap()); }
/// Return a MapBase::Ptr to a deep copy of this map
MapBase::Ptr copy() const override { return MapBase::Ptr(new NonlinearFrustumMap(*this)); }
/// @brief Not implemented, since there is currently no map type that can
/// represent the inverse of a frustum
/// @throw NotImplementedError
MapBase::Ptr inverseMap() const override
{
OPENVDB_THROW(NotImplementedError,
"inverseMap() is not implemented for NonlinearFrustumMap");
}
static bool isRegistered() { return MapRegistry::isRegistered(NonlinearFrustumMap::mapType()); }
static void registerMap()
{
MapRegistry::registerMap(
NonlinearFrustumMap::mapType(),
NonlinearFrustumMap::create);
}
/// Return @c NonlinearFrustumMap
Name type() const override { return mapType(); }
/// Return @c NonlinearFrustumMap
static Name mapType() { return Name("NonlinearFrustumMap"); }
/// Return @c false (a NonlinearFrustumMap is never linear).
bool isLinear() const override { return false; }
/// Return @c false (by convention false)
bool hasUniformScale() const override { return false; }
/// Return @c true if the map is equivalent to an identity
bool isIdentity() const
{
// The frustum can only be consistent with a linear map if the taper value is 1
if (!isApproxEqual(mTaper, double(1)) ) return false;
// There are various ways an identity can decomposed between the two parts of the
// map. Best to just check that the principle vectors are stationary.
const Vec3d e1(1,0,0);
if (!applyMap(e1).eq(e1)) return false;
const Vec3d e2(0,1,0);
if (!applyMap(e2).eq(e2)) return false;
const Vec3d e3(0,0,1);
if (!applyMap(e3).eq(e3)) return false;
return true;
}
bool isEqual(const MapBase& other) const override { return isEqualBase(*this, other); }
bool operator==(const NonlinearFrustumMap& other) const
{
if (mBBox!=other.mBBox) return false;
if (!isApproxEqual(mTaper, other.mTaper)) return false;
if (!isApproxEqual(mDepth, other.mDepth)) return false;
// Two linear transforms are equivalent iff they have the same translation
// and have the same affects on orthongal spanning basis check translation
Vec3d e(0,0,0);
if (!mSecondMap.applyMap(e).eq(other.mSecondMap.applyMap(e))) return false;
/// check spanning vectors
e(0) = 1;
if (!mSecondMap.applyMap(e).eq(other.mSecondMap.applyMap(e))) return false;
e(0) = 0;
e(1) = 1;
if (!mSecondMap.applyMap(e).eq(other.mSecondMap.applyMap(e))) return false;
e(1) = 0;
e(2) = 1;
if (!mSecondMap.applyMap(e).eq(other.mSecondMap.applyMap(e))) return false;
return true;
}
bool operator!=(const NonlinearFrustumMap& other) const { return !(*this == other); }
/// Return the image of @c in under the map
Vec3d applyMap(const Vec3d& in) const override
{
return mSecondMap.applyMap(applyFrustumMap(in));
}
/// Return the pre-image of @c in under the map
Vec3d applyInverseMap(const Vec3d& in) const override
{
return applyFrustumInverseMap(mSecondMap.applyInverseMap(in));
}
/// Return the Jacobian of the linear second map applied to @c in
Vec3d applyJacobian(const Vec3d& in) const override { return mSecondMap.applyJacobian(in); }
/// Return the Jacobian defined at @c isloc applied to @c in
Vec3d applyJacobian(const Vec3d& in, const Vec3d& isloc) const override
{
// Move the center of the x-face of the bbox
// to the origin in index space.
Vec3d centered(isloc);
centered = centered - mBBox.min();
centered.x() -= mXo;
centered.y() -= mYo;
// scale the z-direction on depth / K count
const double zprime = centered.z()*mDepthOnLz;
const double scale = (mGamma * zprime + 1.) / mLx;
const double scale2 = mGamma * mDepthOnLz / mLx;
const Vec3d tmp(scale * in.x() + scale2 * centered.x()* in.z(),
scale * in.y() + scale2 * centered.y()* in.z(),
mDepthOnLz * in.z());
return mSecondMap.applyJacobian(tmp);
}
/// @brief Return the Inverse Jacobian of the map applied to @a in
/// (i.e. inverse map with out translation)
Vec3d applyInverseJacobian(const Vec3d& in) const override {
return mSecondMap.applyInverseJacobian(in);
}
/// Return the Inverse Jacobian defined at @c isloc of the map applied to @a in.
Vec3d applyInverseJacobian(const Vec3d& in, const Vec3d& isloc) const override {
// Move the center of the x-face of the bbox
// to the origin in index space.
Vec3d centered(isloc);
centered = centered - mBBox.min();
centered.x() -= mXo;
centered.y() -= mYo;
// scale the z-direction on depth / K count
const double zprime = centered.z()*mDepthOnLz;
const double scale = (mGamma * zprime + 1.) / mLx;
const double scale2 = mGamma * mDepthOnLz / mLx;
Vec3d out = mSecondMap.applyInverseJacobian(in);
out.x() = (out.x() - scale2 * centered.x() * out.z() / mDepthOnLz) / scale;
out.y() = (out.y() - scale2 * centered.y() * out.z() / mDepthOnLz) / scale;
out.z() = out.z() / mDepthOnLz;
return out;
}
/// @brief Return the Jacobian Transpose of the map applied to vector @c in at @c indexloc.
/// @details This tranforms range-space gradients to domain-space gradients.
Vec3d applyJT(const Vec3d& in, const Vec3d& isloc) const override {
const Vec3d tmp = mSecondMap.applyJT(in);
// Move the center of the x-face of the bbox
// to the origin in index space.
Vec3d centered(isloc);
centered = centered - mBBox.min();
centered.x() -= mXo;
centered.y() -= mYo;
// scale the z-direction on depth / K count
const double zprime = centered.z()*mDepthOnLz;
const double scale = (mGamma * zprime + 1.) / mLx;
const double scale2 = mGamma * mDepthOnLz / mLx;
return Vec3d(scale * tmp.x(),
scale * tmp.y(),
scale2 * centered.x()* tmp.x() +
scale2 * centered.y()* tmp.y() +
mDepthOnLz * tmp.z());
}
/// Return the Jacobian Transpose of the second map applied to @c in.
Vec3d applyJT(const Vec3d& in) const override {
return mSecondMap.applyJT(in);
}
/// Return the transpose of the inverse Jacobian of the linear second map applied to @c in
Vec3d applyIJT(const Vec3d& in) const override { return mSecondMap.applyIJT(in); }
// the Jacobian of the nonlinear part of the transform is a sparse matrix
// Jacobian^(-T) =
//
// (Lx)( 1/s 0 0 )
// ( 0 1/s 0 )
// ( -(x-xo)g/(sLx) -(y-yo)g/(sLx) Lz/(Depth Lx) )
/// Return the transpose of the inverse Jacobain (at @c locW applied to @c in.
/// @c ijk is the location in the pre-image space (e.g. index space)
Vec3d applyIJT(const Vec3d& d1_is, const Vec3d& ijk) const override
{
const Vec3d loc = applyFrustumMap(ijk);
const double s = mGamma * loc.z() + 1.;
// verify that we aren't at the singularity
if (isApproxEqual(s, 0.)) {
OPENVDB_THROW(ArithmeticError, "Tried to evaluate the frustum transform"
" at the singular focal point (e.g. camera)");
}
const double sinv = 1.0/s; // 1/(z*gamma + 1)
const double pt0 = mLx * sinv; // Lx / (z*gamma +1)
const double pt1 = mGamma * pt0; // gamma * Lx / ( z*gamma +1)
const double pt2 = pt1 * sinv; // gamma * Lx / ( z*gamma +1)**2
const Mat3d& jacinv = mSecondMap.getConstJacobianInv();
// compute \frac{\partial E_i}{\partial x_j}
Mat3d gradE(Mat3d::zero());
for (int j = 0; j < 3; ++j ) {
gradE(0,j) = pt0 * jacinv(0,j) - pt2 * loc.x()*jacinv(2,j);
gradE(1,j) = pt0 * jacinv(1,j) - pt2 * loc.y()*jacinv(2,j);
gradE(2,j) = (1./mDepthOnLz) * jacinv(2,j);
}
Vec3d result;
for (int i = 0; i < 3; ++i) {
result(i) = d1_is(0) * gradE(0,i) + d1_is(1) * gradE(1,i) + d1_is(2) * gradE(2,i);
}
return result;
}
/// Return the Jacobian Curvature for the linear second map
Mat3d applyIJC(const Mat3d& in) const override { return mSecondMap.applyIJC(in); }
/// Return the Jacobian Curvature: all the second derivatives in range space
/// @param d2_is second derivative matrix computed in index space
/// @param d1_is gradient computed in index space
/// @param ijk the index space location where the result is computed
Mat3d applyIJC(const Mat3d& d2_is, const Vec3d& d1_is, const Vec3d& ijk) const override
{
const Vec3d loc = applyFrustumMap(ijk);
const double s = mGamma * loc.z() + 1.;
// verify that we aren't at the singularity
if (isApproxEqual(s, 0.)) {
OPENVDB_THROW(ArithmeticError, "Tried to evaluate the frustum transform"
" at the singular focal point (e.g. camera)");
}
// precompute
const double sinv = 1.0/s; // 1/(z*gamma + 1)
const double pt0 = mLx * sinv; // Lx / (z*gamma +1)
const double pt1 = mGamma * pt0; // gamma * Lx / ( z*gamma +1)
const double pt2 = pt1 * sinv; // gamma * Lx / ( z*gamma +1)**2
const double pt3 = pt2 * sinv; // gamma * Lx / ( z*gamma +1)**3
const Mat3d& jacinv = mSecondMap.getConstJacobianInv();
// compute \frac{\partial^2 E_i}{\partial x_j \partial x_k}
Mat3d matE0(Mat3d::zero());
Mat3d matE1(Mat3d::zero()); // matE2 = 0
for(int j = 0; j < 3; j++) {
for (int k = 0; k < 3; k++) {
const double pt4 = 2. * jacinv(2,j) * jacinv(2,k) * pt3;
matE0(j,k) = -(jacinv(0,j) * jacinv(2,k) + jacinv(2,j) * jacinv(0,k)) * pt2 +
pt4 * loc.x();
matE1(j,k) = -(jacinv(1,j) * jacinv(2,k) + jacinv(2,j) * jacinv(1,k)) * pt2 +
pt4 * loc.y();
}
}
// compute \frac{\partial E_i}{\partial x_j}
Mat3d gradE(Mat3d::zero());
for (int j = 0; j < 3; ++j ) {
gradE(0,j) = pt0 * jacinv(0,j) - pt2 * loc.x()*jacinv(2,j);
gradE(1,j) = pt0 * jacinv(1,j) - pt2 * loc.y()*jacinv(2,j);
gradE(2,j) = (1./mDepthOnLz) * jacinv(2,j);
}
Mat3d result(Mat3d::zero());
// compute \fac{\partial E_j}{\partial x_m} \fac{\partial E_i}{\partial x_n}
// \frac{\partial^2 input}{\partial E_i \partial E_j}
for (int m = 0; m < 3; ++m ) {
for ( int n = 0; n < 3; ++n) {
for (int i = 0; i < 3; ++i ) {
for (int j = 0; j < 3; ++j) {
result(m, n) += gradE(j, m) * gradE(i, n) * d2_is(i, j);
}
}
}
}
for (int m = 0; m < 3; ++m ) {
for ( int n = 0; n < 3; ++n) {
result(m, n) +=
matE0(m, n) * d1_is(0) + matE1(m, n) * d1_is(1);// + matE2(m, n) * d1_is(2);
}
}
return result;
}
/// Return the determinant of the Jacobian of linear second map
double determinant() const override {return mSecondMap.determinant();} // no implementation
/// Return the determinate of the Jacobian evaluated at @c loc
/// @c loc is a location in the pre-image space (e.g., index space)
double determinant(const Vec3d& loc) const override
{
double s = mGamma * loc.z() + 1.0;
double frustum_determinant = s * s * mDepthOnLzLxLx;
return mSecondMap.determinant() * frustum_determinant;
}
/// Return the size of a voxel at the center of the near plane
Vec3d voxelSize() const override
{
const Vec3d loc( 0.5*(mBBox.min().x() + mBBox.max().x()),
0.5*(mBBox.min().y() + mBBox.max().y()),
mBBox.min().z());
return voxelSize(loc);
}
/// @brief Returns the lengths of the images of the three segments
/// from @a loc to @a loc + (1,0,0), from @a loc to @a loc + (0,1,0)
/// and from @a loc to @a loc + (0,0,1)
/// @param loc a location in the pre-image space (e.g., index space)
Vec3d voxelSize(const Vec3d& loc) const override
{
Vec3d out, pos = applyMap(loc);
out(0) = (applyMap(loc + Vec3d(1,0,0)) - pos).length();
out(1) = (applyMap(loc + Vec3d(0,1,0)) - pos).length();
out(2) = (applyMap(loc + Vec3d(0,0,1)) - pos).length();
return out;
}
AffineMap::Ptr getAffineMap() const override { return mSecondMap.getAffineMap(); }
/// set the taper value, the ratio of nearplane width / far plane width
void setTaper(double t) { mTaper = t; init();}
/// Return the taper value.
double getTaper() const { return mTaper; }
/// set the frustum depth: distance between near and far plane = frustm depth * frustm x-width
void setDepth(double d) { mDepth = d; init();}
/// Return the unscaled frustm depth
double getDepth() const { return mDepth; }
// gamma a non-dimensional number: nearplane x-width / camera to near plane distance
double getGamma() const { return mGamma; }
/// Return the bounding box that defines the frustum in pre-image space
const BBoxd& getBBox() const { return mBBox; }
/// Return MapBase::Ptr& to the second map
const AffineMap& secondMap() const { return mSecondMap; }
/// Return @c true if the the bounding box in index space that defines the region that
/// is maped into the frustum is non-zero, otherwise @c false
bool isValid() const { return !mBBox.empty();}
/// Return @c true if the second map is a uniform scale, Rotation and translation
bool hasSimpleAffine() const { return mHasSimpleAffine; }
/// read serialization
void read(std::istream& is) override
{
// for backward compatibility with earlier version
if (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_FLOAT_FRUSTUM_BBOX ) {
CoordBBox bb;
bb.read(is);
mBBox = BBoxd(bb.min().asVec3d(), bb.max().asVec3d());
} else {
mBBox.read(is);
}
is.read(reinterpret_cast<char*>(&mTaper), sizeof(double));
is.read(reinterpret_cast<char*>(&mDepth), sizeof(double));
// Read the second maps type.
Name type = readString(is);
// Check if the map has been registered.
if(!MapRegistry::isRegistered(type)) {
OPENVDB_THROW(KeyError, "Map " << type << " is not registered");
}
// Create the second map of the type and then read it in.
MapBase::Ptr proxy = math::MapRegistry::createMap(type);
proxy->read(is);
mSecondMap = *(proxy->getAffineMap());
init();
}
/// write serialization
void write(std::ostream& os) const override
{
mBBox.write(os);
os.write(reinterpret_cast<const char*>(&mTaper), sizeof(double));
os.write(reinterpret_cast<const char*>(&mDepth), sizeof(double));
writeString(os, mSecondMap.type());
mSecondMap.write(os);
}
/// string serialization, useful for debuging
std::string str() const override
{
std::ostringstream buffer;
buffer << " - taper: " << mTaper << std::endl;
buffer << " - depth: " << mDepth << std::endl;
buffer << " SecondMap: "<< mSecondMap.type() << std::endl;
buffer << mSecondMap.str() << std::endl;
return buffer.str();
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the given rotation to the linear part of this map
MapBase::Ptr preRotate(double radians, Axis axis = X_AXIS) const override
{
return MapBase::Ptr(
new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.preRotate(radians, axis)));
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the given translation to the linear part of this map
MapBase::Ptr preTranslate(const Vec3d& t) const override
{
return MapBase::Ptr(
new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.preTranslate(t)));
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the given scale to the linear part of this map
MapBase::Ptr preScale(const Vec3d& s) const override
{
return MapBase::Ptr(
new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.preScale(s)));
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of prepending the given shear to the linear part of this map
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
{
return MapBase::Ptr(new NonlinearFrustumMap(
mBBox, mTaper, mDepth, mSecondMap.preShear(shear, axis0, axis1)));
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of appending the given rotation to the linear part of this map.
MapBase::Ptr postRotate(double radians, Axis axis = X_AXIS) const override
{
return MapBase::Ptr(
new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.postRotate(radians, axis)));
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of appending the given translation to the linear part of this map.
MapBase::Ptr postTranslate(const Vec3d& t) const override
{
return MapBase::Ptr(
new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.postTranslate(t)));
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of appending the given scale to the linear part of this map.
MapBase::Ptr postScale(const Vec3d& s) const override
{
return MapBase::Ptr(
new NonlinearFrustumMap(mBBox, mTaper, mDepth, mSecondMap.postScale(s)));
}
/// @brief Return a MapBase::Ptr to a new map that is the result
/// of appending the given shear to the linear part of this map.
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
{
return MapBase::Ptr(new NonlinearFrustumMap(
mBBox, mTaper, mDepth, mSecondMap.postShear(shear, axis0, axis1)));
}
private:
void init()
{
// set up as a frustum
mLx = mBBox.extents().x();
mLy = mBBox.extents().y();
mLz = mBBox.extents().z();
if (isApproxEqual(mLx,0.) || isApproxEqual(mLy,0.) || isApproxEqual(mLz,0.) ) {
OPENVDB_THROW(ArithmeticError, "The index space bounding box"
" must have at least two index points in each direction.");
}
mXo = 0.5* mLx;
mYo = 0.5* mLy;
// mDepth is non-dimensionalized on near
mGamma = (1./mTaper - 1) / mDepth;
mDepthOnLz = mDepth/mLz;
mDepthOnLzLxLx = mDepthOnLz/(mLx * mLx);
/// test for shear and non-uniform scale
mHasSimpleAffine = true;
Vec3d tmp = mSecondMap.voxelSize();
/// false if there is non-uniform scale
if (!isApproxEqual(tmp(0), tmp(1))) { mHasSimpleAffine = false; return; }
if (!isApproxEqual(tmp(0), tmp(2))) { mHasSimpleAffine = false; return; }
Vec3d trans = mSecondMap.applyMap(Vec3d(0,0,0));
/// look for shear
Vec3d tmp1 = mSecondMap.applyMap(Vec3d(1,0,0)) - trans;
Vec3d tmp2 = mSecondMap.applyMap(Vec3d(0,1,0)) - trans;
Vec3d tmp3 = mSecondMap.applyMap(Vec3d(0,0,1)) - trans;
/// false if there is shear
if (!isApproxEqual(tmp1.dot(tmp2), 0., 1.e-7)) { mHasSimpleAffine = false; return; }
if (!isApproxEqual(tmp2.dot(tmp3), 0., 1.e-7)) { mHasSimpleAffine = false; return; }
if (!isApproxEqual(tmp3.dot(tmp1), 0., 1.e-7)) { mHasSimpleAffine = false; return; }
}
Vec3d applyFrustumMap(const Vec3d& in) const
{
// Move the center of the x-face of the bbox
// to the origin in index space.
Vec3d out(in);
out = out - mBBox.min();
out.x() -= mXo;
out.y() -= mYo;
// scale the z-direction on depth / K count
out.z() *= mDepthOnLz;
double scale = (mGamma * out.z() + 1.)/ mLx;
// scale the x-y on the length I count and apply tapper
out.x() *= scale ;
out.y() *= scale ;
return out;
}
Vec3d applyFrustumInverseMap(const Vec3d& in) const
{
// invert taper and resize: scale = 1/( (z+1)/2 (mt-1) + 1)
Vec3d out(in);
double invScale = mLx / (mGamma * out.z() + 1.);
out.x() *= invScale;
out.y() *= invScale;
out.x() += mXo;
out.y() += mYo;
out.z() /= mDepthOnLz;
// move back
out = out + mBBox.min();
return out;
}
// bounding box in index space used in Frustum transforms.
BBoxd mBBox;
// taper value used in constructing Frustums.
double mTaper;
double mDepth;
// defines the second map
AffineMap mSecondMap;
// these are derived from the above.
double mLx, mLy, mLz;
double mXo, mYo, mGamma, mDepthOnLz, mDepthOnLzLxLx;
// true: if the mSecondMap is linear and has no shear, and has no non-uniform scale
bool mHasSimpleAffine;
}; // class NonlinearFrustumMap
////////////////////////////////////////
/// @brief Creates the composition of two maps, each of which could be a composition.
/// In the case that each component of the composition classified as linear an
/// acceleration AffineMap is stored.
template<typename FirstMapType, typename SecondMapType>
class CompoundMap
{
public:
using MyType = CompoundMap<FirstMapType, SecondMapType>;
using Ptr = SharedPtr<MyType>;
using ConstPtr = SharedPtr<const MyType>;
CompoundMap() { updateAffineMatrix(); }
CompoundMap(const FirstMapType& f, const SecondMapType& s): mFirstMap(f), mSecondMap(s)
{
updateAffineMatrix();
}
CompoundMap(const MyType& other):
mFirstMap(other.mFirstMap),
mSecondMap(other.mSecondMap),
mAffineMap(other.mAffineMap)
{}
Name type() const { return mapType(); }
static Name mapType()
{
return (FirstMapType::mapType() + Name(":") + SecondMapType::mapType());
}
bool operator==(const MyType& other) const
{
if (mFirstMap != other.mFirstMap) return false;
if (mSecondMap != other.mSecondMap) return false;
if (mAffineMap != other.mAffineMap) return false;
return true;
}
bool operator!=(const MyType& other) const { return !(*this == other); }
MyType& operator=(const MyType& other)
{
mFirstMap = other.mFirstMap;
mSecondMap = other.mSecondMap;
mAffineMap = other.mAffineMap;
return *this;
}
bool isIdentity() const
{
if (is_linear<MyType>::value) {
return mAffineMap.isIdentity();
} else {
return mFirstMap.isIdentity()&&mSecondMap.isIdentity();
}
}
bool isDiagonal() const {
if (is_linear<MyType>::value) {
return mAffineMap.isDiagonal();
} else {
return mFirstMap.isDiagonal()&&mSecondMap.isDiagonal();
}
}
AffineMap::Ptr getAffineMap() const
{
if (is_linear<MyType>::value) {
AffineMap::Ptr affine(new AffineMap(mAffineMap));
return affine;
} else {
OPENVDB_THROW(ArithmeticError,
"Constant affine matrix representation not possible for this nonlinear map");
}
}
// direct decompotion
const FirstMapType& firstMap() const { return mFirstMap; }
const SecondMapType& secondMap() const {return mSecondMap; }
void setFirstMap(const FirstMapType& first) { mFirstMap = first; updateAffineMatrix(); }
void setSecondMap(const SecondMapType& second) { mSecondMap = second; updateAffineMatrix(); }
void read(std::istream& is)
{
mAffineMap.read(is);
mFirstMap.read(is);
mSecondMap.read(is);
}
void write(std::ostream& os) const
{
mAffineMap.write(os);
mFirstMap.write(os);
mSecondMap.write(os);
}
private:
void updateAffineMatrix()
{
if (is_linear<MyType>::value) {
// both maps need to be linear, these methods are only defined for linear maps
AffineMap::Ptr first = mFirstMap.getAffineMap();
AffineMap::Ptr second= mSecondMap.getAffineMap();
mAffineMap = AffineMap(*first, *second);
}
}
FirstMapType mFirstMap;
SecondMapType mSecondMap;
// used for acceleration
AffineMap mAffineMap;
}; // class CompoundMap
} // namespace math
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
#endif // OPENVDB_MATH_MAPS_HAS_BEEN_INCLUDED
BBox.h
Coord.h
value
ValueT value
Definition GridBuilder.h:1290
Mat4.h
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Name.h
OPENVDB_API
#define OPENVDB_API
Definition Platform.h:251
Vec3.h
openvdb::v10_0::ArithmeticError
Definition Exceptions.h:56
openvdb::v10_0::KeyError
Definition Exceptions.h:59
openvdb::v10_0::NotImplementedError
Definition Exceptions.h:61
openvdb::v10_0::math::AffineMap
A general linear transform using homogeneous coordinates to perform rotation, scaling,...
Definition Maps.h:299
openvdb::v10_0::math::AffineMap::postScale
MapBase::Ptr postScale(const Vec3d &s) const override
Definition Maps.h:601
openvdb::v10_0::math::AffineMap::accumPostShear
void accumPostShear(Axis axis0, Axis axis1, double shear)
Definition Maps.h:522
openvdb::v10_0::math::AffineMap::registerMap
static void registerMap()
Definition Maps.h:363
openvdb::v10_0::math::AffineMap::AffineMap
AffineMap()
Definition Maps.h:304
openvdb::v10_0::math::AffineMap::write
void write(std::ostream &os) const override
write serialization
Definition Maps.h:533
openvdb::v10_0::math::AffineMap::voxelSize
Vec3d voxelSize(const Vec3d &) const override
Definition Maps.h:465
openvdb::v10_0::math::AffineMap::AffineMap
AffineMap(const Mat3d &m)
Definition Maps.h:316
openvdb::v10_0::math::AffineMap::isDiagonal
bool isDiagonal() const
Return true if the underylying matrix is diagonal.
Definition Maps.h:471
openvdb::v10_0::math::AffineMap::applyJT
Vec3d applyJT(const Vec3d &in, const Vec3d &) const override
Definition Maps.h:436
openvdb::v10_0::math::AffineMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Definition Maps.h:607
openvdb::v10_0::math::AffineMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Definition Maps.h:577
openvdb::v10_0::math::AffineMap::accumPostRotation
void accumPostRotation(Axis axis, double radians)
Modify the existing affine map by post-applying the given operation.
Definition Maps.h:507
openvdb::v10_0::math::AffineMap::accumPreShear
void accumPreShear(Axis axis0, Axis axis1, double shear)
Definition Maps.h:497
openvdb::v10_0::math::AffineMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &t) const override
Definition Maps.h:595
openvdb::v10_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:448
openvdb::v10_0::math::AffineMap::AffineMap
AffineMap(const AffineMap &first, const AffineMap &second)
constructor that merges the matrixes for two affine maps
Definition Maps.h:346
openvdb::v10_0::math::AffineMap::getMat4
Mat4d getMat4() const
Return the matrix representation of this AffineMap.
Definition Maps.h:616
openvdb::v10_0::math::AffineMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition Maps.h:370
openvdb::v10_0::math::AffineMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return AffineMap::Ptr to a deep copy of the current AffineMap.
Definition Maps.h:550
openvdb::v10_0::math::AffineMap::determinant
double determinant(const Vec3d &) const override
Return the determinant of the Jacobian, ignores argument.
Definition Maps.h:457
openvdb::v10_0::math::AffineMap::operator!=
bool operator!=(const AffineMap &other) const
Definition Maps.h:399
openvdb::v10_0::math::AffineMap::hasUniformScale
bool hasUniformScale() const override
Return false ( test if this is unitary with translation ).
Definition Maps.h:377
openvdb::v10_0::math::AffineMap::operator==
bool operator==(const AffineMap &other) const
Definition Maps.h:391
openvdb::v10_0::math::AffineMap::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 postfixing the appropraite operation.
Definition Maps.h:589
openvdb::v10_0::math::AffineMap::applyJT
Vec3d applyJT(const Vec3d &in) const override
Return the Jacobian Transpose of the map applied to in.
Definition Maps.h:438
openvdb::v10_0::math::AffineMap::determinant
double determinant() const override
Return the determinant of the Jacobian.
Definition Maps.h:459
openvdb::v10_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:419
openvdb::v10_0::math::AffineMap::applyIJC
Mat3d applyIJC(const Mat3d &in, const Vec3d &, const Vec3d &) const override
Definition Maps.h:453
openvdb::v10_0::math::AffineMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition Maps.h:357
openvdb::v10_0::math::AffineMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const override
Return the Jacobian of the map applied to in.
Definition Maps.h:421
openvdb::v10_0::math::AffineMap::str
std::string str() const override
string serialization, useful for debugging
Definition Maps.h:535
openvdb::v10_0::math::AffineMap::inverse
AffineMap::Ptr inverse() const
Return AffineMap::Ptr to the inverse of this map.
Definition Maps.h:553
openvdb::v10_0::math::AffineMap::isLinear
bool isLinear() const override
Return true (an AffineMap is always linear).
Definition Maps.h:374
openvdb::v10_0::math::AffineMap::getConstJacobianInv
const Mat3d & getConstJacobianInv() const
Definition Maps.h:618
openvdb::v10_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:425
openvdb::v10_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:430
openvdb::v10_0::math::AffineMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &t) const override
Definition Maps.h:565
openvdb::v10_0::math::AffineMap::voxelSize
Vec3d voxelSize() 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:464
openvdb::v10_0::math::AffineMap::preScale
MapBase::Ptr preScale(const Vec3d &s) const override
Definition Maps.h:571
openvdb::v10_0::math::AffineMap::isRegistered
static bool isRegistered()
Definition Maps.h:361
openvdb::v10_0::math::AffineMap::isScaleTranslate
bool isScaleTranslate() const
Return true if the map is equivalent to a ScaleTranslateMap.
Definition Maps.h:475
openvdb::v10_0::math::AffineMap::AffineMap
AffineMap(const AffineMap &other)
Definition Maps.h:333
openvdb::v10_0::math::AffineMap::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 appropraite operation.
Definition Maps.h:559
openvdb::v10_0::math::AffineMap::getConstMat4
const Mat4d & getConstMat4() const
Definition Maps.h:617
openvdb::v10_0::math::AffineMap::operator=
AffineMap & operator=(const AffineMap &other)
Definition Maps.h:401
openvdb::v10_0::math::AffineMap::applyIJC
Mat3d applyIJC(const Mat3d &m) const override
Return the Jacobian Curvature: zero for a linear map.
Definition Maps.h:450
openvdb::v10_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:446
openvdb::v10_0::math::AffineMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition Maps.h:414
openvdb::v10_0::math::AffineMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition Maps.h:359
openvdb::v10_0::math::AffineMap::isIdentity
bool isIdentity() const
Return true if the underlying matrix is approximately an identity.
Definition Maps.h:469
openvdb::v10_0::math::AffineMap::ConstPtr
SharedPtr< const AffineMap > ConstPtr
Definition Maps.h:302
openvdb::v10_0::math::AffineMap::read
void read(std::istream &is) override
read serialization
Definition Maps.h:531
openvdb::v10_0::math::AffineMap::accumPreRotation
void accumPreRotation(Axis axis, double radians)
Modify the existing affine map by pre-applying the given operation.
Definition Maps.h:482
openvdb::v10_0::math::AffineMap::isScale
bool isScale() const
Return true if the map is equivalent to a ScaleMap.
Definition Maps.h:473
openvdb::v10_0::math::AffineMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition Maps.h:416
openvdb::v10_0::math::AffineMap::accumPreScale
void accumPreScale(const Vec3d &v)
Definition Maps.h:487
openvdb::v10_0::math::AffineMap::accumPreTranslation
void accumPreTranslation(const Vec3d &v)
Definition Maps.h:492
openvdb::v10_0::math::AffineMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new AffineMap.
Definition Maps.h:355
openvdb::v10_0::math::AffineMap::createDecomposedMap
SharedPtr< FullyDecomposedMap > createDecomposedMap()
on-demand decomposition of the affine map
Definition Maps.h:544
openvdb::v10_0::math::AffineMap::Ptr
SharedPtr< AffineMap > Ptr
Definition Maps.h:301
openvdb::v10_0::math::AffineMap::accumPostScale
void accumPostScale(const Vec3d &v)
Definition Maps.h:512
openvdb::v10_0::math::AffineMap::~AffineMap
~AffineMap() override=default
openvdb::v10_0::math::AffineMap::mapType
static Name mapType()
Definition Maps.h:371
openvdb::v10_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:389
openvdb::v10_0::math::AffineMap::accumPostTranslation
void accumPostTranslation(const Vec3d &v)
Definition Maps.h:517
openvdb::v10_0::math::AffineMap::AffineMap
AffineMap(const Mat4d &m)
Definition Maps.h:324
openvdb::v10_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:2596
openvdb::v10_0::math::CompoundMap< UnitaryMap, TranslationMap >::MyType
CompoundMap< UnitaryMap, TranslationMap > MyType
Definition Maps.h:2598
openvdb::v10_0::math::CompoundMap< UnitaryMap, TranslationMap >::Ptr
SharedPtr< MyType > Ptr
Definition Maps.h:2600
openvdb::v10_0::math::CompoundMap::secondMap
const SecondMapType & secondMap() const
Definition Maps.h:2671
openvdb::v10_0::math::CompoundMap::firstMap
const FirstMapType & firstMap() const
Definition Maps.h:2670
openvdb::v10_0::math::CompoundMap::setSecondMap
void setSecondMap(const SecondMapType &second)
Definition Maps.h:2674
openvdb::v10_0::math::CompoundMap::isDiagonal
bool isDiagonal() const
Definition Maps.h:2650
openvdb::v10_0::math::CompoundMap< UnitaryMap, TranslationMap >::ConstPtr
SharedPtr< const MyType > ConstPtr
Definition Maps.h:2601
openvdb::v10_0::math::CompoundMap::write
void write(std::ostream &os) const
Definition Maps.h:2682
openvdb::v10_0::math::CompoundMap::setFirstMap
void setFirstMap(const FirstMapType &first)
Definition Maps.h:2673
openvdb::v10_0::math::CompoundMap::getAffineMap
AffineMap::Ptr getAffineMap() const
Definition Maps.h:2658
openvdb::v10_0::math::CompoundMap::CompoundMap
CompoundMap()
Definition Maps.h:2604
openvdb::v10_0::math::CompoundMap::operator==
bool operator==(const MyType &other) const
Definition Maps.h:2623
openvdb::v10_0::math::CompoundMap::operator!=
bool operator!=(const MyType &other) const
Definition Maps.h:2631
openvdb::v10_0::math::CompoundMap::type
Name type() const
Definition Maps.h:2617
openvdb::v10_0::math::CompoundMap::CompoundMap
CompoundMap(const FirstMapType &f, const SecondMapType &s)
Definition Maps.h:2606
openvdb::v10_0::math::CompoundMap::isIdentity
bool isIdentity() const
Definition Maps.h:2641
openvdb::v10_0::math::CompoundMap::operator=
MyType & operator=(const MyType &other)
Definition Maps.h:2633
openvdb::v10_0::math::CompoundMap< UnitaryMap, TranslationMap >::mapType
static Name mapType()
Definition Maps.h:2618
openvdb::v10_0::math::CompoundMap::CompoundMap
CompoundMap(const MyType &other)
Definition Maps.h:2611
openvdb::v10_0::math::CompoundMap::read
void read(std::istream &is)
Definition Maps.h:2676
openvdb::v10_0::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition Coord.h:249
openvdb::v10_0::math::CoordBBox::min
const Coord & min() const
Definition Coord.h:321
openvdb::v10_0::math::CoordBBox::max
const Coord & max() const
Definition Coord.h:322
openvdb::v10_0::math::CoordBBox::read
void read(std::istream &is)
Unserialize this bounding box from the given stream.
Definition Coord.h:496
openvdb::v10_0::math::Coord::ValueType
Int32 ValueType
Definition Coord.h:32
openvdb::v10_0::math::Coord::asVec3d
Vec3d asVec3d() const
Definition Coord.h:143
openvdb::v10_0::math::MapBase
Abstract base class for maps.
Definition Maps.h:135
openvdb::v10_0::math::MapBase::voxelSize
virtual Vec3d voxelSize() const =0
Method to return the local size of a voxel. When a location is specified as an argument,...
openvdb::v10_0::math::MapBase::applyInverseMap
virtual Vec3d applyInverseMap(const Vec3d &in) const =0
openvdb::v10_0::math::MapBase::isEqualBase
static bool isEqualBase(const MapT &self, const MapBase &other)
Definition Maps.h:250
openvdb::v10_0::math::MapBase::applyMap
virtual Vec3d applyMap(const Vec3d &in) const =0
openvdb::v10_0::math::MapBase::getAffineMap
virtual SharedPtr< AffineMap > getAffineMap() const =0
openvdb::v10_0::math::MapBase::Ptr
SharedPtr< MapBase > Ptr
Definition Maps.h:137
openvdb::v10_0::math::MapBase::isType
bool isType() const
Return true if this map is of concrete type MapT (e.g., AffineMap).
Definition Maps.h:150
openvdb::v10_0::math::MapBase::determinant
virtual double determinant() const =0
openvdb::v10_0::math::MapBase::preShear
virtual MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const =0
openvdb::v10_0::math::MapBase::applyIJC
virtual Mat3d applyIJC(const Mat3d &m) const =0
openvdb::v10_0::math::MapBase::applyJT
virtual Vec3d applyJT(const Vec3d &in) const =0
Apply the Jacobian transpose of this map to a vector. For a linear map this is equivalent to applying...
openvdb::v10_0::math::MapBase::str
virtual std::string str() const =0
openvdb::v10_0::math::MapBase::applyIJC
virtual Mat3d applyIJC(const Mat3d &m, const Vec3d &v, const Vec3d &domainPos) const =0
openvdb::v10_0::math::MapBase::applyJT
virtual Vec3d applyJT(const Vec3d &in, const Vec3d &domainPos) const =0
openvdb::v10_0::math::MapBase::copy
virtual MapBase::Ptr copy() const =0
openvdb::v10_0::math::MapBase::read
virtual void read(std::istream &)=0
openvdb::v10_0::math::MapBase::~MapBase
virtual ~MapBase()=default
openvdb::v10_0::math::MapBase::voxelSize
virtual Vec3d voxelSize(const Vec3d &) const =0
openvdb::v10_0::math::MapBase::isLinear
virtual bool isLinear() const =0
Return true if this map is linear.
openvdb::v10_0::math::MapBase::hasUniformScale
virtual bool hasUniformScale() const =0
Return true if the spacing between the image of latice is uniform in all directions.
openvdb::v10_0::math::MapBase::preScale
virtual MapBase::Ptr preScale(const Vec3d &) const =0
openvdb::v10_0::math::MapBase::applyInverseJacobian
virtual Vec3d applyInverseJacobian(const Vec3d &in) const =0
Apply the InverseJacobian of this map to a vector. For a linear map this is equivalent to applying th...
openvdb::v10_0::math::MapBase::applyIJT
virtual Vec3d applyIJT(const Vec3d &in) const =0
Apply the Inverse Jacobian Transpose of this map to a vector. For a linear map this is equivalent to ...
openvdb::v10_0::math::MapBase::ConstPtr
SharedPtr< const MapBase > ConstPtr
Definition Maps.h:138
openvdb::v10_0::math::MapBase::determinant
virtual double determinant(const Vec3d &) const =0
openvdb::v10_0::math::MapBase::MapBase
MapBase()
Definition Maps.h:247
openvdb::v10_0::math::MapBase::applyIJT
virtual Vec3d applyIJT(const Vec3d &in, const Vec3d &domainPos) const =0
openvdb::v10_0::math::MapBase::MapBase
MapBase(const MapBase &)=default
openvdb::v10_0::math::MapBase::postTranslate
virtual MapBase::Ptr postTranslate(const Vec3d &) const =0
openvdb::v10_0::math::MapBase::type
virtual Name type() const =0
Return the name of this map's concrete type (e.g., "AffineMap").
openvdb::v10_0::math::MapBase::applyInverseJacobian
virtual Vec3d applyInverseJacobian(const Vec3d &in, const Vec3d &domainPos) const =0
openvdb::v10_0::math::MapBase::write
virtual void write(std::ostream &) const =0
openvdb::v10_0::math::MapBase::applyJacobian
virtual Vec3d applyJacobian(const Vec3d &in) const =0
Apply the Jacobian of this map to a vector. For a linear map this is equivalent to applying the map e...
openvdb::v10_0::math::MapBase::preTranslate
virtual MapBase::Ptr preTranslate(const Vec3d &) const =0
openvdb::v10_0::math::MapBase::postRotate
virtual MapBase::Ptr postRotate(double radians, Axis axis=X_AXIS) const =0
openvdb::v10_0::math::MapBase::postShear
virtual MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const =0
openvdb::v10_0::math::MapBase::postScale
virtual MapBase::Ptr postScale(const Vec3d &) const =0
openvdb::v10_0::math::MapBase::applyJacobian
virtual Vec3d applyJacobian(const Vec3d &in, const Vec3d &domainPos) const =0
openvdb::v10_0::math::MapBase::inverseMap
virtual MapBase::Ptr inverseMap() const =0
Return a new map representing the inverse of this map.
openvdb::v10_0::math::MapBase::MapFactory
Ptr(*)() MapFactory
Definition Maps.h:139
openvdb::v10_0::math::MapBase::isEqual
virtual bool isEqual(const MapBase &other) const =0
Return true if this map is equal to the given map.
openvdb::v10_0::math::MapBase::preRotate
virtual MapBase::Ptr preRotate(double radians, Axis axis=X_AXIS) const =0
Methods to update the map.
openvdb::v10_0::math::MapRegistry
Threadsafe singleton object for accessing the map type-name dictionary. Associates a map type-name wi...
Definition Maps.h:263
openvdb::v10_0::math::MapRegistry::createMap
static MapBase::Ptr createMap(const Name &)
Create a new map of the given (registered) type name.
openvdb::v10_0::math::MapRegistry::clear
static void clear()
Clear the map type registry.
openvdb::v10_0::math::MapRegistry::unregisterMap
static void unregisterMap(const Name &)
Remove a map type from the registry.
openvdb::v10_0::math::MapRegistry::isRegistered
static bool isRegistered(const Name &)
Return true if the given map type name is registered.
openvdb::v10_0::math::MapRegistry::MapDictionary
std::map< Name, MapBase::MapFactory > MapDictionary
Definition Maps.h:265
openvdb::v10_0::math::MapRegistry::instance
static MapRegistry * instance()
openvdb::v10_0::math::MapRegistry::registerMap
static void registerMap(const Name &, MapBase::MapFactory)
Register a map type along with a factory function.
openvdb::v10_0::math::Mat3::setToRotation
void setToRotation(const Quat< T > &q)
Set this matrix to the rotation matrix specified by the quaternion.
Definition Mat3.h:253
openvdb::v10_0::math::Mat3::inverse
Mat3 inverse(T tolerance=0) const
Definition Mat3.h:465
openvdb::v10_0::math::Mat3::setCol
void setCol(int j, const Vec3< T > &v)
Set jth column to vector v.
Definition Mat3.h:159
openvdb::v10_0::math::Mat3::transpose
Mat3 transpose() const
returns transpose of this
Definition Mat3.h:454
openvdb::v10_0::math::Mat3::det
T det() const
Determinant of matrix.
Definition Mat3.h:479
openvdb::v10_0::math::Mat3< double >::zero
static const Mat3< double > & zero()
Definition Mat3.h:131
openvdb::v10_0::math::Mat3::col
Vec3< T > col(int j) const
Get jth column, e.g. Vec3d v = m.col(0);.
Definition Mat3.h:168
openvdb::v10_0::math::Mat3::setRow
void setRow(int i, const Vec3< T > &v)
Set ith row to vector v.
Definition Mat3.h:141
openvdb::v10_0::math::Mat4::inverse
Mat4 inverse(T tolerance=0) const
Definition Mat4.h:485
openvdb::v10_0::math::Mat4::getMat3
Mat3< T > getMat3() const
Definition Mat4.h:297
openvdb::v10_0::math::Mat4< double >::identity
static const Mat4< double > & identity()
Definition Mat4.h:117
openvdb::v10_0::math::Mat4::setToRotation
void setToRotation(Axis axis, T angle)
Sets the matrix to a rotation about the given axis.
Definition Mat4.h:783
openvdb::v10_0::math::Mat4::transform
Vec4< T0 > transform(const Vec4< T0 > &v) const
Transform a Vec4 by post-multiplication.
Definition Mat4.h:998
openvdb::v10_0::math::Mat4::setTranslation
void setTranslation(const Vec3< T > &t)
Definition Mat4.h:314
openvdb::v10_0::math::Mat4::setMat3
void setMat3(const Mat3< T > &m)
Set upper left to a Mat3.
Definition Mat4.h:290
openvdb::v10_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:2474
openvdb::v10_0::math::NonlinearFrustumMap::NonlinearFrustumMap
NonlinearFrustumMap()
Definition Maps.h:1900
openvdb::v10_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:1923
openvdb::v10_0::math::NonlinearFrustumMap::setTaper
void setTaper(double t)
set the taper value, the ratio of nearplane width / far plane width
Definition Maps.h:2355
openvdb::v10_0::math::NonlinearFrustumMap::registerMap
static void registerMap()
Definition Maps.h:2036
openvdb::v10_0::math::NonlinearFrustumMap::getBBox
const BBoxd & getBBox() const
Return the bounding box that defines the frustum in pre-image space.
Definition Maps.h:2366
openvdb::v10_0::math::NonlinearFrustumMap::write
void write(std::ostream &os) const override
write serialization
Definition Maps.h:2408
openvdb::v10_0::math::NonlinearFrustumMap::operator!=
bool operator!=(const NonlinearFrustumMap &other) const
Definition Maps.h:2097
openvdb::v10_0::math::NonlinearFrustumMap::secondMap
const AffineMap & secondMap() const
Return MapBase::Ptr& to the second map.
Definition Maps.h:2369
openvdb::v10_0::math::NonlinearFrustumMap::getGamma
double getGamma() const
Definition Maps.h:2363
openvdb::v10_0::math::NonlinearFrustumMap::getDepth
double getDepth() const
Return the unscaled frustm depth.
Definition Maps.h:2361
openvdb::v10_0::math::NonlinearFrustumMap::applyIJT
Vec3d applyIJT(const Vec3d &d1_is, const Vec3d &ijk) const override
Definition Maps.h:2206
openvdb::v10_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:2481
openvdb::v10_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:2452
openvdb::v10_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:2467
openvdb::v10_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:2196
openvdb::v10_0::math::NonlinearFrustumMap::operator==
bool operator==(const NonlinearFrustumMap &other) const
Definition Maps.h:2075
openvdb::v10_0::math::NonlinearFrustumMap::isValid
bool isValid() const
Definition Maps.h:2372
openvdb::v10_0::math::NonlinearFrustumMap::type
Name type() const override
Return NonlinearFrustumMap.
Definition Maps.h:2043
openvdb::v10_0::math::NonlinearFrustumMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Definition Maps.h:2352
openvdb::v10_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:1961
openvdb::v10_0::math::NonlinearFrustumMap::hasUniformScale
bool hasUniformScale() const override
Return false (by convention false).
Definition Maps.h:2051
openvdb::v10_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:2460
openvdb::v10_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:2191
openvdb::v10_0::math::NonlinearFrustumMap::determinant
double determinant() const override
Return the determinant of the Jacobian of linear second map.
Definition Maps.h:2317
openvdb::v10_0::math::NonlinearFrustumMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition Maps.h:2024
openvdb::v10_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:2111
openvdb::v10_0::math::NonlinearFrustumMap::str
std::string str() const override
string serialization, useful for debuging
Definition Maps.h:2419
openvdb::v10_0::math::NonlinearFrustumMap::ConstPtr
SharedPtr< const NonlinearFrustumMap > ConstPtr
Definition Maps.h:1898
openvdb::v10_0::math::NonlinearFrustumMap::isLinear
bool isLinear() const override
Return false (a NonlinearFrustumMap is never linear).
Definition Maps.h:2048
openvdb::v10_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:2169
openvdb::v10_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:2138
openvdb::v10_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:2438
openvdb::v10_0::math::NonlinearFrustumMap::voxelSize
Vec3d voxelSize() const override
Return the size of a voxel at the center of the near plane.
Definition Maps.h:2329
openvdb::v10_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:2445
openvdb::v10_0::math::NonlinearFrustumMap::isRegistered
static bool isRegistered()
Definition Maps.h:2034
openvdb::v10_0::math::NonlinearFrustumMap::determinant
double determinant(const Vec3d &loc) const override
Definition Maps.h:2321
openvdb::v10_0::math::NonlinearFrustumMap::NonlinearFrustumMap
NonlinearFrustumMap(const NonlinearFrustumMap &other)
Definition Maps.h:1935
openvdb::v10_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:1912
openvdb::v10_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:2431
openvdb::v10_0::math::NonlinearFrustumMap::applyIJC
Mat3d applyIJC(const Mat3d &d2_is, const Vec3d &d1_is, const Vec3d &ijk) const override
Definition Maps.h:2247
openvdb::v10_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:2142
openvdb::v10_0::math::NonlinearFrustumMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition Maps.h:2100
openvdb::v10_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:2029
openvdb::v10_0::math::NonlinearFrustumMap::isIdentity
bool isIdentity() const
Return true if the map is equivalent to an identity.
Definition Maps.h:2054
openvdb::v10_0::math::NonlinearFrustumMap::read
void read(std::istream &is) override
read serialization
Definition Maps.h:2378
openvdb::v10_0::math::NonlinearFrustumMap::getTaper
double getTaper() const
Return the taper value.
Definition Maps.h:2357
openvdb::v10_0::math::NonlinearFrustumMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition Maps.h:2106
openvdb::v10_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:2343
openvdb::v10_0::math::NonlinearFrustumMap::Ptr
SharedPtr< NonlinearFrustumMap > Ptr
Definition Maps.h:1897
openvdb::v10_0::math::NonlinearFrustumMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new NonlinearFrustumMap.
Definition Maps.h:2022
openvdb::v10_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:2359
openvdb::v10_0::math::NonlinearFrustumMap::applyIJC
Mat3d applyIJC(const Mat3d &in) const override
Return the Jacobian Curvature for the linear second map.
Definition Maps.h:2242
openvdb::v10_0::math::NonlinearFrustumMap::mapType
static Name mapType()
Return NonlinearFrustumMap.
Definition Maps.h:2045
openvdb::v10_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:2113
openvdb::v10_0::math::NonlinearFrustumMap::hasSimpleAffine
bool hasSimpleAffine() const
Return true if the second map is a uniform scale, Rotation and translation.
Definition Maps.h:2375
openvdb::v10_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:2073
openvdb::v10_0::math::NonlinearFrustumMap::~NonlinearFrustumMap
~NonlinearFrustumMap() override=default
openvdb::v10_0::math::ScaleMap
A specialized Affine transform that scales along the principal axis the scaling need not be uniform i...
Definition Maps.h:659
openvdb::v10_0::math::ScaleMap::postScale
MapBase::Ptr postScale(const Vec3d &) const override
Definition Maps.h:973
openvdb::v10_0::math::ScaleMap::voxelSize
Vec3d voxelSize() const final
Return the lengths of the images of the segments (0,0,0) − 1,0,0), (0,0,0) − (0,1,...
Definition Maps.h:811
openvdb::v10_0::math::ScaleMap::getScale
const Vec3d & getScale() const
Return the scale values that define the map.
Definition Maps.h:798
openvdb::v10_0::math::ScaleMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const final
Return the pre-image of in under the map.
Definition Maps.h:737
openvdb::v10_0::math::ScaleMap::registerMap
static void registerMap()
Definition Maps.h:705
openvdb::v10_0::math::ScaleMap::write
void write(std::ostream &os) const override
write serialization
Definition Maps.h:825
openvdb::v10_0::math::ScaleMap::ConstPtr
SharedPtr< const ScaleMap > ConstPtr
Definition Maps.h:662
openvdb::v10_0::math::ScaleMap::applyMap
Vec3d applyMap(const Vec3d &in) const final
Return the image of in under the map.
Definition Maps.h:729
openvdb::v10_0::math::ScaleMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Definition Maps.h:893
openvdb::v10_0::math::ScaleMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Definition Maps.h:873
openvdb::v10_0::math::ScaleMap::ScaleMap
ScaleMap(const Vec3d &scale)
Definition Maps.h:668
openvdb::v10_0::math::ScaleMap::determinant
double determinant(const Vec3d &) const final
Return the product of the scale values, ignores argument.
Definition Maps.h:791
openvdb::v10_0::math::ScaleMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &) const override
Definition Maps.h:1461
openvdb::v10_0::math::ScaleMap::applyIJT
Vec3d applyIJT(const Vec3d &in) const final
Return the transpose of the inverse Jacobian of the map applied to in.
Definition Maps.h:774
openvdb::v10_0::math::ScaleMap::applyIJT
Vec3d applyIJT(const Vec3d &in, const Vec3d &) const final
Return the transpose of the inverse Jacobian of the map applied to in.
Definition Maps.h:770
openvdb::v10_0::math::ScaleMap::getInvScale
const Vec3d & getInvScale() const
Return 1/(scale).
Definition Maps.h:805
openvdb::v10_0::math::ScaleMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in, const Vec3d &) const final
Return the Jacobian of the map applied to in.
Definition Maps.h:745
openvdb::v10_0::math::ScaleMap::isLinear
bool isLinear() const final
Return true (a ScaleMap is always linear).
Definition Maps.h:716
openvdb::v10_0::math::ScaleMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition Maps.h:712
openvdb::v10_0::math::ScaleMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return a AffineMap equivalent to this map.
Definition Maps.h:854
openvdb::v10_0::math::ScaleMap::postRotate
MapBase::Ptr postRotate(double radians, Axis axis) const override
Return a MapBase::Ptr to a new map that is the result of prepending the appropraite operation to the ...
Definition Maps.h:885
openvdb::v10_0::math::ScaleMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition Maps.h:697
openvdb::v10_0::math::ScaleMap::str
std::string str() const override
string serialization, useful for debuging
Definition Maps.h:834
openvdb::v10_0::math::ScaleMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &) const override
Definition Maps.h:1468
openvdb::v10_0::math::ScaleMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in, const Vec3d &) const final
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation).
Definition Maps.h:753
openvdb::v10_0::math::ScaleMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const final
Return the Jacobian of the map applied to in.
Definition Maps.h:749
openvdb::v10_0::math::ScaleMap::applyIJC
Mat3d applyIJC(const Mat3d &in) const final
Return the Jacobian Curvature: zero for a linear map.
Definition Maps.h:776
openvdb::v10_0::math::ScaleMap::~ScaleMap
~ScaleMap() override=default
openvdb::v10_0::math::ScaleMap::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 appropraite operation to the ...
Definition Maps.h:864
openvdb::v10_0::math::ScaleMap::applyJT
Vec3d applyJT(const Vec3d &in) const final
Return the Jacobian Transpose of the map applied to in.
Definition Maps.h:766
openvdb::v10_0::math::ScaleMap::voxelSize
Vec3d voxelSize(const Vec3d &) const final
Definition Maps.h:812
openvdb::v10_0::math::ScaleMap::operator==
bool operator==(const ScaleMap &other) const
Definition Maps.h:844
openvdb::v10_0::math::ScaleMap::isRegistered
static bool isRegistered()
Definition Maps.h:703
openvdb::v10_0::math::ScaleMap::ScaleMap
ScaleMap()
Definition Maps.h:664
openvdb::v10_0::math::ScaleMap::determinant
double determinant() const final
Return the product of the scale values.
Definition Maps.h:793
openvdb::v10_0::math::ScaleMap::applyJT
Vec3d applyJT(const Vec3d &in, const Vec3d &) const final
Return the Jacobian Transpose of the map applied to in.
Definition Maps.h:764
openvdb::v10_0::math::ScaleMap::getInvTwiceScale
const Vec3d & getInvTwiceScale() const
Return 1/(2 scale). Used to optimize some finite difference calculations.
Definition Maps.h:803
openvdb::v10_0::math::ScaleMap::ScaleMap
ScaleMap(const ScaleMap &other)
Definition Maps.h:682
openvdb::v10_0::math::ScaleMap::hasUniformScale
bool hasUniformScale() const final
Return true if the values have the same magitude (eg. -1, 1, -1 would be a rotation).
Definition Maps.h:719
openvdb::v10_0::math::ScaleMap::applyIJC
Mat3d applyIJC(const Mat3d &in, const Vec3d &, const Vec3d &) const final
Definition Maps.h:787
openvdb::v10_0::math::ScaleMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition Maps.h:699
openvdb::v10_0::math::ScaleMap::getInvScaleSqr
const Vec3d & getInvScaleSqr() const
Return the square of the scale. Used to optimize some finite difference calculations.
Definition Maps.h:801
openvdb::v10_0::math::ScaleMap::read
void read(std::istream &is) override
read serialization
Definition Maps.h:816
openvdb::v10_0::math::ScaleMap::operator!=
bool operator!=(const ScaleMap &other) const
Definition Maps.h:851
openvdb::v10_0::math::ScaleMap::preScale
MapBase::Ptr preScale(const Vec3d &) const override
Definition Maps.h:961
openvdb::v10_0::math::ScaleMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new ScaleMap.
Definition Maps.h:695
openvdb::v10_0::math::ScaleMap::mapType
static Name mapType()
Definition Maps.h:713
openvdb::v10_0::math::ScaleMap::Ptr
SharedPtr< ScaleMap > Ptr
Definition Maps.h:661
openvdb::v10_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:842
openvdb::v10_0::math::ScaleMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in) const final
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation).
Definition Maps.h:758
openvdb::v10_0::math::ScaleTranslateMap
A specialized Affine transform that scales along the principal axis the scaling need not be uniform i...
Definition Maps.h:1166
openvdb::v10_0::math::ScaleTranslateMap::voxelSize
Vec3d voxelSize() const final
Return the absolute values of the scale values.
Definition Maps.h:1336
openvdb::v10_0::math::ScaleTranslateMap::getScale
const Vec3d & getScale() const
Returns the scale values.
Definition Maps.h:1341
openvdb::v10_0::math::ScaleTranslateMap::operator==
bool operator==(const ScaleTranslateMap &other) const
Definition Maps.h:1384
openvdb::v10_0::math::ScaleTranslateMap::ScaleTranslateMap
ScaleTranslateMap(const ScaleTranslateMap &other)
Definition Maps.h:1210
openvdb::v10_0::math::ScaleTranslateMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const final
Return the pre-image of under the map.
Definition Maps.h:1268
openvdb::v10_0::math::ScaleTranslateMap::registerMap
static void registerMap()
Definition Maps.h:1235
openvdb::v10_0::math::ScaleTranslateMap::operator!=
bool operator!=(const ScaleTranslateMap &other) const
Definition Maps.h:1392
openvdb::v10_0::math::ScaleTranslateMap::write
void write(std::ostream &os) const override
write serialization
Definition Maps.h:1363
openvdb::v10_0::math::ScaleTranslateMap::~ScaleTranslateMap
~ScaleTranslateMap() override=default
openvdb::v10_0::math::ScaleTranslateMap::applyMap
Vec3d applyMap(const Vec3d &in) const final
Return the image of under the map.
Definition Maps.h:1260
openvdb::v10_0::math::ScaleTranslateMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Definition Maps.h:1446
openvdb::v10_0::math::ScaleTranslateMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Definition Maps.h:1422
openvdb::v10_0::math::ScaleTranslateMap::determinant
double determinant(const Vec3d &) const final
Return the product of the scale values, ignores argument.
Definition Maps.h:1330
openvdb::v10_0::math::ScaleTranslateMap::applyIJT
Vec3d applyIJT(const Vec3d &in) const final
Return the transpose of the inverse Jacobian of the map applied to in.
Definition Maps.h:1306
openvdb::v10_0::math::ScaleTranslateMap::getTranslation
const Vec3d & getTranslation() const
Returns the translation.
Definition Maps.h:1343
openvdb::v10_0::math::ScaleTranslateMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &t) const override
Definition Maps.h:1439
openvdb::v10_0::math::ScaleTranslateMap::applyIJT
Vec3d applyIJT(const Vec3d &in, const Vec3d &) const final
Return the transpose of the inverse Jacobian of the map applied to in.
Definition Maps.h:1302
openvdb::v10_0::math::ScaleTranslateMap::getInvScale
const Vec3d & getInvScale() const
Return 1/(scale).
Definition Maps.h:1350
openvdb::v10_0::math::ScaleTranslateMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in, const Vec3d &) const final
Return the Jacobian of the map applied to in.
Definition Maps.h:1277
openvdb::v10_0::math::ScaleTranslateMap::isLinear
bool isLinear() const final
Return true (a ScaleTranslateMap is always linear).
Definition Maps.h:1246
openvdb::v10_0::math::ScaleTranslateMap::postScale
MapBase::Ptr postScale(const Vec3d &v) const override
Definition Maps.h:1603
openvdb::v10_0::math::ScaleTranslateMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition Maps.h:1242
openvdb::v10_0::math::ScaleTranslateMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return AffineMap::Ptr to an AffineMap equivalent to *this.
Definition Maps.h:1395
openvdb::v10_0::math::ScaleTranslateMap::postRotate
MapBase::Ptr postRotate(double radians, Axis axis) const override
Return a MapBase::Ptr to a new map that is the result of postfixing the appropraite operation.
Definition Maps.h:1433
openvdb::v10_0::math::ScaleTranslateMap::Ptr
SharedPtr< ScaleTranslateMap > Ptr
Definition Maps.h:1168
openvdb::v10_0::math::ScaleTranslateMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition Maps.h:1225
openvdb::v10_0::math::ScaleTranslateMap::str
std::string str() const override
string serialization, useful for debuging
Definition Maps.h:1373
openvdb::v10_0::math::ScaleTranslateMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in, const Vec3d &) const final
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation).
Definition Maps.h:1285
openvdb::v10_0::math::ScaleTranslateMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const final
Return the Jacobian of the map applied to in.
Definition Maps.h:1281
openvdb::v10_0::math::ScaleTranslateMap::applyIJC
Mat3d applyIJC(const Mat3d &in) const final
Return the Jacobian Curvature: zero for a linear map.
Definition Maps.h:1314
openvdb::v10_0::math::ScaleTranslateMap::ScaleTranslateMap
ScaleTranslateMap(const Vec3d &scale, const Vec3d &translate)
Definition Maps.h:1182
openvdb::v10_0::math::ScaleTranslateMap::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 appropraite operation.
Definition Maps.h:1405
openvdb::v10_0::math::ScaleTranslateMap::preScale
MapBase::Ptr preScale(const Vec3d &v) const override
Definition Maps.h:1591
openvdb::v10_0::math::ScaleTranslateMap::applyJT
Vec3d applyJT(const Vec3d &in) const final
Return the Jacobian Transpose of the map applied to in.
Definition Maps.h:1298
openvdb::v10_0::math::ScaleTranslateMap::voxelSize
Vec3d voxelSize(const Vec3d &) const final
Return the absolute values of the scale values, ignores argument.
Definition Maps.h:1338
openvdb::v10_0::math::ScaleTranslateMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &t) const override
Definition Maps.h:1411
openvdb::v10_0::math::ScaleTranslateMap::ConstPtr
SharedPtr< const ScaleTranslateMap > ConstPtr
Definition Maps.h:1169
openvdb::v10_0::math::ScaleTranslateMap::isRegistered
static bool isRegistered()
Definition Maps.h:1233
openvdb::v10_0::math::ScaleTranslateMap::determinant
double determinant() const final
Return the product of the scale values.
Definition Maps.h:1332
openvdb::v10_0::math::ScaleTranslateMap::applyJT
Vec3d applyJT(const Vec3d &in, const Vec3d &) const final
Return the Jacobian Transpose of the map applied to in.
Definition Maps.h:1296
openvdb::v10_0::math::ScaleTranslateMap::ScaleTranslateMap
ScaleTranslateMap(const ScaleMap &scale, const TranslationMap &translate)
Definition Maps.h:1197
openvdb::v10_0::math::ScaleTranslateMap::getInvTwiceScale
const Vec3d & getInvTwiceScale() const
Return 1/(2 scale). Used to optimize some finite difference calculations.
Definition Maps.h:1348
openvdb::v10_0::math::ScaleTranslateMap::hasUniformScale
bool hasUniformScale() const final
Return true if the scale values have the same magnitude (eg. -1, 1, -1 would be a rotation).
Definition Maps.h:1250
openvdb::v10_0::math::ScaleTranslateMap::applyIJC
Mat3d applyIJC(const Mat3d &in, const Vec3d &, const Vec3d &) const final
Definition Maps.h:1325
openvdb::v10_0::math::ScaleTranslateMap::ScaleTranslateMap
ScaleTranslateMap()
Definition Maps.h:1171
openvdb::v10_0::math::ScaleTranslateMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition Maps.h:1227
openvdb::v10_0::math::ScaleTranslateMap::getInvScaleSqr
const Vec3d & getInvScaleSqr() const
Return the square of the scale. Used to optimize some finite difference calculations.
Definition Maps.h:1346
openvdb::v10_0::math::ScaleTranslateMap::read
void read(std::istream &is) override
read serialization
Definition Maps.h:1353
openvdb::v10_0::math::ScaleTranslateMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new ScaleTranslateMap.
Definition Maps.h:1223
openvdb::v10_0::math::ScaleTranslateMap::mapType
static Name mapType()
Definition Maps.h:1243
openvdb::v10_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:1382
openvdb::v10_0::math::ScaleTranslateMap::applyInverseJacobian
Vec3d applyInverseJacobian(const Vec3d &in) const final
Return the Inverse Jacobian of the map applied to in (i.e. inverse map with out translation).
Definition Maps.h:1290
openvdb::v10_0::math::TranslationMap
A specialized linear transform that performs a translation.
Definition Maps.h:981
openvdb::v10_0::math::TranslationMap::TranslationMap
TranslationMap(const TranslationMap &other)
Definition Maps.h:989
openvdb::v10_0::math::TranslationMap::registerMap
static void registerMap()
Definition Maps.h:1004
openvdb::v10_0::math::TranslationMap::write
void write(std::ostream &os) const override
write serialization
Definition Maps.h:1073
openvdb::v10_0::math::TranslationMap::voxelSize
Vec3d voxelSize(const Vec3d &) const override
Return (1,1,1).
Definition Maps.h:1065
openvdb::v10_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:1041
openvdb::v10_0::math::TranslationMap::postShear
MapBase::Ptr postShear(double shear, Axis axis0, Axis axis1) const override
Definition Maps.h:1144
openvdb::v10_0::math::TranslationMap::preShear
MapBase::Ptr preShear(double shear, Axis axis0, Axis axis1) const override
Definition Maps.h:1119
openvdb::v10_0::math::TranslationMap::getTranslation
const Vec3d & getTranslation() const
Return the translation vector.
Definition Maps.h:1068
openvdb::v10_0::math::TranslationMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &t) const override
Definition Maps.h:1137
openvdb::v10_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:1050
openvdb::v10_0::math::TranslationMap::~TranslationMap
~TranslationMap() override=default
openvdb::v10_0::math::TranslationMap::ConstPtr
SharedPtr< const TranslationMap > ConstPtr
Definition Maps.h:984
openvdb::v10_0::math::TranslationMap::postScale
MapBase::Ptr postScale(const Vec3d &v) const override
Definition Maps.h:1577
openvdb::v10_0::math::TranslationMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition Maps.h:1011
openvdb::v10_0::math::TranslationMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return AffineMap::Ptr to an AffineMap equivalent to *this.
Definition Maps.h:1093
openvdb::v10_0::math::TranslationMap::determinant
double determinant(const Vec3d &) const override
Return 1.
Definition Maps.h:1058
openvdb::v10_0::math::TranslationMap::hasUniformScale
bool hasUniformScale() const override
Return false (by convention true).
Definition Maps.h:1018
openvdb::v10_0::math::TranslationMap::postRotate
MapBase::Ptr postRotate(double radians, Axis axis) const override
Return a MapBase::Ptr to a new map that is the result of postfixing the appropriate operation.
Definition Maps.h:1130
openvdb::v10_0::math::TranslationMap::TranslationMap
TranslationMap()
Definition Maps.h:987
openvdb::v10_0::math::TranslationMap::applyIJC
Mat3d applyIJC(const Mat3d &mat) const override
Return the Jacobian Curvature: zero for a linear map.
Definition Maps.h:1052
openvdb::v10_0::math::TranslationMap::applyJT
Vec3d applyJT(const Vec3d &in) const override
Return the Jacobian Transpose of the map applied to in.
Definition Maps.h:1043
openvdb::v10_0::math::TranslationMap::determinant
double determinant() const override
Return 1.
Definition Maps.h:1060
openvdb::v10_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:1025
openvdb::v10_0::math::TranslationMap::applyIJC
Mat3d applyIJC(const Mat3d &mat, const Vec3d &, const Vec3d &) const override
Definition Maps.h:1053
openvdb::v10_0::math::TranslationMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition Maps.h:996
openvdb::v10_0::math::TranslationMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const override
Return the Jacobian of the map applied to in.
Definition Maps.h:1027
openvdb::v10_0::math::TranslationMap::str
std::string str() const override
string serialization, useful for debuging
Definition Maps.h:1075
openvdb::v10_0::math::TranslationMap::isLinear
bool isLinear() const override
Return true (a TranslationMap is always linear).
Definition Maps.h:1015
openvdb::v10_0::math::TranslationMap::TranslationMap
TranslationMap(const Vec3d &t)
Definition Maps.h:988
openvdb::v10_0::math::TranslationMap::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 appropriate operation.
Definition Maps.h:1105
openvdb::v10_0::math::TranslationMap::preScale
MapBase::Ptr preScale(const Vec3d &v) const override
Definition Maps.h:1566
openvdb::v10_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:1031
openvdb::v10_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:1036
openvdb::v10_0::math::TranslationMap::operator==
bool operator==(const TranslationMap &other) const
Definition Maps.h:1084
openvdb::v10_0::math::TranslationMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &t) const override
Definition Maps.h:1112
openvdb::v10_0::math::TranslationMap::voxelSize
Vec3d voxelSize() const override
Return (1,1,1).
Definition Maps.h:1063
openvdb::v10_0::math::TranslationMap::isRegistered
static bool isRegistered()
Definition Maps.h:1002
openvdb::v10_0::math::TranslationMap::Ptr
SharedPtr< TranslationMap > Ptr
Definition Maps.h:983
openvdb::v10_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:1047
openvdb::v10_0::math::TranslationMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition Maps.h:1021
openvdb::v10_0::math::TranslationMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition Maps.h:998
openvdb::v10_0::math::TranslationMap::read
void read(std::istream &is) override
read serialization
Definition Maps.h:1071
openvdb::v10_0::math::TranslationMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition Maps.h:1023
openvdb::v10_0::math::TranslationMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new TranslationMap.
Definition Maps.h:994
openvdb::v10_0::math::TranslationMap::mapType
static Name mapType()
Definition Maps.h:1012
openvdb::v10_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:1082
openvdb::v10_0::math::TranslationMap::operator!=
bool operator!=(const TranslationMap &other) const
Definition Maps.h:1090
openvdb::v10_0::math::UniformScaleMap
A specialized Affine transform that scales along the principal axis the scaling is uniform in the thr...
Definition Maps.h:909
openvdb::v10_0::math::UniformScaleMap::operator==
bool operator==(const UniformScaleMap &other) const
Definition Maps.h:943
openvdb::v10_0::math::UniformScaleMap::registerMap
static void registerMap()
Definition Maps.h:931
openvdb::v10_0::math::UniformScaleMap::operator!=
bool operator!=(const UniformScaleMap &other) const
Definition Maps.h:944
openvdb::v10_0::math::UniformScaleMap::~UniformScaleMap
~UniformScaleMap() override=default
openvdb::v10_0::math::UniformScaleMap::UniformScaleMap
UniformScaleMap(double scale)
Definition Maps.h:915
openvdb::v10_0::math::UniformScaleMap::postTranslate
MapBase::Ptr postTranslate(const Vec3d &) const override
Return a MapBase::Ptr to a UniformScaleTraslateMap that is the result of post-translation on this map...
Definition Maps.h:1550
openvdb::v10_0::math::UniformScaleMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition Maps.h:938
openvdb::v10_0::math::UniformScaleMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition Maps.h:922
openvdb::v10_0::math::UniformScaleMap::preTranslate
MapBase::Ptr preTranslate(const Vec3d &) const override
Return a MapBase::Ptr to a UniformScaleTraslateMap that is the result of pre-translation on this map.
Definition Maps.h:1558
openvdb::v10_0::math::UniformScaleMap::UniformScaleMap
UniformScaleMap()
Definition Maps.h:914
openvdb::v10_0::math::UniformScaleMap::isRegistered
static bool isRegistered()
Definition Maps.h:930
openvdb::v10_0::math::UniformScaleMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition Maps.h:924
openvdb::v10_0::math::UniformScaleMap::ConstPtr
SharedPtr< const UniformScaleMap > ConstPtr
Definition Maps.h:912
openvdb::v10_0::math::UniformScaleMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new UniformScaleMap.
Definition Maps.h:920
openvdb::v10_0::math::UniformScaleMap::UniformScaleMap
UniformScaleMap(const UniformScaleMap &other)
Definition Maps.h:916
openvdb::v10_0::math::UniformScaleMap::mapType
static Name mapType()
Definition Maps.h:939
openvdb::v10_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:941
openvdb::v10_0::math::UniformScaleMap::Ptr
SharedPtr< UniformScaleMap > Ptr
Definition Maps.h:911
openvdb::v10_0::math::UniformScaleTranslateMap
A specialized Affine transform that uniformaly scales along the principal axis and then translates th...
Definition Maps.h:1482
openvdb::v10_0::math::UniformScaleTranslateMap::operator==
bool operator==(const UniformScaleTranslateMap &other) const
Definition Maps.h:1524
openvdb::v10_0::math::UniformScaleTranslateMap::ConstPtr
SharedPtr< const UniformScaleTranslateMap > ConstPtr
Definition Maps.h:1485
openvdb::v10_0::math::UniformScaleTranslateMap::registerMap
static void registerMap()
Definition Maps.h:1513
openvdb::v10_0::math::UniformScaleTranslateMap::~UniformScaleTranslateMap
~UniformScaleTranslateMap() override=default
openvdb::v10_0::math::UniformScaleTranslateMap::UniformScaleTranslateMap
UniformScaleTranslateMap(const UniformScaleTranslateMap &other)
Definition Maps.h:1493
openvdb::v10_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:1541
openvdb::v10_0::math::UniformScaleTranslateMap::Ptr
SharedPtr< UniformScaleTranslateMap > Ptr
Definition Maps.h:1484
openvdb::v10_0::math::UniformScaleTranslateMap::type
Name type() const override
Return the name of this map's concrete type (e.g., "AffineMap").
Definition Maps.h:1519
openvdb::v10_0::math::UniformScaleTranslateMap::copy
MapBase::Ptr copy() const override
Return a MapBase::Ptr to a deep copy of this map.
Definition Maps.h:1499
openvdb::v10_0::math::UniformScaleTranslateMap::UniformScaleTranslateMap
UniformScaleTranslateMap(double scale, const Vec3d &translate)
Definition Maps.h:1488
openvdb::v10_0::math::UniformScaleTranslateMap::operator!=
bool operator!=(const UniformScaleTranslateMap &other) const
Definition Maps.h:1528
openvdb::v10_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:1532
openvdb::v10_0::math::UniformScaleTranslateMap::isRegistered
static bool isRegistered()
Definition Maps.h:1508
openvdb::v10_0::math::UniformScaleTranslateMap::UniformScaleTranslateMap
UniformScaleTranslateMap(const UniformScaleMap &scale, const TranslationMap &translate)
Definition Maps.h:1490
openvdb::v10_0::math::UniformScaleTranslateMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition Maps.h:1501
openvdb::v10_0::math::UniformScaleTranslateMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new UniformScaleTranslateMap.
Definition Maps.h:1497
openvdb::v10_0::math::UniformScaleTranslateMap::UniformScaleTranslateMap
UniformScaleTranslateMap()
Definition Maps.h:1487
openvdb::v10_0::math::UniformScaleTranslateMap::mapType
static Name mapType()
Definition Maps.h:1520
openvdb::v10_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:1522
openvdb::v10_0::math::UnitaryMap
A specialized linear transform that performs a unitary maping i.e. rotation and or reflection.
Definition Maps.h:1624
openvdb::v10_0::math::UnitaryMap::registerMap
static void registerMap()
Definition Maps.h:1710
openvdb::v10_0::math::UnitaryMap::operator==
bool operator==(const UnitaryMap &other) const
Definition Maps.h:1730
openvdb::v10_0::math::UnitaryMap::write
void write(std::ostream &os) const override
write serialization
Definition Maps.h:1798
openvdb::v10_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:1788
openvdb::v10_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:1760
openvdb::v10_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:1873
openvdb::v10_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const Mat4d &m)
Definition Maps.h:1660
openvdb::v10_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:1840
openvdb::v10_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:1857
openvdb::v10_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:1771
openvdb::v10_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:1865
openvdb::v10_0::math::UnitaryMap::type
Name type() const override
Return UnitaryMap.
Definition Maps.h:1718
openvdb::v10_0::math::UnitaryMap::getAffineMap
AffineMap::Ptr getAffineMap() const override
Return AffineMap::Ptr to an AffineMap equivalent to *this.
Definition Maps.h:1810
openvdb::v10_0::math::UnitaryMap::determinant
double determinant(const Vec3d &) const override
Return the determinant of the Jacobian, ignores argument.
Definition Maps.h:1779
openvdb::v10_0::math::UnitaryMap::hasUniformScale
bool hasUniformScale() const override
Return false (by convention true).
Definition Maps.h:1726
openvdb::v10_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:1849
openvdb::v10_0::math::UnitaryMap::applyJT
Vec3d applyJT(const Vec3d &in) const override
Return the Jacobian Transpose of the map applied to in.
Definition Maps.h:1762
openvdb::v10_0::math::UnitaryMap::determinant
double determinant() const override
Return the determinant of the Jacobian.
Definition Maps.h:1781
openvdb::v10_0::math::UnitaryMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in, const Vec3d &) const override
Definition Maps.h:1743
openvdb::v10_0::math::UnitaryMap::applyIJC
Mat3d applyIJC(const Mat3d &in, const Vec3d &, const Vec3d &) const override
Definition Maps.h:1774
openvdb::v10_0::math::UnitaryMap::copy
MapBase::Ptr copy() const override
Returns a MapBase::Ptr to a deep copy of *this.
Definition Maps.h:1701
openvdb::v10_0::math::UnitaryMap::~UnitaryMap
~UnitaryMap() override=default
openvdb::v10_0::math::UnitaryMap::applyJacobian
Vec3d applyJacobian(const Vec3d &in) const override
Return the Jacobian of the map applied to in.
Definition Maps.h:1745
openvdb::v10_0::math::UnitaryMap::str
std::string str() const override
string serialization, useful for debuging
Definition Maps.h:1803
openvdb::v10_0::math::UnitaryMap::isLinear
bool isLinear() const override
Return true (a UnitaryMap is always linear).
Definition Maps.h:1723
openvdb::v10_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:1816
openvdb::v10_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:1832
openvdb::v10_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:1749
openvdb::v10_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:1754
openvdb::v10_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const Vec3d &axis, double radians)
Definition Maps.h:1634
openvdb::v10_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:1824
openvdb::v10_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:1787
openvdb::v10_0::math::UnitaryMap::isRegistered
static bool isRegistered()
Definition Maps.h:1708
openvdb::v10_0::math::UnitaryMap::UnitaryMap
UnitaryMap(Axis axis, double radians)
Definition Maps.h:1641
openvdb::v10_0::math::UnitaryMap::ConstPtr
SharedPtr< const UnitaryMap > ConstPtr
Definition Maps.h:1627
openvdb::v10_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const UnitaryMap &other)
Definition Maps.h:1685
openvdb::v10_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:1769
openvdb::v10_0::math::UnitaryMap::applyMap
Vec3d applyMap(const Vec3d &in) const override
Return the image of in under the map.
Definition Maps.h:1739
openvdb::v10_0::math::UnitaryMap::inverseMap
MapBase::Ptr inverseMap() const override
Return a new map representing the inverse of this map.
Definition Maps.h:1703
openvdb::v10_0::math::UnitaryMap::UnitaryMap
UnitaryMap()
default constructor makes an Idenity.
Definition Maps.h:1630
openvdb::v10_0::math::UnitaryMap::read
void read(std::istream &is) override
read serialization
Definition Maps.h:1792
openvdb::v10_0::math::UnitaryMap::applyInverseMap
Vec3d applyInverseMap(const Vec3d &in) const override
Return the pre-image of in under the map.
Definition Maps.h:1741
openvdb::v10_0::math::UnitaryMap::create
static MapBase::Ptr create()
Return a MapBase::Ptr to a new UnitaryMap.
Definition Maps.h:1699
openvdb::v10_0::math::UnitaryMap::operator!=
bool operator!=(const UnitaryMap &other) const
Definition Maps.h:1737
openvdb::v10_0::math::UnitaryMap::applyIJC
Mat3d applyIJC(const Mat3d &in) const override
Return the Jacobian Curvature: zero for a linear map.
Definition Maps.h:1773
openvdb::v10_0::math::UnitaryMap::Ptr
SharedPtr< UnitaryMap > Ptr
Definition Maps.h:1626
openvdb::v10_0::math::UnitaryMap::mapType
static Name mapType()
Return UnitaryMap.
Definition Maps.h:1720
openvdb::v10_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const Mat3d &m)
Definition Maps.h:1648
openvdb::v10_0::math::UnitaryMap::UnitaryMap
UnitaryMap(const UnitaryMap &first, const UnitaryMap &second)
Definition Maps.h:1691
openvdb::v10_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:1728
openvdb::v10_0::math::Vec3::x
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition Vec3.h:85
openvdb::v10_0::math::Vec3::length
T length() const
Length of the vector.
Definition Vec3.h:200
openvdb::v10_0::math::Vec3::dot
T dot(const Vec3< T > &v) const
Dot product.
Definition Vec3.h:191
openvdb::v10_0::math::Vec3::asPointer
T * asPointer()
Definition Vec3.h:94
openvdb::v10_0::math::Vec3::y
T & y()
Definition Vec3.h:86
openvdb::v10_0::math::Vec3::z
T & z()
Definition Vec3.h:87
openvdb::v10_0::math::Vec3::normalize
bool normalize(T eps=T(1.0e-7))
this = normalized this
Definition Vec3.h:362
io.h
openvdb::v10_0::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v10_0::math::hasTranslation
bool hasTranslation(const Mat4< T > &m)
Definition Mat4.h:1309
openvdb::v10_0::math::Mat3d
Mat3< double > Mat3d
Definition Mat3.h:834
openvdb::v10_0::math::SymmetricMap
SpectralDecomposedMap SymmetricMap
Definition Maps.h:46
openvdb::v10_0::math::createSymmetricMap
OPENVDB_API SharedPtr< SymmetricMap > createSymmetricMap(const Mat3d &m)
Utility methods.
openvdb::v10_0::math::createPolarDecomposedMap
OPENVDB_API SharedPtr< PolarDecomposedMap > createPolarDecomposedMap(const Mat3d &m)
Decomposes a general linear into translation following polar decomposition.
openvdb::v10_0::math::isDiagonal
bool isDiagonal(const MatType &mat)
Determine if a matrix is diagonal.
Definition Mat.h:902
openvdb::v10_0::math::simplify
OPENVDB_API SharedPtr< MapBase > simplify(SharedPtr< AffineMap > affine)
reduces an AffineMap to a ScaleMap or a ScaleTranslateMap when it can
openvdb::v10_0::math::isApproxEqual
bool isApproxEqual(const Type &a, const Type &b, const Type &tolerance)
Return true if a is equal to b to within the given tolerance.
Definition Math.h:406
openvdb::v10_0::math::UnitaryAndTranslationMap
CompoundMap< UnitaryMap, TranslationMap > UnitaryAndTranslationMap
Definition Maps.h:44
openvdb::v10_0::math::FullyDecomposedMap
CompoundMap< SymmetricMap, UnitaryAndTranslationMap > FullyDecomposedMap
Definition Maps.h:47
openvdb::v10_0::math::isInvertible
bool isInvertible(const MatType &m)
Determine if a matrix is invertible.
Definition Mat.h:869
openvdb::v10_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::v10_0::math::scale
MatType scale(const Vec3< typename MatType::value_type > &s)
Return a matrix that scales by s.
Definition Mat.h:615
openvdb::v10_0::math::isUnitary
bool isUnitary(const MatType &m)
Determine if a matrix is unitary (i.e., rotation or reflection).
Definition Mat.h:889
openvdb::v10_0::math::SpectralDecomposedMap
CompoundMap< CompoundMap< UnitaryMap, ScaleMap >, UnitaryMap > SpectralDecomposedMap
Definition Maps.h:45
openvdb::v10_0::math::Vec3d
Vec3< double > Vec3d
Definition Vec3.h:664
openvdb::v10_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::v10_0::math::isAffine
bool isAffine(const Mat4< T > &m)
Definition Mat4.h:1304
openvdb::v10_0::math::PolarDecomposedMap
CompoundMap< SymmetricMap, UnitaryMap > PolarDecomposedMap
Definition Maps.h:48
openvdb::v10_0::math::Mat4d
Mat4< double > Mat4d
Definition Mat4.h:1354
openvdb::v10_0::math::Round
float Round(float x)
Return x rounded to the nearest integer.
Definition Math.h:819
openvdb::v10_0::math::isIdentity
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition Mat.h:860
openvdb::v10_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:688
openvdb::v10_0::math::Axis
Axis
Definition Math.h:901
openvdb::v10_0::math::X_AXIS
@ X_AXIS
Definition Math.h:902
openvdb::v10_0::Name
std::string Name
Definition Name.h:17
openvdb::v10_0::readString
Name readString(std::istream &is)
Definition Name.h:20
openvdb::v10_0::writeString
void writeString(std::ostream &os, const Name &name)
Definition Name.h:31
openvdb::v10_0::OPENVDB_FILE_VERSION_FLOAT_FRUSTUM_BBOX
@ OPENVDB_FILE_VERSION_FLOAT_FRUSTUM_BBOX
Definition version.h.in:255
openvdb::v10_0::BBoxd
math::BBox< Vec3d > BBoxd
Definition Types.h:84
openvdb::v10_0::SharedPtr
std::shared_ptr< T > SharedPtr
Definition Types.h:114
openvdb::v10_0::StaticPtrCast
SharedPtr< T > StaticPtrCast(const SharedPtr< U > &ptr)
Return a new shared pointer that points to the same object as the given pointer after a static_cast.
Definition Types.h:146
openvdb
Definition Exceptions.h:13
std
Definition Coord.h:587
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
Types.h
openvdb::v10_0::math::Tolerance::value
static T value()
Definition Math.h:148
openvdb::v10_0::math::is_diagonal_jacobian
Definition Maps.h:90
openvdb::v10_0::math::is_diagonal_jacobian::value
static const bool value
Definition Maps.h:91
openvdb::v10_0::math::is_linear< AffineMap >::value
static const bool value
Definition Maps.h:56
openvdb::v10_0::math::is_linear< CompoundMap< T1, T2 > >::value
static const bool value
Definition Maps.h:65
openvdb::v10_0::math::is_linear< ScaleMap >::value
static const bool value
Definition Maps.h:57
openvdb::v10_0::math::is_linear< ScaleTranslateMap >::value
static const bool value
Definition Maps.h:61
openvdb::v10_0::math::is_linear< TranslationMap >::value
static const bool value
Definition Maps.h:60
openvdb::v10_0::math::is_linear< UniformScaleMap >::value
static const bool value
Definition Maps.h:58
openvdb::v10_0::math::is_linear< UniformScaleTranslateMap >::value
static const bool value
Definition Maps.h:62
openvdb::v10_0::math::is_linear< UnitaryMap >::value
static const bool value
Definition Maps.h:59
openvdb::v10_0::math::is_linear
Map traits.
Definition Maps.h:55
openvdb::v10_0::math::is_linear::value
static const bool value
Definition Maps.h:55
openvdb::v10_0::math::is_scale< ScaleMap >::value
static const bool value
Definition Maps.h:80
openvdb::v10_0::math::is_scale_translate< ScaleTranslateMap >::value
static const bool value
Definition Maps.h:83
openvdb::v10_0::math::is_scale_translate
Definition Maps.h:82
openvdb::v10_0::math::is_scale_translate::value
static const bool value
Definition Maps.h:82
openvdb::v10_0::math::is_scale
Definition Maps.h:79
openvdb::v10_0::math::is_scale::value
static const bool value
Definition Maps.h:79
openvdb::v10_0::math::is_uniform_diagonal_jacobian
Definition Maps.h:86
openvdb::v10_0::math::is_uniform_diagonal_jacobian::value
static const bool value
Definition Maps.h:87
openvdb::v10_0::math::is_uniform_scale< UniformScaleMap >::value
static const bool value
Definition Maps.h:70
openvdb::v10_0::math::is_uniform_scale_translate< TranslationMap >::value
static const bool value
Definition Maps.h:73
openvdb::v10_0::math::is_uniform_scale_translate< UniformScaleTranslateMap >::value
static const bool value
Definition Maps.h:75
openvdb::v10_0::math::is_uniform_scale_translate
Definition Maps.h:72
openvdb::v10_0::math::is_uniform_scale_translate::value
static const bool value
Definition Maps.h:72
openvdb::v10_0::math::is_uniform_scale
Definition Maps.h:69
openvdb::v10_0::math::is_uniform_scale::value
static const bool value
Definition Maps.h:69
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:212