00001 #ifndef X3DTK_SFPOINT2F_H 00002 #define X3DTK_SFPOINT2F_H 00003 00004 #include "SFVec2f.h" 00005 00006 #include <math.h> 00007 #include <iostream> 00008 00009 namespace X3DTK { 00010 00011 class SFString; 00012 00021 class SFPoint2f 00022 { 00023 public: 00025 float x; 00027 float y; 00028 00030 SFPoint2f(); 00032 SFPoint2f(float x, float y); 00034 SFPoint2f(const SFPoint2f &p); 00036 SFPoint2f &operator= (const SFPoint2f &v); 00038 SFPoint2f &operator+= (const SFVec2f &v); 00040 SFPoint2f &operator+= (const SFPoint2f &v); 00042 SFPoint2f &operator-= (const SFVec2f &v); 00044 explicit SFPoint2f(const SFString &s); 00045 // Conversion from vector to point. 00046 explicit SFPoint2f(const SFVec2f &V); 00048 inline float &operator[](int i) {return (&x)[i];}; 00050 inline const float &operator[](int i) const {return (&x)[i];}; 00051 00053 friend SFPoint2f operator+ (const SFPoint2f &v1, const SFVec2f &v2); 00055 friend SFPoint2f operator+ (const SFPoint2f &v1, const SFPoint2f &v2); 00057 friend SFPoint2f operator- (const SFPoint2f &v1, const SFVec2f &v2); 00059 friend SFVec2f operator- (const SFPoint2f &v1, const SFPoint2f &v2); 00061 friend SFPoint2f operator* (const float a, const SFPoint2f &v); 00063 friend float distance(const SFPoint2f &A, const SFPoint2f &B); 00065 inline float *f_data() {return &x;}; 00067 inline const float *f_data() const {return &x;}; 00069 inline operator float *() {return &x;}; 00071 inline operator const float *() const {return &x;}; 00073 static const SFPoint2f null; 00074 }; 00075 00076 } 00077 00078 #endif