?? vector.h
字號:
#pragma once
#include <cmath>
#include <float.h>
struct CVector
{
public :
CVector() : x( 0.0f ), y( 0.0f ), z( 0.0f )
{}
CVector( float x, float y, float z ) : x( x ), y( y ), z( z )
{}
float x, y, z;
float Magnitude()
{
return sqrt( x*x + y*y + z*z );
}
CVector Normalize()
{
float m = Magnitude();
return CVector( x/m, y/m, z/m);
}
CVector operator + ( CVector v )
{
return CVector ( x + v.x, y + v.y, z + v.z );
}
CVector operator - ( CVector v )
{
return CVector ( x - v.x, y - v.y, z - v.z );
}
void operator += ( CVector v )
{
x = v.x + x; y = v.y + y; z = v.z + z;
}
CVector operator * ( float scale )
{
return CVector( x * scale, y * scale, z * scale );
}
CVector operator ^ ( CVector v )
{
return CVector( y * v.z - z * v.y,
-x * v.z - z * v.x,
x * v.y - y * v.x );
}
float operator * (CVector v)
{
return x*v.x+y*v.y+z*v.z;
}
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -