AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ParallelogramBoundary Class Reference

#include "AreaBoundary.h"

Inheritance diagram for ParallelogramBoundary:
AreaBoundary

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)
 
virtual bool IsWithinBoundaryArea (Position const *pos) const =0
 

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
 

Detailed Description

Constructor & Destructor Documentation

◆ ParallelogramBoundary()

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

Member Function Documentation

◆ IsWithinBoundaryArea()

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

Implements AreaBoundary.

77{
78 // half-plane signs
79 bool sign1 = ((-_b.GetDoublePositionX() + pos->GetPositionX()) * _aby - (-_b.GetDoublePositionY() + pos->GetPositionY()) * _abx) < 0;
80 bool sign2 = ((-_a.GetDoublePositionX() + pos->GetPositionX()) * _day - (-_a.GetDoublePositionY() + pos->GetPositionY()) * _dax) < 0;
81 bool sign3 = ((-_d.GetDoublePositionY() + pos->GetPositionY()) * _abx - (-_d.GetDoublePositionX() + pos->GetPositionX()) * _aby) < 0; // AB = -CD
82 bool sign4 = ((-_c.GetDoublePositionY() + pos->GetPositionY()) * _dax - (-_c.GetDoublePositionX() + pos->GetPositionX()) * _day) < 0; // DA = -BC
83
84 // if all signs are equal, the point is inside
85 return ((sign1 == sign2) && (sign2 == sign3) && (sign3 == sign4));
86}

References _a, _abx, _aby, _b, _c, _d, _dax, _day, AreaBoundary::DoublePosition::GetDoublePositionX(), AreaBoundary::DoublePosition::GetDoublePositionY(), Position::GetPositionX(), and Position::GetPositionY().

Member Data Documentation

◆ _a

DoublePosition const ParallelogramBoundary::_a
private

Referenced by IsWithinBoundaryArea().

◆ _abx

double const ParallelogramBoundary::_abx
private

Referenced by IsWithinBoundaryArea().

◆ _aby

double const ParallelogramBoundary::_aby
private

Referenced by IsWithinBoundaryArea().

◆ _b

DoublePosition const ParallelogramBoundary::_b
private

Referenced by IsWithinBoundaryArea().

◆ _c

DoublePosition const ParallelogramBoundary::_c
private

Referenced by IsWithinBoundaryArea().

◆ _d

DoublePosition const ParallelogramBoundary::_d
private

Referenced by IsWithinBoundaryArea().

◆ _dax

double const ParallelogramBoundary::_dax
private

Referenced by IsWithinBoundaryArea().

◆ _day

double const ParallelogramBoundary::_day
private

Referenced by IsWithinBoundaryArea().