Skip to end of metadata
Go to start of metadata
You are here: Common > Math > Vec2_tpl Structure
Vec2_tpl Structure
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<F1> &, Vec2_tpl<F2> &)
C++
template <class F1,class F2> Vec2_tpl<F1> operator -(const Vec2_tpl<F1> & op1, const Vec2_tpl<F2> & op2);
Vec2_tpl::! Operator
C++
int operator !() const;
Description

template

Vec2_tpl::!= Operator
C++
bool operator !=(const Vec2_tpl<F> & 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<F> &)
C++
template <class F> Vec2_tpl<F> operator *(F op1, const Vec2_tpl<F> & op2);
Vec2_tpl::* Operator (Vec2_tpl<F1> &, Vec2_tpl<F2>&)
C++
template <class F1,class F2> F1 operator *(const Vec2_tpl<F1> & op1, const Vec2_tpl<F2>& 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<F1> & op1, const Vec2_tpl<F2>& op2);
Description

cross product

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

dot product

Vec2_tpl::+ Operator
C++
template <class F1,class F2> Vec2_tpl<F1> operator +(const Vec2_tpl<F1> & op1, const Vec2_tpl<F2> & op2);
Vec2_tpl::+= Operator
C++
template <class F1,class F2> Vec2_tpl<F1>& operator +=(Vec2_tpl<F1> & op1, const Vec2_tpl<F2> & op2);
Vec2_tpl::= Operator
C++
Vec2_tpl & operator =(const Vec2_tpl & src);
Vec2_tpl::-= Operator
C++
template <class F1,class F2> Vec2_tpl<F1>& operator -=(Vec2_tpl<F1> & op1, const Vec2_tpl<F2> & op2);
Vec2_tpl::== Operator
C++
template <class F> bool operator ==(const Vec2_tpl<F> & left, const Vec2_tpl<F> & 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<F>& safe = Vec2Constants<F>::fVec2_OneX) const;
Vec2_tpl::IsEquivalent Method (Vec2_tpl<F> &, F)
C++
bool IsEquivalent(const Vec2_tpl<F> & v1, F epsilon = VEC_EPSILON) const;
Vec2_tpl::IsEquivalent Method (Vec2_tpl<F>&, Vec2_tpl<F>&, F)
C++
static bool IsEquivalent(const Vec2_tpl<F>& v0, const Vec2_tpl<F>& 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<F>& safe = Vec2Constants<F>::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<F1> &)
C++
template <class F1> Vec2_tpl(const Vec2_tpl<F1> & src);
Vec2_tpl::Vec2_tpl Constructor (Vec3_tpl<F1> &)
C++
template <class F1> explicit Vec2_tpl(const Vec3_tpl<F1> & src);
Vec2_tpl::Vec2_tpl Constructor (Vec3_tpl<F>&)
C++
explicit Vec2_tpl(const Vec3_tpl<F>& v);
Vec2_tpl::Vec2_tpl Constructor (type_zero)
C++
Vec2_tpl(type_zero);
Vec2_tpl::Vec2Constants<T>::fVec2_One Method
C++
template <typename T> Vec2_tpl<T> Vec2Constants<T>::fVec2_One(1, 1);
Vec2_tpl::Vec2Constants<T>::fVec2_OneX Method
C++
template <typename T> Vec2_tpl<T> Vec2Constants<T>::fVec2_OneX(1, 0);
Vec2_tpl::Vec2Constants<T>::fVec2_OneY Method
C++
template <typename T> Vec2_tpl<T> Vec2Constants<T>::fVec2_OneY(0, 1);
Vec2_tpl::Vec2Constants<T>::fVec2_Zero Method
C++
template <typename T> Vec2_tpl<T> Vec2Constants<T>::fVec2_Zero(0, 0);
Vec2_tpl::zero Method
C++
Vec2_tpl& zero();
friend bool operator==(const Vec2_tpl<F> &left, const Vec2_tpl<F> &right) { return left.x == right.x && left.y == right.y; } friend bool operator!=(const Vec2_tpl<F> &left, const Vec2_tpl<F> &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<F> &v) const { return float (x*v.y - y*v.x); } void SetLerp( const Vec2_tpl<F> &p, const Vec2_tpl<F> &q, F t ) { *this = p*(1.0f-t) + q*t;} static Vec2_tpl<F> CreateLerp( const Vec2_tpl<F> &p, const Vec2_tpl<F> &q, F t ) { return p*(1.0f-t) + q*t;} void SetSlerp( const Vec2_tpl<F>& p, const Vec2_tpl<F>& 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<F> CreateSlerp( const Vec2_tpl<F>& p, const Vec2_tpl<F>& q, F t ) { Vec2_tpl<F> 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<F> &left, const Vec2_tpl<F> &right) { return left.x == right.x && left.y == right.y; } friend bool operator!=(const Vec2_tpl<F> &left, const Vec2_tpl<F> &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<F> &v) const { return float (x*v.y - y*v.x); } void SetLerp( const Vec2_tpl<F> &p, const Vec2_tpl<F> &q, F t ) { *this = p*(1.0f-t) + q*t;} static Vec2_tpl<F> CreateLerp( const Vec2_tpl<F> &p, const Vec2_tpl<F> &q, F t ) { return p*(1.0f-t) + q*t;} void SetSlerp( const Vec2_tpl<F>& p, const Vec2_tpl<F>& 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<F> CreateSlerp( const Vec2_tpl<F>& p, const Vec2_tpl<F>& q, F t ) { Vec2_tpl<F> 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<f32> Vec2;
Description

always 32 bit

Vec2_tpl::Vec2d Nested Type
C++
typedef Vec2_tpl<f64> 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<real> 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<real> 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;

In This Topic

  • No labels