SFVec2f.h

Go to the documentation of this file.
00001 #ifndef X3DTK_SFVEC2F_H
00002 #define X3DTK_SFVEC2F_H
00003 
00004 #include "Platform.h"
00005 
00006 #include <math.h>
00007 #include <iostream>
00008 
00009 namespace X3DTK {
00010 
00011 class SFString;
00012 class SFPoint2f;
00013 
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);
00047   inline float &operator[](int i) {return (&x)[i];};
00049   inline const float &operator[](int i) const {return (&x)[i];};
00050   
00052   friend bool operator== (const SFVec2f &v1, const SFVec2f &v2);
00054   friend bool operator!= (const SFVec2f &v1, const SFVec2f &v2);
00056   friend SFVec2f operator+ (const SFVec2f &v1, const SFVec2f &v2);
00058   friend SFVec2f operator- (const SFVec2f &v1, const SFVec2f &v2);
00060   friend SFVec2f operator- (const SFVec2f &v);
00062   friend float operator* (const SFVec2f &v1, const SFVec2f &v2);
00064   friend SFVec2f operator* (const float a, const SFVec2f &v);
00066   float norm() const;
00068   SFVec2f normalize();
00070   SFVec2f normalized() const;
00072   inline float *f_data() {return &x;};
00074   inline const float *f_data() const {return &x;};
00076   inline operator float *() {return &x;};
00078   inline operator const float *() const {return &x;};
00080   SFString toSFString() const;
00081   
00083   static const SFVec2f null;
00084 };
00085 
00086 }
00087 
00088 #endif

Generated on Fri Aug 27 13:16:22 2004 for X3DToolKit by doxygen 1.3.6