00001 00002 // SFVec2f.h // 00004 00005 #ifndef VECTOR2F_H 00006 #define VECTOR2F_H 00007 00008 #include "Platform.h" 00009 00010 #include <math.h> 00011 #include <iostream> 00012 00013 namespace X3DTK { 00014 00015 class SFString; 00016 //class SFPoint2f; 00017 00021 00022 class SFVec2f 00023 { 00024 public: 00026 float x; 00028 float y; 00029 00031 SFVec2f(); 00033 SFVec2f(float x, float y); 00035 SFVec2f(const SFVec2f &v); 00037 SFVec2f &operator= (const SFVec2f &v); 00039 SFVec2f &operator+= (const SFVec2f &v); 00041 SFVec2f &operator-= (const SFVec2f &v); 00043 explicit SFVec2f(const SFString &s); 00045 //explicit SFVec2f(const SFPoint2f &P); 00046 00048 friend bool operator== (const SFVec2f &v1, const SFVec2f &v2); 00050 friend bool operator!= (const SFVec2f &v1, const SFVec2f &v2); 00052 friend SFVec2f operator+ (const SFVec2f &v1, const SFVec2f &v2); 00054 friend SFVec2f operator- (const SFVec2f &v1, const SFVec2f &v2); 00056 friend float operator* (const SFVec2f &v1, const SFVec2f &v2); 00058 friend SFVec2f operator* (const float a, const SFVec2f &v); 00060 float norm() const; 00062 SFVec2f normalize(); 00064 SFVec2f normalized() const; 00066 inline float *f_data() {return &x;}; 00068 inline const float *f_data() const {return &x;}; 00070 static const SFVec2f null; 00071 }; 00072 00073 } 00074 00075 #endif