Cry_Vector2.h
F x;
F y;
Vec2_tpl operator -() const;
int operator !() const;
template
bool operator !=(const Vec2_tpl& vec);
Vec2_tpl operator *(F k) const;
dot product
Vec2_tpl& operator *=(F k);
Vec2_tpl operator /(F k) const;
Vec2_tpl& operator /=(F k);
F& operator [](int idx);
F operator [](int idx) const;
cross product
dot product
F area() const;
F atan2() const;
operator F*();
Vec2_tpl& flip();
F GetLength() const;
F GetLength2() const;
Vec2_tpl GetNormalized() const;
Vec2_tpl GetNormalizedSafe(const struct Vec2_tpl& safe = Vec2Constants ::fVec2_OneX) const;
bool IsEquivalent(const Vec2_tpl& v1, F epsilon = VEC_EPSILON) const;
static bool IsEquivalent(const Vec2_tpl& v0, const Vec2_tpl & v1, F epsilon = VEC_EPSILON);
Vec2_tpl& Normalize();
The default Normalize function is in fact "safe". 0 vectors remain unchanged.
Vec2_tpl& NormalizeSafe(const struct Vec2_tpl& safe = Vec2Constants ::fVec2_Zero);
Normalize if non-0, otherwise set to specified "safe" value.
Vec2_tpl rot90ccw() const;
Vec2_tpl rot90cw() const;
Vec2_tpl& set(F nx, F ny);
void SetLength(F fLen);
Vec2_tpl();
Vec2_tpl(F vx, F vy);
template <class F1> explicit Vec2_tpl(const F1 * psrc);
template <class F1> Vec2_tpl(const Vec2_tpl& src);
template <class F1> explicit Vec2_tpl(const Vec3_tpl& src);
explicit Vec2_tpl(const Vec3_tpl& v);
Vec2_tpl(type_zero);
template <typename T> Vec2_tplVec2Constants ::fVec2_One (1, 1);
template <typename T> Vec2_tplVec2Constants ::fVec2_OneX (1, 0);
template <typename T> Vec2_tplVec2Constants ::fVec2_OneY (0, 1);
template <typename T> Vec2_tplVec2Constants ::fVec2_Zero (0, 0);
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 };
typedef F value_type;
typedef Vec2_tplVec2;
always 32 bit
typedef Vec2_tplVec2d;
always 64 bit
typedef Vec2_tpl<int> Vec2i;
typedef Vec2_tplVec2r;
variable float precision. depending on the target system it can be 32, 64 or 80 bit
typedef Vec2_tplvector2d;
typedef Vec2_tpl<float> vector2df;
typedef Vec2_tpl<int> vector2di;
typedef Vec2_tpl<unsigned int> vector2dui;
typedef Vec2_tpl<float> vector2f;
typedef Vec2_tpl<long> vector2l;