Vec2_tpl

C++
template <class F>
struct Vec2_tpl {
  F x, y;
};
File

Cry_Vector2.h

Vec2_tpl::x Data Member
C++
F x;
Vec2_tpl::y Data Member
C++
F y;
Vec2_tpl::- Operator ()
C++
Vec2_tpl operator -() const;
Vec2_tpl::- Operator (Vec2_tpl &, Vec2_tpl &)
C++
template <class F1,class F2> Vec2_tpl operator -(const Vec2_tpl & op1, const Vec2_tpl & op2);
Vec2_tpl::! Operator
C++
int operator !() const;
Description

template

Vec2_tpl::!= Operator
C++
bool operator !=(const Vec2_tpl & vec);
Description

bool operator==(const Vec2_tpl&vec) { return x == vec.x && y == vec.y;

Vec2_tpl::* Operator (F)
C++
Vec2_tpl operator *(F k) const;
Vec2_tpl::* Operator (F, Vec2_tpl &)
C++
template <class F> Vec2_tpl operator *(F op1, const Vec2_tpl & op2);
Vec2_tpl::* Operator (Vec2_tpl &, Vec2_tpl&)
C++
template <class F1,class F2> F1 operator *(const Vec2_tpl & op1, const Vec2_tpl& op2);
Description

dot product

Vec2_tpl::*= Operator
C++
Vec2_tpl& operator *=(F k);
Vec2_tpl::/ Operator
C++
Vec2_tpl operator /(F k) const;
Vec2_tpl::/= Operator
C++
Vec2_tpl& operator /=(F k);
Vec2_tpl::[] Operator (int)
C++
F& operator [](int idx);
Vec2_tpl::[] Operator (int)
C++
F operator [](int idx) const;
Vec2_tpl::^ Operator
C++
template <class F1,class F2> F1 operator ^(const Vec2_tpl & op1, const Vec2_tpl& op2);
Description

cross product

Vec2_tpl::| Operator
C++
template <class F1,class F2> F1 operator |(const Vec2_tpl & op1, const Vec2_tpl& op2);
Description

dot product

Vec2_tpl::+ Operator
C++
template <class F1,class F2> Vec2_tpl operator +(const Vec2_tpl & op1, const Vec2_tpl & op2);
Vec2_tpl::+= Operator
C++
template <class F1,class F2> Vec2_tpl& operator +=(Vec2_tpl & op1, const Vec2_tpl & op2);
Vec2_tpl::= Operator
C++
Vec2_tpl & operator =(const Vec2_tpl & src);
Vec2_tpl::-= Operator
C++
template <class F1,class F2> Vec2_tpl& operator -=(Vec2_tpl & op1, const Vec2_tpl & op2);
Vec2_tpl::== Operator
C++
template <class F> bool operator ==(const Vec2_tpl & left, const Vec2_tpl & right);
Vec2_tpl::area Method
C++
F area() const;
Vec2_tpl::atan2 Method
C++
F atan2() const;
Vec2_tpl::clamp_tpl Method
C++
template <>  Vec2 clamp_tpl<Vec2>(Vec2 X, Vec2 Min, Vec2 Max);
Vec2_tpl::F* Operator
C++
operator F*();
Vec2_tpl::flip Method
C++
Vec2_tpl& flip();
Vec2_tpl::GetLength Method
C++
F GetLength() const;
Vec2_tpl::GetLength2 Method
C++
F GetLength2() const;
Vec2_tpl::GetNormalized Method
C++
Vec2_tpl GetNormalized() const;
Vec2_tpl::GetNormalizedSafe Method
C++
Vec2_tpl GetNormalizedSafe(const struct Vec2_tpl& safe = Vec2Constants::fVec2_OneX) const;
Vec2_tpl::IsEquivalent Method (Vec2_tpl &, F)
C++
bool IsEquivalent(const Vec2_tpl & v1, F epsilon = VEC_EPSILON) const;
Vec2_tpl::IsEquivalent Method (Vec2_tpl&, Vec2_tpl&, F)
C++
static bool IsEquivalent(const Vec2_tpl& v0, const Vec2_tpl& v1, F epsilon = VEC_EPSILON);
Vec2_tpl::Normalize Method
C++
Vec2_tpl& Normalize();
Description

The default Normalize function is in fact "safe". 0 vectors remain unchanged.

Vec2_tpl::NormalizeSafe Method
C++
Vec2_tpl& NormalizeSafe(const struct Vec2_tpl& safe = Vec2Constants::fVec2_Zero);
Description

Normalize if non-0, otherwise set to specified "safe" value.

Vec2_tpl::rot90ccw Method
C++
Vec2_tpl rot90ccw() const;
Vec2_tpl::rot90cw Method
C++
Vec2_tpl rot90cw() const;
Vec2_tpl::set Method
C++
Vec2_tpl& set(F nx, F ny);
Vec2_tpl::SetLength Method
C++
void SetLength(F fLen);
Vec2_tpl::Vec2_tpl Constructor ()
C++
Vec2_tpl();
Vec2_tpl::Vec2_tpl Constructor (F, F)
C++
Vec2_tpl(F vx, F vy);
Vec2_tpl::Vec2_tpl Constructor (F1 *)
C++
template <class F1> explicit Vec2_tpl(const F1 * psrc);
Vec2_tpl::Vec2_tpl Constructor (Vec2_tpl &)
C++
template <class F1> Vec2_tpl(const Vec2_tpl & src);
Vec2_tpl::Vec2_tpl Constructor (Vec3_tpl &)
C++
template <class F1> explicit Vec2_tpl(const Vec3_tpl & src);
Vec2_tpl::Vec2_tpl Constructor (Vec3_tpl&)
C++
explicit Vec2_tpl(const Vec3_tpl& v);
Vec2_tpl::Vec2_tpl Constructor (type_zero)
C++
Vec2_tpl(type_zero);
Vec2_tpl::Vec2Constants::fVec2_One Method
C++
template <typename T> Vec2_tpl Vec2Constants::fVec2_One(1, 1);
Vec2_tpl::Vec2Constants::fVec2_OneX Method
C++
template <typename T> Vec2_tpl Vec2Constants::fVec2_OneX(1, 0);
Vec2_tpl::Vec2Constants::fVec2_OneY Method
C++
template <typename T> Vec2_tpl Vec2Constants::fVec2_OneY(0, 1);
Vec2_tpl::Vec2Constants::fVec2_Zero Method
C++
template <typename T> Vec2_tpl Vec2Constants::fVec2_Zero(0, 0);
Vec2_tpl::zero Method
C++
Vec2_tpl& zero();
friend bool operator==(const Vec2_tpl &left, const Vec2_tpl &right) { return left.x == right.x && left.y == right.y; } friend bool operator!=(const Vec2_tpl &left, const Vec2_tpl &right) { return !(left==right); } bool IsZero(F e = (F)0.0) const { return (fabs_tpl(x) <= e) && (fabs_tpl(y) <= e); } bool IsZeroFast(F e = (F)0.0003) const { return (fabs_tpl(x) + fabs_tpl(y)) <= e; } F Dot(const Vec2_tpl &rhs) const {return x*rhs.x + y*rhs.y;} Vec2_tpl Perp() const {return Vec2_tpl(-y, x);} F Cross (const Vec2_tpl &v) const { return float (x*v.y - y*v.x); } void SetLerp( const Vec2_tpl &p, const Vec2_tpl &q, F t ) { *this = p*(1.0f-t) + q*t;} static Vec2_tpl CreateLerp( const Vec2_tpl &p, const Vec2_tpl &q, F t ) { return p*(1.0f-t) + q*t;} void SetSlerp( const Vec2_tpl& p, const Vec2_tpl& q, F t ) { assert((fabs_tpl(1-(p|p)))<0.005); assert((fabs_tpl(1-(q|q)))<0.005); F cosine = (p|q); if(cosine>=(F)0.99) { SetLerp(p,q,t); this->Normalize(); } else { F rad = acos_tpl(cosine); F scale_0 = sin_tpl((1-t)*rad); F scale_1 = sin_tpl(t*rad); *this=(p*scale_0 + q*scale_1) / sin_tpl(rad); this->Normalize(); } } static Vec2_tpl CreateSlerp( const Vec2_tpl& p, const Vec2_tpl& q, F t ) { Vec2_tpl v; v.SetSlerp(p,q,t); return v; } bool IsValid() const { if (!NumberValid(x)) return false; if (!NumberValid(y)) return false; return true; } AUTO_STRUCT_INFO } Friend
C++
friend bool operator==(const Vec2_tpl &left, const Vec2_tpl &right) { return left.x == right.x && left.y == right.y; } friend bool operator!=(const Vec2_tpl &left, const Vec2_tpl &right) { return !(left==right); } bool IsZero(F e = (F)0.0) const { return (fabs_tpl(x) <= e) && (fabs_tpl(y) <= e); } bool IsZeroFast(F e = (F)0.0003) const { return (fabs_tpl(x) + fabs_tpl(y)) <= e; } F Dot(const Vec2_tpl &rhs) const {return x*rhs.x + y*rhs.y;} Vec2_tpl Perp() const {return Vec2_tpl(-y, x);} F Cross (const Vec2_tpl &v) const { return float (x*v.y - y*v.x); } void SetLerp( const Vec2_tpl &p, const Vec2_tpl &q, F t ) { *this = p*(1.0f-t) + q*t;} static Vec2_tpl CreateLerp( const Vec2_tpl &p, const Vec2_tpl &q, F t ) { return p*(1.0f-t) + q*t;} void SetSlerp( const Vec2_tpl& p, const Vec2_tpl& q, F t ) { assert((fabs_tpl(1-(p|p)))<0.005); assert((fabs_tpl(1-(q|q)))<0.005); F cosine = (p|q); if(cosine>=(F)0.99) { SetLerp(p,q,t); this->Normalize(); } else { F rad = acos_tpl(cosine); F scale_0 = sin_tpl((1-t)*rad); F scale_1 = sin_tpl(t*rad); *this=(p*scale_0 + q*scale_1) / sin_tpl(rad); this->Normalize(); } } static Vec2_tpl CreateSlerp( const Vec2_tpl& p, const Vec2_tpl& q, F t ) { Vec2_tpl v; v.SetSlerp(p,q,t); return v; } bool IsValid() const { if (!NumberValid(x)) return false; if (!NumberValid(y)) return false; return true; } AUTO_STRUCT_INFO };
Vec2_tpl::value_type Nested Type
C++
typedef F value_type;
Vec2_tpl::Vec2 Nested Type
C++
typedef Vec2_tpl Vec2;
Description

always 32 bit

Vec2_tpl::Vec2d Nested Type
C++
typedef Vec2_tpl Vec2d;
Description

always 64 bit

Vec2_tpl::Vec2i Nested Type
C++
typedef Vec2_tpl<int> Vec2i;
Vec2_tpl::Vec2r Nested Type
C++
typedef Vec2_tpl Vec2r;
Description

variable float precision. depending on the target system it can be 32, 64 or 80 bit

Vec2_tpl::vector2d Nested Type
C++
typedef Vec2_tpl vector2d;
Vec2_tpl::vector2df Nested Type
C++
typedef Vec2_tpl<float> vector2df;
Vec2_tpl::vector2di Nested Type
C++
typedef Vec2_tpl<int> vector2di;
Vec2_tpl::vector2dui Nested Type
C++
typedef Vec2_tpl<unsigned int> vector2dui;
Vec2_tpl::vector2f Nested Type
C++
typedef Vec2_tpl<float> vector2f;
Vec2_tpl::vector2l Nested Type
C++
typedef Vec2_tpl<long> vector2l;