00001 #include <windows.h> 00002 #include "vector.h" 00003 #include "mmgr.h" 00004 00005 00006 VECTOR::VECTOR(float sx, float sy, float sz) 00007 : 00008 x(sx), 00009 y(sy), 00010 z(sz) 00011 { 00012 } 00013 00014 VECTOR::~VECTOR() 00015 { 00016 } 00017 00018 void VECTOR::Reset() 00019 { 00020 x = 0; 00021 y = 0; 00022 z = 0; 00023 } 00024 00025 float VECTOR::DotProduct(VECTOR vect) 00026 { 00027 float dot; 00028 dot = vect.x * x + vect.y * y + vect.z * z; 00029 return dot; 00030 } 00031 00032 void VECTOR::CrossVector(VECTOR vect) 00033 { 00034 VECTOR temp = *this; 00035 x = vect.y * temp.z - vect.z * temp.y; 00036 y = vect.z * temp.x - vect.x * temp.z; 00037 z = vect.x * temp.y - vect.y * temp.x; 00038 } 00039 00040 float VECTOR::GetMagnitude() 00041 { 00042 float magnitude = (float)sqrt(x * x + y * y + z * z); 00043 if (magnitude != 0.0f) 00044 return magnitude; 00045 else 00046 return 1.0; 00047 } 00048 00049 void VECTOR::Normalize() 00050 { 00051 float magnitude = this->GetMagnitude(); 00052 x /= magnitude; 00053 y /= magnitude; 00054 z /= magnitude; 00055 }
1.2.15