📄 xvector2d.inl
字号:
#ifndef __XVECTOR_2D_INLINE_INCLUDE__
#define __XVECTOR_2D_INLINE_INCLUDE__
#ifndef IN_MATHLIB_NAMESPACE
#error You cann't include this file out the XMathLib namespace
#endif
class _MATH_LIB_EXPORT_ XVector2D
{
public:
XVector2D(){};
~XVector2D(){};
XVector2D(float _x,float _y){x = _x ; y = _y; }
void add(XVector2D& rv){x += rv.x; y += rv.y;}
void sub(XVector2D& rv){x -= rv.x; y -= rv.y;}
void mul(float s){x *= s; y *= s;}
float fabs(){ return sqrt(x * x + y * y) ;}
float len(){ return sqrt(x * x + y * y) ;}
float squardlen(){return (x * x + y * y) ;}
void normalize(){float len = sqrt(x * x + y * y) ; x/=len;y/=len; }
void normalize(XVector2D &vout){float len = sqrt(x * x + y * y) ; vout.x = x/len; vout.y = y/len;};
XVector2D operator +(XVector2D& v){ return XVector2D(v.x + x, v.y + y);};
XVector2D operator -(XVector2D& v){ return XVector2D(x - v.x, y - v.y);};
XVector2D operator *(float s){ return XVector2D(x * s, y * s);};
bool operator ==(XVector2D& v) {return (v.x == x && v.y == y); }
bool isZero(){return (x ==0 && y ==0);}
float dp(XVector2D& v){return (v.x*x + v.y *y) ;};
XVector2D& operator +=(XVector2D& v){ x += v.x ; y += v.y ; return *this; }
XVector2D& operator -=(XVector2D& v){ x -= v.x ; y -= v.y ; return *this; }
XVector2D& operator *=(float s){ x *= s ; y *= s ; return *this; };
public:
union
{
struct
{
float x,y;
};
struct
{
float s,t;
};
float v[2];
};
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -