?? vector.h
字號:
//========================================================
/**
* @file Vector.h
*
* 項目描述: DirectInput鍵盤演示
* 文件描述: 向量類
* 適用平臺: Windows98/2000/NT/XP
*
* 作者: WWBOSS
* 電子郵件: wwboss123@gmail.com
* 創建日期: 2006-12-06
* 修改日期: 2006-12-10
*
*/
//========================================================
#ifndef __VECTOR_H__
#define __VECTOR_H__
#include "stdafx.h"
/** 向量類 */
class Vector3
{
public:
/** 構造函數 */
Vector3() { x = 0.0; y = 0.0; z = 0.0; }
Vector3( float xx, float yy, float zz)
{
x = xx;
y = yy;
z = zz;
}
Vector3(const Vector3& vec)
{
x = vec.x;
y = vec.y;
z = vec.z;
}
/** 成員函數 */
inline float length(); /**< 計算向量長度 */
Vector3 normalize(); /**< 單位化向量 */
float dotProduct(const Vector3& v); /**< 計算點積 */
Vector3 crossProduct(const Vector3& v); /**< 計算叉積 */
/** 重載操作符 */
Vector3 operator + (const Vector3& v);
Vector3 operator - (const Vector3& v);
Vector3 operator * (float scale);
Vector3 operator / (float scale);
Vector3 operator - ();
public:
float x,y,z;
};
/** 2D平面上的點 */
struct Point2
{
int x,y;
Point2():x(0),y(0) {}
Point2(int _x,int _y):x(_x),y(_y) {}
const Point2 &operator=(const Point2 &p)
{
x = p.x;
y = p.y;
return *this;
}
};
#endif //__VECTOR_H__
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -