TrinityCore
ParallelogramBoundary Class Reference

#include <AreaBoundary.h>

Public Member Functions

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

Protected Member Functions

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

Private Attributes

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

Constructor & Destructor Documentation

◆ ParallelogramBoundary()

ParallelogramBoundary::ParallelogramBoundary ( Position const &  cornerA,
Position const &  cornerB,
Position const &  cornerD,
bool  isInverted = false 
)
71  :
double GetDoublePositionX() const
Definition: AreaBoundary.h:45
DoublePosition const _a
Definition: AreaBoundary.h:137
DoublePosition const _c
Definition: AreaBoundary.h:137
double const _abx
Definition: AreaBoundary.h:138
AreaBoundary(bool isInverted)
Definition: AreaBoundary.h:32
DoublePosition const _b
Definition: AreaBoundary.h:137
double const _dax
Definition: AreaBoundary.h:138
double const _day
Definition: AreaBoundary.h:138
DoublePosition const _d
Definition: AreaBoundary.h:137
double const _aby
Definition: AreaBoundary.h:138
double GetDoublePositionY() const
Definition: AreaBoundary.h:46

Member Function Documentation

◆ IsWithinBoundaryArea()

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

Implements AreaBoundary.

74 {
75  // half-plane signs
76  bool sign1 = ((-_b.GetDoublePositionX() + pos->GetPositionX()) * _aby - (-_b.GetDoublePositionY() + pos->GetPositionY()) * _abx) < 0;
77  bool sign2 = ((-_a.GetDoublePositionX() + pos->GetPositionX()) * _day - (-_a.GetDoublePositionY() + pos->GetPositionY()) * _dax) < 0;
78  bool sign3 = ((-_d.GetDoublePositionY() + pos->GetPositionY()) * _abx - (-_d.GetDoublePositionX() + pos->GetPositionX()) * _aby) < 0; // AB = -CD
79  bool sign4 = ((-_c.GetDoublePositionY() + pos->GetPositionY()) * _dax - (-_c.GetDoublePositionX() + pos->GetPositionX()) * _day) < 0; // DA = -BC
80 
81  // if all signs are equal, the point is inside
82  return ((sign1 == sign2) && (sign2 == sign3) && (sign3 == sign4));
83 }
double GetDoublePositionX() const
Definition: AreaBoundary.h:45
DoublePosition const _a
Definition: AreaBoundary.h:137
DoublePosition const _c
Definition: AreaBoundary.h:137
double const _abx
Definition: AreaBoundary.h:138
DoublePosition const _b
Definition: AreaBoundary.h:137
double const _dax
Definition: AreaBoundary.h:138
double const _day
Definition: AreaBoundary.h:138
DoublePosition const _d
Definition: AreaBoundary.h:137
double const _aby
Definition: AreaBoundary.h:138
double GetDoublePositionY() const
Definition: AreaBoundary.h:46
+ Here is the call graph for this function:

Member Data Documentation

◆ _a

DoublePosition const ParallelogramBoundary::_a
private

◆ _abx

double const ParallelogramBoundary::_abx
private

◆ _aby

double const ParallelogramBoundary::_aby
private

◆ _b

DoublePosition const ParallelogramBoundary::_b
private

◆ _c

DoublePosition const ParallelogramBoundary::_c
private

◆ _d

DoublePosition const ParallelogramBoundary::_d
private

◆ _dax

double const ParallelogramBoundary::_dax
private

◆ _day

double const ParallelogramBoundary::_day
private

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