18 #ifndef Trinity_game_Position_h__
19 #define Trinity_game_Position_h__
30 : m_positionX(
x), m_positionY(
y), m_positionZ(
z), m_orientation(NormalizeOrientation(o)) { }
69 m_positionX =
x; m_positionY =
y;
74 m_positionX =
x; m_positionY =
y; m_positionZ =
z;
79 m_positionX =
x; m_positionY =
y; m_positionZ =
z; SetOrientation(orientation);
94 m_positionX = pos.
x; m_positionY = pos.
y; m_positionZ = pos.
z;
97 void RelocateOffset(
Position const &offset);
101 m_orientation = NormalizeOrientation(orientation);
111 x = m_positionX; y = m_positionY;
116 x = m_positionX; y = m_positionY; z = m_positionZ;
121 x = m_positionX; y = m_positionY; z = m_positionZ; o = m_orientation;
130 bool IsPositionValid()
const;
134 float dx = m_positionX -
x;
float dy = m_positionY -
y;
return dx*dx + dy*dy;
139 return std::sqrt(GetExactDist2dSq(x, y));
144 float dx = m_positionX - pos->
m_positionX;
float dy = m_positionY - pos->
m_positionY;
return dx*dx + dy*dy;
149 return std::sqrt(GetExactDist2dSq(pos));
154 float dz = m_positionZ -
z;
return GetExactDist2dSq(x, y) + dz*dz;
159 return std::sqrt(GetExactDistSq(x, y, z));
169 return std::sqrt(GetExactDistSq(pos));
172 void GetPositionOffsetTo(
Position const & endPos,
Position & retOffset)
const;
175 float GetAngle(
Position const* pos)
const;
176 float GetAngle(
float x,
float y)
const;
179 return GetAngle(pos) - m_orientation;
183 void GetSinCos(
float x,
float y,
float &vsin,
float &vcos)
const;
187 return GetExactDist2dSq(x, y) < dist * dist;
192 return GetExactDist2dSq(pos) < dist * dist;
197 return GetExactDistSq(x, y, z) < dist * dist;
202 return GetExactDistSq(pos) < dist * dist;
205 bool IsWithinBox(
const Position& center,
float xradius,
float yradius,
float zradius)
const;
206 bool HasInArc(
float arcangle,
Position const* pos,
float border = 2.0f)
const;
207 bool HasInLine(
Position const* pos,
float width)
const;
218 mod = std::fmod(mod, 2.0f * static_cast<float>(
M_PI));
219 mod = -mod + 2.0f *
static_cast<float>(
M_PI);
222 return std::fmod(o, 2.0f * static_cast<float>(
M_PI));
226 #define MAPID_INVALID 0xFFFFFFFF
235 :
Position(loc), m_mapId(loc.GetMapId()) { }
266 #endif // Trinity_game_Position_h__
float x
Definition: Vector3.h:62
TC_GAME_API ByteBuffer & operator<<(ByteBuffer &buf, Position::PositionXYStreamer const &streamer)
Definition: Position.cpp:167
Definition: Position.h:228
PositionXYZOStreamer(Position &pos)
Definition: Position.h:48
Definition: ByteBuffer.h:70
Position::PositionXYZOStreamer PositionXYZOStream()
Definition: Position.h:128
float GetExactDist(Position const *pos) const
Definition: Position.h:167
Position::PositionXYStreamer PositionXYStream()
Definition: Position.h:126
float GetExactDist2dSq(float x, float y) const
Definition: Position.h:132
#define M_PI
Definition: Common.h:163
float m_positionY
Definition: Position.h:53
void GetPosition(float &x, float &y, float &z) const
Definition: Position.h:114
void SetOrientation(float orientation)
Definition: Position.h:99
Position * Pos
Definition: Position.h:43
float m_positionX
Definition: Position.h:52
static float NormalizeOrientation(float o)
Definition: Position.h:211
Position * Pos
Definition: Position.h:49
Position::PositionXYZStreamer PositionXYZStream()
Definition: Position.h:127
float y
Definition: Vector3.h:62
void Relocate(float x, float y, float z)
Definition: Position.h:72
bool IsInDist2d(Position const *pos, float dist) const
Definition: Position.h:190
uint32 m_mapId
Definition: Position.h:256
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:137
float GetExactDist2d(Position const *pos) const
Definition: Position.h:147
float GetOrientation() const
Definition: Position.h:107
void Relocate(float x, float y)
Definition: Position.h:67
WorldLocation GetWorldLocation() const
Definition: Position.h:249
WorldLocation(uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
Definition: Position.h:231
string ToString(int i)
Definition: strutil.h:491
float GetRelativeAngle(float x, float y) const
Definition: Position.h:182
Definition: Position.h:46
Definition: Position.h:40
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
void GetPosition(float &x, float &y) const
Definition: Position.h:109
Position(float x=0, float y=0, float z=0, float o=0)
Definition: Position.h:29
float GetExactDistSq(float x, float y, float z) const
Definition: Position.h:152
PositionXYStreamer(Position &pos)
Definition: Position.h:36
float GetPositionZ() const
Definition: Position.h:106
bool operator==(const CoordPair< LIMIT > &p1, const CoordPair< LIMIT > &p2)
Definition: GridDefines.h:160
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
float GetRelativeAngle(Position const *pos) const
Definition: Position.h:177
uint32 GetMapId() const
Definition: Position.h:254
float m_positionZ
Definition: Position.h:54
Position GetPosition() const
Definition: Position.h:124
void Relocate(Position const *pos)
Definition: Position.h:87
float GetExactDist2dSq(Position const *pos) const
Definition: Position.h:142
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:185
Position * Pos
Definition: Position.h:37
void WorldRelocate(uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
Definition: Position.h:243
float z
Definition: Vector3.h:62
bool IsInDist(Position const *pos, float dist) const
Definition: Position.h:200
Position(Position const &loc)
Definition: Position.h:32
#define TC_GAME_API
Definition: Define.h:134
float GetExactDist(float x, float y, float z) const
Definition: Position.h:157
Definition: Position.h:27
#define MAPID_INVALID
Definition: Position.h:226
TC_GAME_API ByteBuffer & operator>>(ByteBuffer &buf, Position::PositionXYStreamer const &streamer)
Definition: Position.cpp:174
void Relocate(G3D::Vector3 const &pos)
Definition: Position.h:92
void Relocate(Position const &pos)
Definition: Position.h:82
G3D::int16 x
Definition: Vector2int16.h:37
void GetPosition(float &x, float &y, float &z, float &o) const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:104
void Relocate(float x, float y, float z, float orientation)
Definition: Position.h:77
Pos
Definition: boss_gothik.cpp:115
PositionXYZStreamer(Position &pos)
Definition: Position.h:42
Definition: Position.h:34
void WorldRelocate(WorldLocation const &loc)
Definition: Position.h:237
WorldLocation(WorldLocation const &loc)
Definition: Position.h:234
float m_orientation
Definition: Position.h:57
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:195
float GetExactDistSq(Position const *pos) const
Definition: Position.h:162
bool operator!=(Position const &a)
Definition: Position.h:62