4#ifndef OPENVDB_MATH_VEC2_HAS_BEEN_INCLUDED 
    5#define OPENVDB_MATH_VEC2_HAS_BEEN_INCLUDED 
   20template<
typename T> 
class Mat2;
 
   35    explicit Vec2(T val) { this->
mm[0] = this->
mm[1] = val; }
 
   45    template <
typename Source>
 
   48        this->
mm[0] = 
static_cast<T
>(a[0]);
 
   49        this->
mm[1] = 
static_cast<T
>(a[1]);
 
 
   53    template<
typename Source>
 
   56        this->
mm[0] = 
static_cast<T
>(t[0]);
 
   57        this->
mm[1] = 
static_cast<T
>(t[1]);
 
 
   63    template<
typename Other>
 
   67        this->mm[0] = this->mm[1] = 
static_cast<T
>(val);
 
 
   71    T& 
x() {
return this->
mm[0];}
 
   72    T& 
y() {
return this->
mm[1];}
 
   75    T 
x()
 const {
return this->
mm[0];}
 
   76    T 
y()
 const {
return this->
mm[1];}
 
   91        this->
mm[0] = 
x; this->
mm[1] = 
y;
 
 
   98        this->
mm[0] = 0; this->
mm[1] = 0;
 
 
  103    template<
typename Source>
 
  123    bool eq(
const Vec2<T> &v, T eps = 
static_cast<T
>(1.0e-7))
 const 
 
  134    template <
typename T0, 
typename T1>
 
  137        this->
mm[0] = v1[0] + v2[0];
 
  138        this->
mm[1] = v1[1] + v2[1];
 
 
  145    template <
typename T0, 
typename T1>
 
  148        this->
mm[0] = v1[0] - v2[0];
 
  149        this->
mm[1] = v1[1] - v2[1];
 
 
  156    template <
typename T0, 
typename T1>
 
  159        this->
mm[0] = scalar * v[0];
 
  160        this->
mm[1] = scalar * v[1];
 
 
  165    template <
typename T0, 
typename T1>
 
  168        this->
mm[0] = v[0] / scalar;
 
  169        this->
mm[1] = v[1] / scalar;
 
 
  180        return static_cast<T
>(sqrt(
double(this->
mm[0]*this->
mm[0] + this->
mm[1]*this->
mm[1])));
 
 
  191        this->
mm[0] = std::exp(this->
mm[0]);
 
  192        this->
mm[1] = std::exp(this->
mm[1]);
 
 
  200        this->
mm[0] = std::log(this->
mm[0]);
 
  201        this->
mm[1] = std::log(this->
mm[1]);
 
 
  208        return this->
mm[0] + this->
mm[1];
 
 
  214        return this->
mm[0] * this->
mm[1];
 
 
  249        return l2 ? *
this/
static_cast<T
>(sqrt(l2)) : 
Vec2<T>(1,0);
 
 
  253    template <
typename S>
 
  256        this->
mm[0] *= scalar;
 
  257        this->
mm[1] *= scalar;
 
 
  262    template <
typename S>
 
  265        this->
mm[0] *= v1[0];
 
  266        this->
mm[1] *= v1[1];
 
 
  271    template <
typename S>
 
  274        this->
mm[0] /= scalar;
 
  275        this->
mm[1] /= scalar;
 
 
  280    template <
typename S>
 
  283        this->
mm[0] /= v1[0];
 
  284        this->
mm[1] /= v1[1];
 
 
  289    template <
typename S>
 
  292        this->
mm[0] += scalar;
 
  293        this->
mm[1] += scalar;
 
 
  298    template <
typename S>
 
  301        this->
mm[0] += v1[0];
 
  302        this->
mm[1] += v1[1];
 
 
  307    template <
typename S>
 
  310        this->
mm[0] -= scalar;
 
  311        this->
mm[1] -= scalar;
 
 
  316    template <
typename S>
 
  319        this->
mm[0] -= v1[0];
 
  320        this->
mm[1] -= v1[1];
 
 
  336        return dot(onto)*(T(1)/l);
 
 
  346        return onto*(
dot(onto)*(T(1)/l));
 
 
 
  360template <
typename S, 
typename T>
 
  367template <
typename S, 
typename T>
 
  376template <
typename T0, 
typename T1>
 
  384template <
typename S, 
typename T>
 
  391template <
typename S, 
typename T>
 
  400template <
typename T0, 
typename T1>
 
  408template <
typename T0, 
typename T1>
 
  417template <
typename S, 
typename T>
 
  426template <
typename T0, 
typename T1>
 
  435template <
typename S, 
typename T>
 
  507            std::min(v1.
x(), v2.
x()),
 
  508            std::min(v1.
y(), v2.
y()));
 
 
  516            std::max(v1.
x(), v2.
x()),
 
  517            std::max(v1.
y(), v2.
y()));
 
 
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
#define OPENVDB_IS_POD(Type)
Definition Math.h:56
Definition Exceptions.h:56
Real mm[SIZE]
Definition Tuple.h:165
Vec2< T > unit(T eps, T &len) const
return normalized this and length, throws if null vector
Definition Vec2.h:236
Vec2(T x, T y)
Constructor with two arguments, e.g. Vec2f v(1,2,3);.
Definition Vec2.h:38
Real & x()
Definition Vec2.h:71
Vec2(Other val, typename std::enable_if< std::is_arithmetic< Other >::value, Conversion >::type=Conversion{})
Construct a vector all of whose components have the given value, which may be of an arithmetic type d...
Definition Vec2.h:64
bool normalize(T eps=static_cast< T >(1.0e-8))
this = normalized this
Definition Vec2.h:218
const Vec2< T > & operator=(const Vec2< Source > &v)
Assignment operator.
Definition Vec2.h:104
T length() const
Length of the vector.
Definition Vec2.h:178
const Vec2< T > & exp()
Definition Vec2.h:189
T sum() const
Return the sum of all the vector components.
Definition Vec2.h:206
T component(const Vec2< T > &onto, T eps=static_cast< T >(1.0e-8)) const
Definition Vec2.h:331
static unsigned numColumns()
Definition Vec2.h:326
const Vec2< T > & sub(const Vec2< T0 > &v1, const Vec2< T1 > &v2)
Definition Vec2.h:146
bool operator==(const Vec2< T > &v) const
Equality operator, does exact floating point comparisons.
Definition Vec2.h:114
T * asPointer()
Definition Vec2.h:84
const Vec2< T > & log()
Definition Vec2.h:198
static unsigned numRows()
Definition Vec2.h:325
Vec2(Source *a)
Constructor with array argument, e.g. float a[2]; Vec2f v(a);.
Definition Vec2.h:46
const Vec2< T > & operator/=(const Vec2< S > &v1)
Divide each element of this vector by the corresponding element of the given vector.
Definition Vec2.h:281
const Vec2< T > & operator+=(const Vec2< S > &v1)
Add each element of the given vector to the corresponding element of this vector.
Definition Vec2.h:299
const Vec2< T > & operator*=(S scalar)
Multiply each element of this vector by scalar.
Definition Vec2.h:254
T & operator()(int i)
Alternative indexed reference to the elements.
Definition Vec2.h:79
Real & y()
Definition Vec2.h:72
const Vec2< T > & operator-=(const Vec2< S > &v1)
Subtract each element of the given vector from the corresponding element of this vector.
Definition Vec2.h:317
Vec2(T val)
Construct a vector all of whose components have the given value.
Definition Vec2.h:35
T operator()(int i) const
Alternative indexed constant reference to the elements,.
Definition Vec2.h:82
const Vec2< T > & init(T x=0, T y=0)
Definition Vec2.h:89
T product() const
Return the product of all the vector components.
Definition Vec2.h:212
const Vec2< T > & add(const Vec2< T0 > &v1, const Vec2< T1 > &v2)
Definition Vec2.h:135
const Vec2< T > & scale(T0 scalar, const Vec2< T1 > &v)
Definition Vec2.h:157
T dot(const Vec2< T > &v) const
Dot product.
Definition Vec2.h:175
const Vec2< T > & setZero()
Set "this" vector to zero.
Definition Vec2.h:96
const T * asPointer() const
Definition Vec2.h:85
T lengthSqr() const
Definition Vec2.h:185
bool eq(const Vec2< T > &v, T eps=static_cast< T >(1.0e-7)) const
Test if "this" vector is equivalent to vector v with tolerance of eps.
Definition Vec2.h:123
Vec2< T > projection(const Vec2< T > &onto, T eps=static_cast< T >(1.0e-8)) const
Definition Vec2.h:341
static Vec2< T > ones()
Definition Vec2.h:356
T x() const
Get the component, e.g. float f = v.y();.
Definition Vec2.h:75
Vec2(const Tuple< 2, Source > &t)
Conversion constructor.
Definition Vec2.h:54
const Vec2< T > & operator/=(S scalar)
Divide each element of this vector by scalar.
Definition Vec2.h:272
T y() const
Definition Vec2.h:76
const Vec2< T > & operator+=(S scalar)
Add scalar to each element of this vector.
Definition Vec2.h:290
const Vec2< T > & operator*=(const Vec2< S > &v1)
Multiply each element of this vector by the corresponding element of the given vector.
Definition Vec2.h:263
static unsigned numElements()
Definition Vec2.h:327
const Vec2< T > & div(T0 scalar, const Vec2< T1 > &v)
Definition Vec2.h:166
bool operator!=(const Vec2< T > &v) const
Inequality operator, does exact floating point comparisons.
Definition Vec2.h:120
static Vec2< T > zero()
Predefined constants, e.g. Vec2f v = Vec2f::xNegAxis();.
Definition Vec2.h:355
Vec2< T > unit(T eps=0) const
return normalized this, throws if null vector
Definition Vec2.h:229
Vec2< T > operator-() const
Negation operator, for e.g. v1 = -v2;.
Definition Vec2.h:130
Vec2< T > unitSafe() const
return normalized this, or (1, 0) if this is null vector
Definition Vec2.h:246
Real ValueType
Definition Vec2.h:27
const Vec2< T > & operator-=(S scalar)
Subtract scalar from each element of this vector.
Definition Vec2.h:308
Vec2< T > getArbPerpendicular() const
Definition Vec2.h:352
Real value_type
Definition Vec2.h:26
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
Vec2< int32_t > Vec2i
Definition Vec2.h:530
void orthonormalize(Vec2< T > &v1, Vec2< T > &v2)
Definition Vec2.h:476
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
Vec2< double > Vec2d
Definition Vec2.h:533
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
Vec2< float > Vec2s
Definition Vec2.h:532
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:554
Vec2< uint32_t > Vec2ui
Definition Vec2.h:531
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:528
Type Exp(const Type &x)
Return ex.
Definition Math.h:710
Coord Abs(const Coord &xyz)
Definition Coord.h:518
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition Vec2.h:446
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
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition Math.h:443
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition Vec2.h:504
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
Definition Vec2.h:513
Definition Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
Dummy class for tag dispatch of conversion constructors.
Definition Tuple.h:24
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218