1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "ai_share/ai_vector.h"
25 #include "ai_vector_mirror.h"
30 //----------------------------------------------------------------------------
32 //----------------------------------------------------------------------------
34 /** This class is an extension of CAIVector with an added height and
35 orientation information.
37 This class as an additionnal sint32 h field and a CAngle theta field. The
38 height unit is 1 meter length (and thus there is no precision smaller than 1
39 meter), and the orientation (see CAngle) is on the horizontal XY plane.
46 CAIPos() : CAIVector(0., 0.), _h(0), _theta(0.f
) { }
47 CAIPos(CAIPos
const& pos
) : CAIVector(pos
), _h(pos
._h
), _theta(pos
._theta
) { }
49 explicit CAIPos(CAIVector
const& xy
, sint32 h
, float theta
) : CAIVector(xy
), _h(h
), _theta(theta
) { }
50 explicit CAIPos(CAIVector
const& xy
, sint32 h
, CAngle
const& theta
) : CAIVector(xy
), _h(h
), _theta(theta
) { }
52 CAIPos(CAIPosMirror
const& pos
);
53 explicit CAIPos(CAIVectorMirror
const& xy
, sint32 h
, float theta
);
54 explicit CAIPos(CAIVectorMirror
const& xy
, sint32 h
, CAngle
const& theta
);
56 explicit CAIPos(C x
, C y
, sint32 h
, float theta
) : CAIVector(x
, y
), _h(h
), _theta(theta
) { }
58 explicit CAIPos(C x
, C y
, sint32 h
, CAngle theta
) :CAIVector(x
, y
), _h(h
), _theta(theta
) { }
60 std::string
toString() const
62 return NLMISC::toString("(%9s,%9s,%d) %3d\"",x().toString().c_str(),y().toString().c_str(),h(),theta().asDegrees());
65 inline bool operator==(const CAIPos
&other
) const { return CAIVector::operator==(other
) && other
.h()==h(); }
66 inline bool operator!=(const CAIPos
&other
) const { return CAIVector::operator!=(other
) || other
.h()!=h(); }
67 inline bool operator==(const CAIPosMirror
&other
) const;
68 inline bool operator!=(const CAIPosMirror
&other
) const;
70 inline bool operator==(const CAIVectorMirror
&other
) const { return CAIVector::operator==(other
); }
71 inline bool operator!=(const CAIVectorMirror
&other
) const { return CAIVector::operator!=(other
); }
74 inline const CAIPos
&operator= (const CAIPos
&other
) { setX(other
.x()); setY(other
.y()); _h
=other
._h
; _theta
=other
._theta
; return *this; }
75 inline const CAIPos
&operator= (const CAIPosMirror
&other
); /* { setX(other.x()); setY(other.y()); _h=other.h(); _theta=other.theta(); return *this; }*/
77 template <class V
> inline const CAIPos
&operator+=(const V
&v
) { CAIVector::operator +=(v
); return *this; }
78 template <class V
> inline const CAIPos
&operator-=(const V
&v
) { CAIVector::operator -=(v
); return *this; }
80 template <class V
> inline const CAIPos
operator+(const V
&v
) const { CAIPos
p(*this); return p
+=v
; }
81 template <class V
> inline const CAIPos
operator-(const V
&v
) const { CAIPos
p(*this); return p
-=v
; }
83 inline const sint32
&h() const { return _h
; }
84 inline const CAngle
&theta() const { return _theta
; }
86 template <class C
> inline void setH(const C
&h
) { _h
=h
; }
87 template <class C
> inline void setTheta(const C
&theta
) { _theta
=theta
; }
94 //--------------------------------------------------------------------------
96 //--------------------------------------------------------------------------
98 #include "ai_pos_mirror.h"
101 inline const CAIPos
&CAIPos::operator= (const CAIPosMirror
&other
)
106 _theta
=other
.theta();
111 inline CAIPos::CAIPos(const CAIPosMirror
&pos
):
112 CAIVector(pos
.x(),pos
.y()), _h(pos
.h()), _theta(pos
.theta())
116 inline CAIPos::CAIPos(const CAIVectorMirror
&xy
, sint32 h
, float theta
):
117 CAIVector(xy
.x(),xy
.y()), _h(h
), _theta(theta
)
121 inline CAIPos::CAIPos(const CAIVectorMirror
&xy
, sint32 h
, const CAngle
&theta
):
122 CAIVector(xy
.x(),xy
.y()), _h(h
), _theta(theta
)
126 inline bool CAIPos::operator==(const CAIPosMirror
&other
) const
128 return (other
.x()==x()) && (other
.y()==y()) && other
.h()==h();
131 inline bool CAIPos::operator!=(const CAIPosMirror
&other
) const
133 return !(*this == other
);