⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xvector2d.inl

📁 XMathLib是一个通用的3D图形数学库。 其中包含两个部分: XMathLib和XGeomLib。分别处理数学和几何运算。 数学部分包含向量、矩阵、四元数的运算。以及其它的运算。 几何部分
💻 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 + -