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

📄 vector3d.h

📁 3D游戏展示程序
💻 H
字号:
//--------------------------------------------------
//  Desc: 3D Vector
//  Date: 2007.4.2 /update
//  Author: artsylee
//
//  Copyright (C) 2007 artsylee
//
//--------------------------------------------------

#ifndef _VECTOR3D_
#define _VECTOR3D_

#include <math.h>

class Vector3D
{
public:
	float	x;
	float	y;
	float	z;

	Vector3D();	
	Vector3D(float fx, float fy, float fz);							
	Vector3D(const Vector3D &v);

	Vector3D	operator-(const Vector3D &v) const;
	Vector3D	operator+(const Vector3D &v) const;
	Vector3D	operator*(float scale) const;
	Vector3D	operator/(float scale) const;
	float		operator*(const Vector3D &v) const;
	Vector3D	operator%(const Vector3D &v) const;

	Vector3D&   operator=(const Vector3D &v);
	Vector3D&	operator+=(const Vector3D &v);
	Vector3D&	operator-=(const Vector3D &v);
	Vector3D&	operator*=(float scale);

	float		LengthSquared() const;
	float		Length() const;
	Vector3D&	Normalize();
	Vector3D	operator~() const;

	operator	float*()	{	return (float*)this;	}
	bool		operator==(const Vector3D &v)	{ return (x == v.x && y == v.y && z == v.z); }
	bool		operator!=(const Vector3D &v)	{ return (x != v.x || y != v.y || z != v.z); }
};

__forceinline Vector3D operator*(float d, const Vector3D& v)	{ v*d;	}
//__forceinline Vector3D operator*(const Vector3D& v, float d)	{ v*d;	}


#endif // _VECTOR3D_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -