00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GEOM_VEC2_H
00020 #define GEOM_VEC2_H
00021
00022 #include <cstddef>
00023 #include <ostream>
00024
00025 #include <boost/operators.hpp>
00026
00027 #include <ost/geom/module_config.hh>
00028 #include <ost/config.hh>
00029
00030 namespace geom {
00031
00032
00033 class Vec3;
00034 class Vec4;
00035
00036
00037
00038
00039 class DLLEXPORT_OST_GEOM Vec2:
00040 private boost::equality_comparable<Vec2>,
00041 private boost::additive<Vec2>,
00042 private boost::additive<Vec2, Real>,
00043 private boost::multiplicative<Vec2, Real>
00044 {
00045 public:
00047 Vec2();
00048
00050 Vec2(Real x, Real y);
00051
00053 Vec2(const Vec2& v);
00054
00056 explicit Vec2(const Vec3& v);
00057
00059 explicit Vec2(const Vec4& v);
00060
00062 explicit Vec2(const Real[2]);
00063
00064 #if OST_DOUBLE_PRECISION
00066 explicit Vec2(const float[2]);
00067 #endif
00069 Vec2& operator=(const Vec2& v);
00070
00072 Real& operator[](std::size_t indx);
00074 const Real& operator[](std::size_t indx) const;
00076 Real GetX() const;
00077 Real GetY() const;
00078 void SetX(Real v);
00079 void SetY(Real v);
00080
00082 bool operator==(const Vec2& rhs) const;
00083
00085 Vec2& operator+=(const Vec2& rhs);
00086 Vec2& operator+=(Real d);
00088 Vec2& operator-=(const Vec2& rhs);
00089 Vec2& operator-=(Real d);
00091 Vec2 operator-() const;
00093 Vec2& operator*=(Real d);
00095 Vec2& operator/=(Real d);
00096
00097 Real* Data() {return data_;}
00098 const Real* Data() const {return data_;}
00099
00100 private:
00101 Real data_[2];
00102
00103 void set(Real x, Real y);
00104 };
00105
00106 DLLEXPORT_OST_GEOM Vec2 operator/(Real d, const Vec2& v);
00107
00108 DLLEXPORT_OST_GEOM std::ostream& operator<<(std::ostream&, const Vec2&);
00109
00110 }
00111
00112 # endif