Loading...
Searching...
No Matches
Vec4.h
Go to the documentation of this file.
// Copyright Contributors to the OpenVDB Project
// SPDX-License-Identifier: MPL-2.0
#ifndef OPENVDB_MATH_VEC4_HAS_BEEN_INCLUDED
#define OPENVDB_MATH_VEC4_HAS_BEEN_INCLUDED
#include <openvdb/Exceptions.h>
#include "Math.h"
#include "Tuple.h"
#include "Vec3.h"
#include <algorithm>
#include <cmath>
#include <type_traits>
namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
namespace OPENVDB_VERSION_NAME {
namespace math {
template<typename T> class Mat3;
template<typename T>
class Vec4: public Tuple<4, T>
{
public:
using value_type = T;
using ValueType = T;
/// Trivial constructor, the vector is NOT initialized
/// @note destructor, copy constructor, assignment operator and
/// move constructor are left to be defined by the compiler (default)
Vec4() = default;
/// @brief Construct a vector all of whose components have the given value.
explicit Vec4(T val) { this->mm[0] = this->mm[1] = this->mm[2] = this->mm[3] = val; }
/// Constructor with four arguments, e.g. Vec4f v(1,2,3,4);
Vec4(T x, T y, T z, T w)
{
this->mm[0] = x;
this->mm[1] = y;
this->mm[2] = z;
this->mm[3] = w;
}
/// Constructor with array argument, e.g. float a[4]; Vec4f v(a);
template <typename Source>
Vec4(Source *a)
{
this->mm[0] = static_cast<T>(a[0]);
this->mm[1] = static_cast<T>(a[1]);
this->mm[2] = static_cast<T>(a[2]);
this->mm[3] = static_cast<T>(a[3]);
}
/// Conversion constructor
template<typename Source>
explicit Vec4(const Tuple<4, Source> &v)
{
this->mm[0] = static_cast<T>(v[0]);
this->mm[1] = static_cast<T>(v[1]);
this->mm[2] = static_cast<T>(v[2]);
this->mm[3] = static_cast<T>(v[3]);
}
/// @brief Construct a vector all of whose components have the given value,
/// which may be of an arithmetic type different from this vector's value type.
/// @details Type conversion warnings are suppressed.
template<typename Other>
explicit Vec4(Other val,
typename std::enable_if<std::is_arithmetic<Other>::value, Conversion>::type = Conversion{})
{
this->mm[0] = this->mm[1] = this->mm[2] = this->mm[3] = static_cast<T>(val);
}
/// Reference to the component, e.g. v.x() = 4.5f;
T& x() { return this->mm[0]; }
T& y() { return this->mm[1]; }
T& z() { return this->mm[2]; }
T& w() { return this->mm[3]; }
/// Get the component, e.g. float f = v.y();
T x() const { return this->mm[0]; }
T y() const { return this->mm[1]; }
T z() const { return this->mm[2]; }
T w() const { return this->mm[3]; }
T* asPointer() { return this->mm; }
const T* asPointer() const { return this->mm; }
/// Alternative indexed reference to the elements
T& operator()(int i) { return this->mm[i]; }
/// Alternative indexed constant reference to the elements,
T operator()(int i) const { return this->mm[i]; }
/// Returns a Vec3 with the first three elements of the Vec4.
Vec3<T> getVec3() const { return Vec3<T>(this->mm[0], this->mm[1], this->mm[2]); }
/// "this" vector gets initialized to [x, y, z, w],
/// calling v.init(); has same effect as calling v = Vec4::zero();
const Vec4<T>& init(T x=0, T y=0, T z=0, T w=0)
{
this->mm[0] = x; this->mm[1] = y; this->mm[2] = z; this->mm[3] = w;
return *this;
}
/// Set "this" vector to zero
const Vec4<T>& setZero()
{
this->mm[0] = 0; this->mm[1] = 0; this->mm[2] = 0; this->mm[3] = 0;
return *this;
}
/// Assignment operator
template<typename Source>
const Vec4<T>& operator=(const Vec4<Source> &v)
{
// note: don't static_cast because that suppresses warnings
this->mm[0] = v[0];
this->mm[1] = v[1];
this->mm[2] = v[2];
this->mm[3] = v[3];
return *this;
}
/// Test if "this" vector is equivalent to vector v with tolerance
/// of eps
bool eq(const Vec4<T> &v, T eps = static_cast<T>(1.0e-8)) const
{
return isApproxEqual(this->mm[0], v.mm[0], eps) &&
isApproxEqual(this->mm[1], v.mm[1], eps) &&
isApproxEqual(this->mm[2], v.mm[2], eps) &&
isApproxEqual(this->mm[3], v.mm[3], eps);
}
/// Negation operator, for e.g. v1 = -v2;
Vec4<T> operator-() const
{
return Vec4<T>(
-this->mm[0],
-this->mm[1],
-this->mm[2],
-this->mm[3]);
}
/// this = v1 + v2
/// "this", v1 and v2 need not be distinct objects, e.g. v.add(v1,v);
template <typename T0, typename T1>
const Vec4<T>& add(const Vec4<T0> &v1, const Vec4<T1> &v2)
{
this->mm[0] = v1[0] + v2[0];
this->mm[1] = v1[1] + v2[1];
this->mm[2] = v1[2] + v2[2];
this->mm[3] = v1[3] + v2[3];
return *this;
}
/// this = v1 - v2
/// "this", v1 and v2 need not be distinct objects, e.g. v.sub(v1,v);
template <typename T0, typename T1>
const Vec4<T>& sub(const Vec4<T0> &v1, const Vec4<T1> &v2)
{
this->mm[0] = v1[0] - v2[0];
this->mm[1] = v1[1] - v2[1];
this->mm[2] = v1[2] - v2[2];
this->mm[3] = v1[3] - v2[3];
return *this;
}
/// this = scalar*v, v need not be a distinct object from "this",
/// e.g. v.scale(1.5,v1);
template <typename T0, typename T1>
const Vec4<T>& scale(T0 scale, const Vec4<T1> &v)
{
this->mm[0] = scale * v[0];
this->mm[1] = scale * v[1];
this->mm[2] = scale * v[2];
this->mm[3] = scale * v[3];
return *this;
}
template <typename T0, typename T1>
const Vec4<T> &div(T0 scalar, const Vec4<T1> &v)
{
this->mm[0] = v[0] / scalar;
this->mm[1] = v[1] / scalar;
this->mm[2] = v[2] / scalar;
this->mm[3] = v[3] / scalar;
return *this;
}
/// Dot product
T dot(const Vec4<T> &v) const
{
return (this->mm[0]*v.mm[0] + this->mm[1]*v.mm[1]
+ this->mm[2]*v.mm[2] + this->mm[3]*v.mm[3]);
}
/// Length of the vector
T length() const
{
return std::sqrt(
this->mm[0]*this->mm[0] +
this->mm[1]*this->mm[1] +
this->mm[2]*this->mm[2] +
this->mm[3]*this->mm[3]);
}
/// Squared length of the vector, much faster than length() as it
/// does not involve square root
T lengthSqr() const
{
return (this->mm[0]*this->mm[0] + this->mm[1]*this->mm[1]
+ this->mm[2]*this->mm[2] + this->mm[3]*this->mm[3]);
}
/// Return a reference to itself after the exponent has been
/// applied to all the vector components.
inline const Vec4<T>& exp()
{
this->mm[0] = std::exp(this->mm[0]);
this->mm[1] = std::exp(this->mm[1]);
this->mm[2] = std::exp(this->mm[2]);
this->mm[3] = std::exp(this->mm[3]);
return *this;
}
/// Return a reference to itself after log has been
/// applied to all the vector components.
inline const Vec4<T>& log()
{
this->mm[0] = std::log(this->mm[0]);
this->mm[1] = std::log(this->mm[1]);
this->mm[2] = std::log(this->mm[2]);
this->mm[3] = std::log(this->mm[3]);
return *this;
}
/// Return the sum of all the vector components.
inline T sum() const
{
return this->mm[0] + this->mm[1] + this->mm[2] + this->mm[3];
}
/// Return the product of all the vector components.
inline T product() const
{
return this->mm[0] * this->mm[1] * this->mm[2] * this->mm[3];
}
/// this = normalized this
bool normalize(T eps = static_cast<T>(1.0e-8))
{
T d = length();
if (isApproxEqual(d, T(0), eps)) {
return false;
}
*this *= (T(1) / d);
return true;
}
/// return normalized this, throws if null vector
Vec4<T> unit(T eps=0) const
{
T d;
return unit(eps, d);
}
/// return normalized this and length, throws if null vector
Vec4<T> unit(T eps, T& len) const
{
len = length();
if (isApproxEqual(len, T(0), eps)) {
throw ArithmeticError("Normalizing null 4-vector");
}
return *this / len;
}
/// return normalized this, or (1, 0, 0, 0) if this is null vector
Vec4<T> unitSafe() const
{
T l2 = lengthSqr();
return l2 ? *this / static_cast<T>(sqrt(l2)) : Vec4<T>(1, 0, 0, 0);
}
/// Multiply each element of this vector by @a scalar.
template <typename S>
const Vec4<T> &operator*=(S scalar)
{
this->mm[0] *= scalar;
this->mm[1] *= scalar;
this->mm[2] *= scalar;
this->mm[3] *= scalar;
return *this;
}
/// Multiply each element of this vector by the corresponding element of the given vector.
template <typename S>
const Vec4<T> &operator*=(const Vec4<S> &v1)
{
this->mm[0] *= v1[0];
this->mm[1] *= v1[1];
this->mm[2] *= v1[2];
this->mm[3] *= v1[3];
return *this;
}
/// Divide each element of this vector by @a scalar.
template <typename S>
const Vec4<T> &operator/=(S scalar)
{
this->mm[0] /= scalar;
this->mm[1] /= scalar;
this->mm[2] /= scalar;
this->mm[3] /= scalar;
return *this;
}
/// Divide each element of this vector by the corresponding element of the given vector.
template <typename S>
const Vec4<T> &operator/=(const Vec4<S> &v1)
{
this->mm[0] /= v1[0];
this->mm[1] /= v1[1];
this->mm[2] /= v1[2];
this->mm[3] /= v1[3];
return *this;
}
/// Add @a scalar to each element of this vector.
template <typename S>
const Vec4<T> &operator+=(S scalar)
{
this->mm[0] += scalar;
this->mm[1] += scalar;
this->mm[2] += scalar;
this->mm[3] += scalar;
return *this;
}
/// Add each element of the given vector to the corresponding element of this vector.
template <typename S>
const Vec4<T> &operator+=(const Vec4<S> &v1)
{
this->mm[0] += v1[0];
this->mm[1] += v1[1];
this->mm[2] += v1[2];
this->mm[3] += v1[3];
return *this;
}
/// Subtract @a scalar from each element of this vector.
template <typename S>
const Vec4<T> &operator-=(S scalar)
{
this->mm[0] -= scalar;
this->mm[1] -= scalar;
this->mm[2] -= scalar;
this->mm[3] -= scalar;
return *this;
}
/// Subtract each element of the given vector from the corresponding element of this vector.
template <typename S>
const Vec4<T> &operator-=(const Vec4<S> &v1)
{
this->mm[0] -= v1[0];
this->mm[1] -= v1[1];
this->mm[2] -= v1[2];
this->mm[3] -= v1[3];
return *this;
}
// Number of cols, rows, elements
static unsigned numRows() { return 1; }
static unsigned numColumns() { return 4; }
static unsigned numElements() { return 4; }
/// Predefined constants, e.g. Vec4f v = Vec4f::xNegAxis();
static Vec4<T> zero() { return Vec4<T>(0, 0, 0, 0); }
static Vec4<T> origin() { return Vec4<T>(0, 0, 0, 1); }
static Vec4<T> ones() { return Vec4<T>(1, 1, 1, 1); }
};
/// Equality operator, does exact floating point comparisons
template <typename T0, typename T1>
inline bool operator==(const Vec4<T0> &v0, const Vec4<T1> &v1)
{
return
isExactlyEqual(v0[0], v1[0]) &&
isExactlyEqual(v0[1], v1[1]) &&
isExactlyEqual(v0[2], v1[2]) &&
isExactlyEqual(v0[3], v1[3]);
}
/// Inequality operator, does exact floating point comparisons
template <typename T0, typename T1>
inline bool operator!=(const Vec4<T0> &v0, const Vec4<T1> &v1) { return !(v0==v1); }
/// Multiply each element of the given vector by @a scalar and return the result.
template <typename S, typename T>
inline Vec4<typename promote<S, T>::type> operator*(S scalar, const Vec4<T> &v)
{ return v*scalar; }
/// Multiply each element of the given vector by @a scalar and return the result.
template <typename S, typename T>
inline Vec4<typename promote<S, T>::type> operator*(const Vec4<T> &v, S scalar)
{
Vec4<typename promote<S, T>::type> result(v);
result *= scalar;
return result;
}
/// Multiply corresponding elements of @a v0 and @a v1 and return the result.
template <typename T0, typename T1>
inline Vec4<typename promote<T0, T1>::type> operator*(const Vec4<T0> &v0, const Vec4<T1> &v1)
{
Vec4<typename promote<T0, T1>::type> result(v0[0]*v1[0],
v0[1]*v1[1],
v0[2]*v1[2],
v0[3]*v1[3]);
return result;
}
/// Divide @a scalar by each element of the given vector and return the result.
template <typename S, typename T>
inline Vec4<typename promote<S, T>::type> operator/(S scalar, const Vec4<T> &v)
{
return Vec4<typename promote<S, T>::type>(scalar/v[0],
scalar/v[1],
scalar/v[2],
scalar/v[3]);
}
/// Divide each element of the given vector by @a scalar and return the result.
template <typename S, typename T>
inline Vec4<typename promote<S, T>::type> operator/(const Vec4<T> &v, S scalar)
{
Vec4<typename promote<S, T>::type> result(v);
result /= scalar;
return result;
}
/// Divide corresponding elements of @a v0 and @a v1 and return the result.
template <typename T0, typename T1>
inline Vec4<typename promote<T0, T1>::type> operator/(const Vec4<T0> &v0, const Vec4<T1> &v1)
{
Vec4<typename promote<T0, T1>::type>
result(v0[0]/v1[0], v0[1]/v1[1], v0[2]/v1[2], v0[3]/v1[3]);
return result;
}
/// Add corresponding elements of @a v0 and @a v1 and return the result.
template <typename T0, typename T1>
inline Vec4<typename promote<T0, T1>::type> operator+(const Vec4<T0> &v0, const Vec4<T1> &v1)
{
Vec4<typename promote<T0, T1>::type> result(v0);
result += v1;
return result;
}
/// Add @a scalar to each element of the given vector and return the result.
template <typename S, typename T>
inline Vec4<typename promote<S, T>::type> operator+(const Vec4<T> &v, S scalar)
{
Vec4<typename promote<S, T>::type> result(v);
result += scalar;
return result;
}
/// Subtract corresponding elements of @a v0 and @a v1 and return the result.
template <typename T0, typename T1>
inline Vec4<typename promote<T0, T1>::type> operator-(const Vec4<T0> &v0, const Vec4<T1> &v1)
{
Vec4<typename promote<T0, T1>::type> result(v0);
result -= v1;
return result;
}
/// Subtract @a scalar from each element of the given vector and return the result.
template <typename S, typename T>
inline Vec4<typename promote<S, T>::type> operator-(const Vec4<T> &v, S scalar)
{
Vec4<typename promote<S, T>::type> result(v);
result -= scalar;
return result;
}
template <typename T>
inline bool
isApproxEqual(const Vec4<T>& a, const Vec4<T>& b)
{
return a.eq(b);
}
template <typename T>
inline bool
isApproxEqual(const Vec4<T>& a, const Vec4<T>& b, const Vec4<T>& eps)
{
return isApproxEqual(a[0], b[0], eps[0]) &&
isApproxEqual(a[1], b[1], eps[1]) &&
isApproxEqual(a[2], b[2], eps[2]) &&
isApproxEqual(a[3], b[3], eps[3]);
}
template<typename T>
inline Vec4<T>
Abs(const Vec4<T>& v)
{
return Vec4<T>(Abs(v[0]), Abs(v[1]), Abs(v[2]), Abs(v[3]));
}
/// @remark We are switching to a more explicit name because the semantics
/// are different from std::min/max. In that case, the function returns a
/// reference to one of the objects based on a comparator. Here, we must
/// fabricate a new object which might not match either of the inputs.
/// Return component-wise minimum of the two vectors.
template <typename T>
inline Vec4<T> minComponent(const Vec4<T> &v1, const Vec4<T> &v2)
{
return Vec4<T>(
std::min(v1.x(), v2.x()),
std::min(v1.y(), v2.y()),
std::min(v1.z(), v2.z()),
std::min(v1.w(), v2.w()));
}
/// Return component-wise maximum of the two vectors.
template <typename T>
inline Vec4<T> maxComponent(const Vec4<T> &v1, const Vec4<T> &v2)
{
return Vec4<T>(
std::max(v1.x(), v2.x()),
std::max(v1.y(), v2.y()),
std::max(v1.z(), v2.z()),
std::max(v1.w(), v2.w()));
}
/// @brief Return a vector with the exponent applied to each of
/// the components of the input vector.
template <typename T>
inline Vec4<T> Exp(Vec4<T> v) { return v.exp(); }
/// @brief Return a vector with log applied to each of
/// the components of the input vector.
template <typename T>
inline Vec4<T> Log(Vec4<T> v) { return v.log(); }
using Vec4i = Vec4<int32_t>;
using Vec4ui = Vec4<uint32_t>;
using Vec4s = Vec4<float>;
using Vec4d = Vec4<double>;
OPENVDB_IS_POD(Vec4i)
OPENVDB_IS_POD(Vec4ui)
OPENVDB_IS_POD(Vec4s)
OPENVDB_IS_POD(Vec4d)
} // namespace math
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
#endif // OPENVDB_MATH_VEC4_HAS_BEEN_INCLUDED
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
OPENVDB_IS_POD
#define OPENVDB_IS_POD(Type)
Definition Math.h:56
Tuple.h
Vec3.h
openvdb::v10_0::ArithmeticError
Definition Exceptions.h:56
openvdb::v10_0::math::Vec4< Real >::mm
Real mm[SIZE]
Definition Tuple.h:164
openvdb::v10_0::math::Tuple< 4, T >::Tuple
Tuple()=default
openvdb::v10_0::math::Vec3
Definition Vec3.h:24
openvdb::v10_0::math::Vec4
Definition Vec4.h:25
openvdb::v10_0::math::Vec4::Vec4
Vec4(const Tuple< 4, Source > &v)
Conversion constructor.
Definition Vec4.h:59
openvdb::v10_0::math::Vec4::Vec4
Vec4(Source *a)
Constructor with array argument, e.g. float a[4]; Vec4f v(a);.
Definition Vec4.h:49
openvdb::v10_0::math::Vec4< Real >::x
Real & x()
Definition Vec4.h:78
openvdb::v10_0::math::Vec4::exp
const Vec4< T > & exp()
Definition Vec4.h:228
openvdb::v10_0::math::Vec4::getVec3
Vec3< T > getVec3() const
Returns a Vec3 with the first three elements of the Vec4.
Definition Vec4.h:99
openvdb::v10_0::math::Vec4::normalize
bool normalize(T eps=static_cast< T >(1.0e-8))
this = normalized this
Definition Vec4.h:261
openvdb::v10_0::math::Vec4::log
const Vec4< T > & log()
Definition Vec4.h:239
openvdb::v10_0::math::Vec4::init
const Vec4< T > & init(T x=0, T y=0, T z=0, T w=0)
Definition Vec4.h:103
openvdb::v10_0::math::Vec4::length
T length() const
Length of the vector.
Definition Vec4.h:208
openvdb::v10_0::math::Vec4::sum
T sum() const
Return the sum of all the vector components.
Definition Vec4.h:249
openvdb::v10_0::math::Vec4::ones
static Vec4< T > ones()
Definition Vec4.h:392
openvdb::v10_0::math::Vec4::Vec4
Vec4(T x, T y, T z, T w)
Constructor with four arguments, e.g. Vec4f v(1,2,3,4);.
Definition Vec4.h:39
openvdb::v10_0::math::Vec4::numColumns
static unsigned numColumns()
Definition Vec4.h:386
openvdb::v10_0::math::Vec4::add
const Vec4< T > & add(const Vec4< T0 > &v1, const Vec4< T1 > &v2)
Definition Vec4.h:152
openvdb::v10_0::math::Vec4::operator-=
const Vec4< T > & operator-=(S scalar)
Subtract scalar from each element of this vector.
Definition Vec4.h:364
openvdb::v10_0::math::Vec4::origin
static Vec4< T > origin()
Definition Vec4.h:391
openvdb::v10_0::math::Vec4::asPointer
T * asPointer()
Definition Vec4.h:89
openvdb::v10_0::math::Vec4::numRows
static unsigned numRows()
Definition Vec4.h:385
openvdb::v10_0::math::Vec4::div
const Vec4< T > & div(T0 scalar, const Vec4< T1 > &v)
Definition Vec4.h:190
openvdb::v10_0::math::Vec4::w
T w() const
Definition Vec4.h:87
openvdb::v10_0::math::Vec4::operator()
T & operator()(int i)
Alternative indexed reference to the elements.
Definition Vec4.h:93
openvdb::v10_0::math::Vec4< Real >::y
Real & y()
Definition Vec4.h:79
openvdb::v10_0::math::Vec4< Real >::z
Real & z()
Definition Vec4.h:80
openvdb::v10_0::math::Vec4::operator/=
const Vec4< T > & operator/=(const Vec4< S > &v1)
Divide each element of this vector by the corresponding element of the given vector.
Definition Vec4.h:331
openvdb::v10_0::math::Vec4::operator()
T operator()(int i) const
Alternative indexed constant reference to the elements,.
Definition Vec4.h:96
openvdb::v10_0::math::Vec4::product
T product() const
Return the product of all the vector components.
Definition Vec4.h:255
openvdb::v10_0::math::Vec4::zero
static Vec4< T > zero()
Predefined constants, e.g. Vec4f v = Vec4f::xNegAxis();.
Definition Vec4.h:390
openvdb::v10_0::math::Vec4::asPointer
const T * asPointer() const
Definition Vec4.h:90
openvdb::v10_0::math::Vec4::lengthSqr
T lengthSqr() const
Definition Vec4.h:220
openvdb::v10_0::math::Vec4::operator+=
const Vec4< T > & operator+=(const Vec4< S > &v1)
Add each element of the given vector to the corresponding element of this vector.
Definition Vec4.h:353
openvdb::v10_0::math::Vec4::unit
Vec4< T > unit(T eps=0) const
return normalized this, throws if null vector
Definition Vec4.h:272
openvdb::v10_0::math::Vec4::sub
const Vec4< T > & sub(const Vec4< T0 > &v1, const Vec4< T1 > &v2)
Definition Vec4.h:166
openvdb::v10_0::math::Vec4::x
T x() const
Get the component, e.g. float f = v.y();.
Definition Vec4.h:84
openvdb::v10_0::math::Vec4::operator+=
const Vec4< T > & operator+=(S scalar)
Add scalar to each element of this vector.
Definition Vec4.h:342
openvdb::v10_0::math::Vec4::dot
T dot(const Vec4< T > &v) const
Dot product.
Definition Vec4.h:201
openvdb::v10_0::math::Vec4::z
T z() const
Definition Vec4.h:86
openvdb::v10_0::math::Vec4::unitSafe
Vec4< T > unitSafe() const
return normalized this, or (1, 0, 0, 0) if this is null vector
Definition Vec4.h:289
openvdb::v10_0::math::Vec4::y
T y() const
Definition Vec4.h:85
openvdb::v10_0::math::Vec4::Vec4
Vec4()=default
openvdb::v10_0::math::Vec4::setZero
const Vec4< T > & setZero()
Set "this" vector to zero.
Definition Vec4.h:110
openvdb::v10_0::math::Vec4::numElements
static unsigned numElements()
Definition Vec4.h:387
openvdb::v10_0::math::Vec4::scale
const Vec4< T > & scale(T0 scale, const Vec4< T1 > &v)
Definition Vec4.h:179
openvdb::v10_0::math::Vec4::operator-
Vec4< T > operator-() const
Negation operator, for e.g. v1 = -v2;.
Definition Vec4.h:140
openvdb::v10_0::math::Vec4::operator/=
const Vec4< T > & operator/=(S scalar)
Divide each element of this vector by scalar.
Definition Vec4.h:320
openvdb::v10_0::math::Vec4::Vec4
Vec4(Other val, typename std::enable_if< std::is_arithmetic< Other >::value, Conversion >::type=Conversion{})
Construct a vector all of whose components have the given value, which may be of an arithmetic type d...
Definition Vec4.h:71
openvdb::v10_0::math::Vec4::eq
bool eq(const Vec4< T > &v, T eps=static_cast< T >(1.0e-8)) const
Definition Vec4.h:131
openvdb::v10_0::math::Vec4::operator-=
const Vec4< T > & operator-=(const Vec4< S > &v1)
Subtract each element of the given vector from the corresponding element of this vector.
Definition Vec4.h:375
openvdb::v10_0::math::Vec4::Vec4
Vec4(T val)
Construct a vector all of whose components have the given value.
Definition Vec4.h:36
openvdb::v10_0::math::Vec4< Real >::ValueType
Real ValueType
Definition Vec4.h:28
openvdb::v10_0::math::Vec4::operator*=
const Vec4< T > & operator*=(const Vec4< S > &v1)
Multiply each element of this vector by the corresponding element of the given vector.
Definition Vec4.h:308
openvdb::v10_0::math::Vec4::unit
Vec4< T > unit(T eps, T &len) const
return normalized this and length, throws if null vector
Definition Vec4.h:279
openvdb::v10_0::math::Vec4::operator=
const Vec4< T > & operator=(const Vec4< Source > &v)
Assignment operator.
Definition Vec4.h:118
openvdb::v10_0::math::Vec4< Real >::value_type
Real value_type
Definition Vec4.h:27
openvdb::v10_0::math::Vec4< Real >::w
Real & w()
Definition Vec4.h:81
openvdb::v10_0::math::Vec4::operator*=
const Vec4< T > & operator*=(S scalar)
Multiply each element of this vector by scalar.
Definition Vec4.h:297
openvdb::v10_0::math::Log
Vec2< T > Log(Vec2< T > v)
Return a vector with log applied to each of the components of the input vector.
Definition Vec2.h:528
openvdb::v10_0::math::operator==
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition Vec3.h:473
openvdb::v10_0::math::Vec4ui
Vec4< uint32_t > Vec4ui
Definition Vec4.h:560
openvdb::v10_0::math::operator*
Mat3< typename promote< T0, T1 >::type > operator*(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Multiply m0 by m1 and return the resulting matrix.
Definition Mat3.h:597
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::Vec4s
Vec4< float > Vec4s
Definition Vec4.h:561
openvdb::v10_0::math::operator-
Vec3< typename promote< T, Coord::ValueType >::type > operator-(const Vec3< T > &v0, const Coord &v1)
Allow a Coord to be subtracted from a Vec3.
Definition Coord.h:551
openvdb::v10_0::math::operator+
Vec3< typename promote< T, typename Coord::ValueType >::type > operator+(const Vec3< T > &v0, const Coord &v1)
Allow a Coord to be added to or subtracted from a Vec3.
Definition Coord.h:525
openvdb::v10_0::math::Exp
Type Exp(const Type &x)
Return ex.
Definition Math.h:710
openvdb::v10_0::math::Abs
Coord Abs(const Coord &xyz)
Definition Coord.h:515
openvdb::v10_0::math::operator/
Vec2< typename promote< S, T >::type > operator/(S scalar, const Vec2< T > &v)
Divide scalar by each element of the given vector and return the result.
Definition Vec2.h:385
openvdb::v10_0::math::Vec4i
Vec4< int32_t > Vec4i
Definition Vec4.h:559
openvdb::v10_0::math::isExactlyEqual
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition Math.h:443
openvdb::v10_0::math::minComponent
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition Vec2.h:504
openvdb::v10_0::math::operator!=
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition Vec3.h:481
openvdb::v10_0::math::maxComponent
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
Definition Vec2.h:513
openvdb::v10_0::math::Vec4d
Vec4< double > Vec4d
Definition Vec4.h:562
openvdb
Definition Exceptions.h:13
Exceptions.h
openvdb::v10_0::math::Conversion
Dummy class for tag dispatch of conversion constructors.
Definition Tuple.h:23
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