00001 00002 00003 #ifndef VECTOR3F_H 00004 #define VECTOR3F_H 00005 00006 00007 #ifndef PIOVER180 00008 #define PIOVER180 0.0174532925 00009 #define PI 3.1415926536 00010 #define EQUAL_TOLERANCE 0.00001 00011 #endif 00012 00013 #include "Vector4f.h" 00014 00015 #include <string> 00016 00017 00018 namespace pge { 00019 00020 00021 class Vector3f { 00022 public: 00023 //************************************************************************ 00024 // 00025 // Constructor 00026 // 00027 //************************************************************************ 00029 Vector3f(void); 00030 Vector3f(float x, float y, float z); 00031 Vector3f(float v[3]); 00032 Vector3f(const Vector3f ©); 00033 Vector3f(const Vector4f &vec); 00034 00035 00036 //************************************************************************ 00037 // 00038 // Destructor 00039 // 00040 //************************************************************************ 00042 ~Vector3f(void); 00043 00044 00045 //************************************************************************ 00046 // 00047 // Functions 00048 // 00049 //************************************************************************ 00051 Vector3f add(const Vector3f &v); 00052 00054 Vector3f add(float c); 00055 Vector3f subtract(const Vector3f &v); 00056 Vector3f subtract(float c); 00057 Vector3f divide(const Vector3f &v); 00058 Vector3f divide(float c); 00059 Vector3f multiply(const Vector3f &v); 00060 Vector3f multiply(float c); 00061 00063 float sqrMagnitude(void); 00064 00066 float magnitude(void); 00067 00069 float dotProduct(const Vector3f &v); 00070 00072 void normalize(void); 00073 00075 Vector3f crossProduct(const Vector3f &v); 00076 00078 float angle(Vector3f v); 00079 00081 float sqrDistance(const Vector3f &v); 00082 00084 float distance(const Vector3f &v); 00085 00086 bool isNullVector(void); 00087 00089 bool equals(const Vector3f &v); 00090 00091 Vector3f closestPointOnLine(Vector3f lineStart, Vector3f lineEnd); 00092 00093 Vector3f createNormal(Vector3f a, Vector3f b, Vector3f c); 00094 00096 std::string toString(void); 00097 00098 // 00099 // 00100 // 00101 Vector3f operator+(const Vector3f &v) { 00102 return add(v); 00103 } 00104 00105 // 00106 // 00107 // 00108 Vector3f operator-(const Vector3f &v) { 00109 return subtract(v); 00110 } 00111 00112 // 00113 // 00114 // 00115 Vector3f operator*(const Vector3f &v) { 00116 return multiply(v); 00117 } 00118 00119 // 00120 // 00121 // 00122 Vector3f operator*(float f) { 00123 return multiply(f); 00124 } 00125 00126 00127 //************************************************************************ 00128 // 00129 // Variables 00130 // 00131 //************************************************************************ 00132 float m_v[3]; 00133 }; 00134 }; 00135 00136 #endif