Generated vec3

//generated on Mon Oct 31 22:02:37 2016

#ifndef VEC3_H
#define VEC3_H





//============================
// vec3
//============================
template <typename T>
struct vec3
 {
      inline vec3();
      inline explicit vec3(const T &xyz);
      inline explicit vec3(const T *begin);
      inline vec3(const T &xv, const T &yv, const T &zv);
      inline vec3(const vec3<T> &that);
      inline vec3(const T (&xy)[2], const T &z);
      inline vec3(const T (&that)[3]);


      inline T &x();
      inline const T &x() const;
      inline void setX(const T &x);
      inline T &y();
      inline const T &y() const;
      inline void setY(const T &y);
      inline T &z();
      inline const T &z() const;
      inline void setZ(const T &z);

      inline unsigned int count() const;
      inline T &operator[](unsigned int i);
      inline const T &operator[](unsigned int i) const;

      inline T *begin();
      inline const T *begin() const;
      inline T *end();
      inline const T *end() const;

      inline vec3<T> &operator++();
      inline vec3<T> operator++(int);
      inline vec3<T> &operator--();
      inline vec3<T> operator--(int);


      inline vec3<T> &operator=(const vec3<T> &xyz);
      inline vec3<T> operator+(const vec3<T> &xyz) const;
      inline vec3<T> &operator+=(const vec3<T> &xyz);
      inline vec3<T> operator-(const vec3<T> &xyz) const;
      inline vec3<T> &operator-=(const vec3<T> &xyz);
      inline vec3<T> operator*(const vec3<T> &xyz) const;
      inline vec3<T> &operator*=(const vec3<T> &xyz);
      inline vec3<T> operator/(const vec3<T> &xyz) const;
      inline vec3<T> &operator/=(const vec3<T> &xyz);
      inline vec3<T> operator%(const vec3<T> &xyz) const;
      inline vec3<T> &operator%=(const vec3<T> &xyz);
      inline bool operator<(const vec3<T> &xyz) const;
      inline bool operator<=(const vec3<T> &xyz) const;
      inline bool operator>(const vec3<T> &xyz) const;
      inline bool operator>=(const vec3<T> &xyz) const;
      inline bool operator==(const vec3<T> &xyz) const;
      inline bool operator!=(const vec3<T> &xyz) const;
      inline vec3<T> operator<<(const vec3<T> &xyz) const;
      inline vec3<T> &operator<<=(const vec3<T> &xyz);
      inline vec3<T> operator>>(const vec3<T> &xyz) const;
      inline vec3<T> &operator>>=(const vec3<T> &xyz);
      inline vec3<T> operator|(const vec3<T> &xyz) const;
      inline vec3<T> &operator|=(const vec3<T> &xyz);
      inline vec3<T> operator^(const vec3<T> &xyz) const;
      inline vec3<T> &operator^=(const vec3<T> &xyz);
      inline vec3<T> operator&(const vec3<T> &xyz) const;
      inline vec3<T> operator&=(const vec3<T> &xyz) const;
      inline bool operator||(const vec3<T> &xyz) const;


      inline vec3<T> operator*(const T &xyz) const;
      inline vec3<T> &operator*=(const T &xyz);
      inline vec3<T> operator/(const T &xyz) const;
      inline vec3<T> &operator/=(const T &xyz);
      inline vec3<T> operator%(const T &xyz) const;
      inline vec3<T> &operator%=(const T &xyz);

      inline vec3<T> operator-() const;
      inline vec3<T> operator+() const;
      inline bool operator!() const;


      inline T (&xy)[2]();
      inline const T (&xy)[2]() const;
      inline void setXY(const T (&them)[2]);
      inline T (&xyz)[3]();
      inline const T (&xyz)[3]() const;
      inline void setXYZ(const T (&them)[3]);
      inline T (&array)[3]();
      inline const T (&array)[3]() const;
      inline operator T (&)[3]();
      inline operator const T (&)[3]() const;

      template <typename T1>
      inline vec3<T1> to();


   private:
      T xv;
      T yv;
      T zv;
 };


















template <typename T>
T &vec3<T>::x()
   { return xv; }

template <typename T>
const T &vec3<T>::x() const
   { return xv; }

template <typename T>
void vec3<T>::setX(const T &x)
   { xv=x; }

template <typename T>
T &vec3<T>::y()
   { return yv; }

template <typename T>
const T &vec3<T>::y() const
   { return yv; }

template <typename T>
void vec3<T>::setY(const T &y)
   { yv=y; }

template <typename T>
T &vec3<T>::z()
   { return zv; }

template <typename T>
const T &vec3<T>::z() const
   { return zv; }

template <typename T>
void vec3<T>::setZ(const T &z)
   { zv=z; }

template <typename T>
vec3<T>::vec3()
 :xv(0),
  yv(0),
  zv(0)
   {
   }

template <typename T>
vec3<T>::vec3(const T &xyz)
 :xv(xyz),
  yv(xyz),
  zv(xyz)
   {
   }

template <typename T>
vec3<T>::vec3(const T *begin)
 :xv(begin[0]),
  yv(begin[1]),
  zv(begin[2])
   {
   }

template <typename T>
vec3<T>::vec3(const T &xv, const T &yv, const T &zv)
 :xv(xv),
  yv(yv),
  zv(zv)
   {
   }

template <typename T>
vec3<T>::vec3(const vec3<T> &that)
 :xv(that.xv),
  yv(that.yv),
  zv(that.zv)
   {
   }

template <typename T>
T *vec3<T>::begin()
   { return &xv; }

template <typename T>
const T *vec3<T>::begin() const
   { return &xv; }

template <typename T>
unsigned int vec3<T>::count() const
   { return 3; }

template <typename T>
T *vec3<T>::end()
   { return begin()+count(); }

template <typename T>
const T *vec3<T>::end() const
   { return begin()+count(); }

template <typename T>
T &vec3<T>::operator[](unsigned int i)
   {
      J_ASSERT(i<count(), "Index out of range!");
      return *(begin()+i);
   }

template <typename T>
const T &vec3<T>::operator[](unsigned int i) const
   {
      J_ASSERT(i<count(), "Index out of range!");
      return *(begin()+i);
   }

template <typename T>
vec3<T> &vec3<T>::operator++()
   {
      ++xv;
      ++yv;
      ++zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator++(int)
   { return vec3<T>(xv++, yv++, zv++); }

template <typename T>
vec3<T> &vec3<T>::operator--()
   {
      --xv;
      --yv;
      --zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator--(int)
   { return vec3<T>(xv--, yv--, zv--); }

template <typename T>
vec3<T> &vec3<T>::operator=(const vec3<T> &xyz)
   {
      xv=xyz.xv;
      yv=xyz.yv;
      zv=xyz.zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator+(const vec3<T> &xyz) const
   { return vec3<T>(xv+xyz.xv, yv+xyz.yv, zv+xyz.zv); }

template <typename T>
vec3<T> &vec3<T>::operator+=(const vec3<T> &xyz)
   {
      xv+=xyz.xv;
      yv+=xyz.yv;
      zv+=xyz.zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator-(const vec3<T> &xyz) const
   { return vec3<T>(xv-xyz.xv, yv-xyz.yv, zv-xyz.zv); }

template <typename T>
vec3<T> &vec3<T>::operator-=(const vec3<T> &xyz)
   {
      xv-=xyz.xv;
      yv-=xyz.yv;
      zv-=xyz.zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator*(const vec3<T> &xyz) const
   { return vec3<T>(xv*xyz.xv, yv*xyz.yv, zv*xyz.zv); }

template <typename T>
vec3<T> &vec3<T>::operator*=(const vec3<T> &xyz)
   {
      xv*=xyz.xv;
      yv*=xyz.yv;
      zv*=xyz.zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator/(const vec3<T> &xyz) const
   { return vec3<T>(xv/xyz.xv, yv/xyz.yv, zv/xyz.zv); }

template <typename T>
vec3<T> &vec3<T>::operator/=(const vec3<T> &xyz)
   {
      xv/=xyz.xv;
      yv/=xyz.yv;
      zv/=xyz.zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator%(const vec3<T> &xyz) const
   { return vec3<T>(xv%xyz.xv, yv%xyz.yv, zv%xyz.zv); }

template <typename T>
vec3<T> &vec3<T>::operator%=(const vec3<T> &xyz)
   {
      xv%=xyz.xv;
      yv%=xyz.yv;
      zv%=xyz.zv;
      return *this;
   }

template <typename T>
bool vec3<T>::operator<(const vec3<T> &xyz) const
   { return (xv<xyz.xv) && (yv<xyz.yv) && (zv<xyz.zv); }

template <typename T>
bool vec3<T>::operator<=(const vec3<T> &xyz) const
   { return (xv<=xyz.xv) && (yv<=xyz.yv) && (zv<=xyz.zv); }

template <typename T>
bool vec3<T>::operator>(const vec3<T> &xyz) const
   { return (xv>xyz.xv) && (yv>xyz.yv) && (zv>xyz.zv); }

template <typename T>
bool vec3<T>::operator>=(const vec3<T> &xyz) const
   { return (xv>=xyz.xv) && (yv>=xyz.yv) && (zv>=xyz.zv); }

template <typename T>
bool vec3<T>::operator==(const vec3<T> &xyz) const
   { return (xv==xyz.xv) && (yv==xyz.yv) && (zv==xyz.zv); }

template <typename T>
bool vec3<T>::operator!=(const vec3<T> &xyz) const
   { return (xv!=xyz.xv) || (yv!=xyz.yv) || (zv!=xyz.zv); }

template <typename T>
vec3<T> vec3<T>::operator<<(const vec3<T> &xyz) const
   { return vec3<T>(xv<<xyz.xv, yv<<xyz.yv, zv<<xyz.zv); }

template <typename T>
vec3<T> &vec3<T>::operator<<=(const vec3<T> &xyz)
   {
      xv<<=xyz.xv;
      yv<<=xyz.yv;
      zv<<=xyz.zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator>>(const vec3<T> &xyz) const
   { return vec3<T>(xv>>xyz.xv, yv>>xyz.yv, zv>>xyz.zv); }

template <typename T>
vec3<T> &vec3<T>::operator>>=(const vec3<T> &xyz)
   {
      xv>>=xyz.xv;
      yv>>=xyz.yv;
      zv>>=xyz.zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator|(const vec3<T> &xyz) const
   { return vec3<T>(xv|xyz.xv, yv|xyz.yv, zv|xyz.zv); }

template <typename T>
vec3<T> &vec3<T>::operator|=(const vec3<T> &xyz)
   {
      xv|=xyz.xv;
      yv|=xyz.yv;
      zv|=xyz.zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator^(const vec3<T> &xyz) const
   { return vec3<T>(xv^xyz.xv, yv^xyz.yv, zv^xyz.zv); }

template <typename T>
vec3<T> &vec3<T>::operator^=(const vec3<T> &xyz)
   {
      xv^=xyz.xv;
      yv^=xyz.yv;
      zv^=xyz.zv;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator&(const vec3<T> &xyz) const
   { return vec3<T>(xv&xyz.xv, yv&xyz.yv, zv&xyz.zv); }

template <typename T>
vec3<T> vec3<T>::operator&=(const vec3<T> &xyz) const
   { return vec3<T>(xv&=xyz.xv, yv&=xyz.yv, zv&=xyz.zv); }

template <typename T>
bool vec3<T>::operator||(const vec3<T> &xyz) const
   { return (xv||xyz.xv) || (yv||xyz.yv) || (zv||xyz.zv); }

template <typename T>
vec3<T> vec3<T>::operator*(const T &xyz) const
   { return vec3<T>(xv*xyz, yv*xyz, zv*xyz); }

template <typename T>
vec3<T> &vec3<T>::operator*=(const T &xyz)
   {
      xv*=xyz;
      yv*=xyz;
      zv*=xyz;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator/(const T &xyz) const
   { return vec3<T>(xv/xyz, yv/xyz, zv/xyz); }

template <typename T>
vec3<T> &vec3<T>::operator/=(const T &xyz)
   {
      xv/=xyz;
      yv/=xyz;
      zv/=xyz;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator%(const T &xyz) const
   { return vec3<T>(xv%xyz, yv%xyz, zv%xyz); }

template <typename T>
vec3<T> &vec3<T>::operator%=(const T &xyz)
   {
      xv%=xyz;
      yv%=xyz;
      zv%=xyz;
      return *this;
   }

template <typename T>
vec3<T> vec3<T>::operator-() const
   { return vec3<T>(-xv, -yv, -zv); }

template <typename T>
vec3<T> vec3<T>::operator+() const
   { return vec3<T>(+xv, +yv, +zv); }

template <typename T>
bool vec3<T>::operator!() const
   { return (!xv) && (!yv) && (!zv); }

template <typename T>
T (&vec3<T>::xy)[2]()
   { return *reinterpret_cast<T (*)[2]>(begin()); }

template <typename T>
const T (&vec3<T>::xy)[2]() const
   { return *reinterpret_cast<const T (*)[2]>(begin()); }

template <typename T>
void vec3<T>::setXY(const T (&them)[2])
   { memcpy(xy(), them, sizeof(T[2])); }

template <typename T>
vec3<T>::vec3(const T (&xy)[2], const T &z)
 :vec3(xy[0], xy[1], z)
   {
   }

template <typename T>
T (&vec3<T>::xyz)[3]()
   { return *reinterpret_cast<T (*)[3]>(begin()); }

template <typename T>
const T (&vec3<T>::xyz)[3]() const
   { return *reinterpret_cast<const T (*)[3]>(begin()); }

template <typename T>
void vec3<T>::setXYZ(const T (&them)[3])
   { memcpy(xyz(), them, sizeof(T[3])); }

template <typename T>
T (&vec3<T>::array)[3]()
   { return *reinterpret_cast<T (*)[3]>(begin()); }

template <typename T>
const T (&vec3<T>::array)[3]() const
   { return *reinterpret_cast<const T (*)[3]>(begin()); }

template <typename T>
vec3<T>::operator T (&)[3]()
   { return array(); }

template <typename T>
vec3<T>::operator const T (&)[3]() const
   { return array(); }

template <typename T, typename T1>
vec3<T1> vec3<T>::to()
   { return vec3<T1>(static_cast<T1>(xv), static_cast<T1>(yv), static_cast<T1>(zv)); }

template <typename T>
vec3<T>::vec3(const T (&that)[3])
 :xv(that[0]),
  yv(that[1]),
  zv(that[2])
   {
   }

#endif  // VEC3_H

//this header was generated in 7 milliseconds

No comments:

Post a Comment

Pages