00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GEOM_VEC3_H
00020 #define GEOM_VEC3_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 Vec2;
00034 class Vec4;
00035
00036
00038 class DLLEXPORT_OST_GEOM Vec3:
00039 private boost::equality_comparable<Vec3>,
00040 private boost::additive<Vec3>,
00041 private boost::additive<Vec3, Real>,
00042 private boost::multiplicative<Vec3, Real>
00043 {
00044 public:
00046 Vec3();
00047
00049 Vec3(Real x, Real y, Real z);
00050
00052 Vec3(const Vec3& v);
00053
00055 Vec3(const Vec2& v);
00056
00058
00062 explicit Vec3(const Vec4& v);
00063
00065 explicit Vec3(const Real[3]);
00066
00067 #if OST_DOUBLE_PRECISION
00069 explicit Vec3(const float[3]);
00070 #endif
00072 Vec3& operator=(const Vec3& v);
00073
00075 bool operator==(const Vec3& rhs) const;
00076
00078 Real& operator[](std::size_t indx);
00080 const Real& operator[](std::size_t indx) const;
00082 Real GetX() const;
00083 Real GetY() const;
00084 Real GetZ() const;
00085 void SetX(Real v);
00086 void SetY(Real v);
00087 void SetZ(Real v);
00088
00090 Vec3& operator+=(const Vec3& rhs);
00091 Vec3& operator+=(Real d);
00093 Vec3& operator-=(const Vec3& rhs);
00094 Vec3& operator-=(Real d);
00096 Vec3 operator-() const;
00098 Vec3& operator*=(Real d);
00100 Vec3& operator/=(Real d);
00101
00102 Real* Data() {return data_;}
00103 const Real* Data() const {return data_;}
00104
00105 private:
00106 Real data_[3];
00107
00108 void set(Real x, Real y, Real z);
00109 };
00110
00111 DLLEXPORT_OST_GEOM Vec3 operator/(Real, const Vec3& v);
00112
00113 DLLEXPORT_OST_GEOM std::ostream& operator<<(std::ostream&, const Vec3&);
00114
00115 }
00116
00117
00118 # endif