Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef VEC3_H
00011 #define VEC3_H
00012
00013 #include <math.h>
00014 #include <assert.h>
00015 #include <string>
00016 #include "vec2.h"
00017
00018 class Vector3D
00019 {
00020 public:
00021
00022 Vector3D();
00023 Vector3D ( float x, float y, float z );
00024 Vector3D ( const CVec2& v, float z);
00025
00026 Vector3D ( const Vector3D& v2 );
00027
00028 Vector3D operator+ ( const Vector3D& vVector ) const;
00029 Vector3D& operator+= ( const Vector3D& vVector );
00030 Vector3D operator+() const;
00031
00032 Vector3D operator- ( const Vector3D& vVector ) const;
00033 Vector3D& operator-= ( const Vector3D& vVector );
00034 Vector3D operator-() const;
00035
00036
00037 float operator* ( const Vector3D& vVector ) const;
00038
00039
00040 Vector3D operator^ ( const Vector3D& vVector2 ) const;
00041
00042
00043 Vector3D operator* ( const float num ) const;
00044 Vector3D& operator*= ( const float num );
00045 Vector3D operator/ ( float num ) const;
00046 Vector3D& operator/= ( const float num );
00047
00048 bool operator < ( const Vector3D& vVec ) const;
00049 bool operator > ( const Vector3D& vVec ) const;
00050 bool operator== ( const Vector3D& v1 ) const;
00051
00052 float operator [] ( const unsigned int i ) const;
00053 float& operator [] ( const unsigned int i );
00054
00055 void set ( float fx, float fy, float fz );
00056
00057 float x() const {
00058 return m_X;
00059 }
00060
00061 float y() const {
00062 return m_Y;
00063 }
00064
00065 float z() const {
00066 return m_Z;
00067 }
00068
00069 void lerp ( const Vector3D& v1, const Vector3D& v2, float f );
00070
00071 float magnitude() const;
00072
00073 std::string toString( int precision=3, std::string name="" );
00074
00075 private:
00076 float m_X, m_Y, m_Z;
00077 };
00078
00079 #include "vec3_inl.h"
00080
00081
00082 #endif