TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ParallelogramBoundary Class Reference

#include <AreaBoundary.h>

Public Member Functions

 ParallelogramBoundary (Position const &cornerA, Position const &cornerB, Position const &cornerD, bool isInverted=false)
 
 ParallelogramBoundary (DoublePosition const &cornerA, DoublePosition const &cornerB, DoublePosition const &cornerD, bool isInverted=false)
 
- Public Member Functions inherited from AreaBoundary
virtual ~AreaBoundary ()
 
BoundaryType GetBoundaryType () const
 
bool IsWithinBoundary (const Position *pos) const
 

Protected Member Functions

bool IsWithinBoundaryArea (const Position *pos) const override
 
- Protected Member Functions inherited from AreaBoundary
 AreaBoundary (BoundaryType bType, bool isInverted)
 

Private Attributes

const DoublePosition _a
 
const DoublePosition _b
 
const DoublePosition _d
 
const DoublePosition _c
 
const double _abx
 
const double _dax
 
const double _aby
 
const double _day
 

Additional Inherited Members

- Public Types inherited from AreaBoundary
enum  BoundaryType {
  BOUNDARY_RECTANGLE, BOUNDARY_CIRCLE, BOUNDARY_ELLIPSE, BOUNDARY_TRIANGLE,
  BOUNDARY_PARALLELOGRAM, BOUNDARY_Z_RANGE
}
 
- Protected Attributes inherited from AreaBoundary
const BoundaryType m_boundaryType
 
bool m_isInvertedBoundary
 

Constructor & Destructor Documentation

ParallelogramBoundary::ParallelogramBoundary ( Position const cornerA,
Position const cornerB,
Position const cornerD,
bool  isInverted = false 
)
95  :
96  ParallelogramBoundary(DoublePosition(cornerA), DoublePosition(cornerB), DoublePosition(cornerD), isInverted) { }
ParallelogramBoundary(Position const &cornerA, Position const &cornerB, Position const &cornerD, bool isInverted=false)
Definition: AreaBoundary.cpp:95
ParallelogramBoundary::ParallelogramBoundary ( DoublePosition const cornerA,
DoublePosition const cornerB,
DoublePosition const cornerD,
bool  isInverted = false 
)
97  :
double GetDoublePositionX() const
Definition: AreaBoundary.h:49
const double _dax
Definition: AreaBoundary.h:138
const DoublePosition _d
Definition: AreaBoundary.h:137
double GetDoublePositionY() const
Definition: AreaBoundary.h:50
const double _aby
Definition: AreaBoundary.h:138
const double _abx
Definition: AreaBoundary.h:138
const DoublePosition _a
Definition: AreaBoundary.h:137
const double _day
Definition: AreaBoundary.h:138
const DoublePosition _c
Definition: AreaBoundary.h:137
const DoublePosition _b
Definition: AreaBoundary.h:137
AreaBoundary(BoundaryType bType, bool isInverted)
Definition: AreaBoundary.h:63

Member Function Documentation

bool ParallelogramBoundary::IsWithinBoundaryArea ( const Position pos) const
overrideprotectedvirtual

Implements AreaBoundary.

100 {
101  if (!pos)
102  return false;
103 
104  // half-plane signs
105  bool sign1 = ((-_b.GetDoublePositionX() + pos->GetPositionX()) * _aby - (-_b.GetDoublePositionY() + pos->GetPositionY()) * _abx) < 0;
106  bool sign2 = ((-_a.GetDoublePositionX() + pos->GetPositionX()) * _day - (-_a.GetDoublePositionY() + pos->GetPositionY()) * _dax) < 0;
107  bool sign3 = ((-_d.GetDoublePositionY() + pos->GetPositionY()) * _abx - (-_d.GetDoublePositionX() + pos->GetPositionX()) * _aby) < 0; // AB = -CD
108  bool sign4 = ((-_c.GetDoublePositionY() + pos->GetPositionY()) * _dax - (-_c.GetDoublePositionX() + pos->GetPositionX()) * _day) < 0; // DA = -BC
109 
110  // if all signs are equal, the point is inside
111  return ((sign1 == sign2) && (sign2 == sign3) && (sign3 == sign4));
112 }
double GetDoublePositionX() const
Definition: AreaBoundary.h:49
const double _dax
Definition: AreaBoundary.h:138
const DoublePosition _d
Definition: AreaBoundary.h:137
float GetPositionY() const
Definition: Position.h:105
double GetDoublePositionY() const
Definition: AreaBoundary.h:50
const double _aby
Definition: AreaBoundary.h:138
const double _abx
Definition: AreaBoundary.h:138
const DoublePosition _a
Definition: AreaBoundary.h:137
const double _day
Definition: AreaBoundary.h:138
float GetPositionX() const
Definition: Position.h:104
const DoublePosition _c
Definition: AreaBoundary.h:137
const DoublePosition _b
Definition: AreaBoundary.h:137

+ Here is the call graph for this function:

Member Data Documentation

const DoublePosition ParallelogramBoundary::_a
private
const double ParallelogramBoundary::_abx
private
const double ParallelogramBoundary::_aby
private
const DoublePosition ParallelogramBoundary::_b
private
const DoublePosition ParallelogramBoundary::_c
private
const DoublePosition ParallelogramBoundary::_d
private
const double ParallelogramBoundary::_dax
private
const double ParallelogramBoundary::_day
private

The documentation for this class was generated from the following files: