00001 #include <windows.h> 00002 00003 00004 #include "vector.h" 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::Set() 00019 { 00020 x = 0; 00021 y = 0; 00022 z = 0; 00023 } 00024 00025 float VECTOR::MagnitudeVector() 00026 { 00027 return(sqrt(x*x+y*y+z*z)); 00028 } 00029 00030 VECTOR VECTOR::NormaliseVector() 00031 { 00032 VECTOR vec; 00033 float temp = MagnitudeVector(); 00034 vec.x = x / temp; 00035 vec.y = y / temp; 00036 vec.z = z / temp; 00037 return vec; 00038 } 00039 00040 float VECTOR::DotProduct(VECTOR vect) 00041 { 00042 float dot; 00043 dot = vect.x * x + vect.y * y + vect.z * z; 00044 return dot; 00045 } 00046 00047 VECTOR VECTOR::CrossProduct(VECTOR vect) 00048 { 00049 VECTOR temp = *this; 00050 x = vect.y * temp.z - vect.z * temp.y; 00051 y = vect.z * temp.x - vect.x * temp.z; 00052 z = vect.x * temp.y - vect.y * temp.x; 00053 return temp; 00054 }
1.2.15