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

#include "AreaBoundary.h"

Inheritance diagram for TriangleBoundary:
AreaBoundary

Public Member Functions

 TriangleBoundary (Position const &pointA, Position const &pointB, Position const &pointC, 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 _c
 
double const _abx
 
double const _bcx
 
double const _cax
 
double const _aby
 
double const _bcy
 
double const _cay
 

Detailed Description

Constructor & Destructor Documentation

◆ TriangleBoundary()

TriangleBoundary::TriangleBoundary ( Position const &  pointA,
Position const &  pointB,
Position const &  pointC,
bool  isInverted = false 
)
60 :
Definition: AreaBoundary.h:24
double GetDoublePositionY() const
Definition: AreaBoundary.h:46
double GetDoublePositionX() const
Definition: AreaBoundary.h:45
double const _bcx
Definition: AreaBoundary.h:125
DoublePosition const _a
Definition: AreaBoundary.h:124
double const _abx
Definition: AreaBoundary.h:125
double const _aby
Definition: AreaBoundary.h:125
double const _cax
Definition: AreaBoundary.h:125
DoublePosition const _c
Definition: AreaBoundary.h:124
DoublePosition const _b
Definition: AreaBoundary.h:124
double const _cay
Definition: AreaBoundary.h:125
double const _bcy
Definition: AreaBoundary.h:125

Member Function Documentation

◆ IsWithinBoundaryArea()

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

Implements AreaBoundary.

63{
64 // half-plane signs
65 bool sign1 = ((-_b.GetDoublePositionX() + pos->GetPositionX()) * _aby - (-_b.GetDoublePositionY() + pos->GetPositionY()) * _abx) < 0;
66 bool sign2 = ((-_c.GetDoublePositionX() + pos->GetPositionX()) * _bcy - (-_c.GetDoublePositionY() + pos->GetPositionY()) * _bcx) < 0;
67 bool sign3 = ((-_a.GetDoublePositionX() + pos->GetPositionX()) * _cay - (-_a.GetDoublePositionY() + pos->GetPositionY()) * _cax) < 0;
68
69 // if all signs are the same, the point is inside the triangle
70 return ((sign1 == sign2) && (sign2 == sign3));
71}

References _a, _abx, _aby, _b, _bcx, _bcy, _c, _cax, _cay, AreaBoundary::DoublePosition::GetDoublePositionX(), AreaBoundary::DoublePosition::GetDoublePositionY(), Position::GetPositionX(), and Position::GetPositionY().

Member Data Documentation

◆ _a

DoublePosition const TriangleBoundary::_a
private

Referenced by IsWithinBoundaryArea().

◆ _abx

double const TriangleBoundary::_abx
private

Referenced by IsWithinBoundaryArea().

◆ _aby

double const TriangleBoundary::_aby
private

Referenced by IsWithinBoundaryArea().

◆ _b

DoublePosition const TriangleBoundary::_b
private

Referenced by IsWithinBoundaryArea().

◆ _bcx

double const TriangleBoundary::_bcx
private

Referenced by IsWithinBoundaryArea().

◆ _bcy

double const TriangleBoundary::_bcy
private

Referenced by IsWithinBoundaryArea().

◆ _c

DoublePosition const TriangleBoundary::_c
private

Referenced by IsWithinBoundaryArea().

◆ _cax

double const TriangleBoundary::_cax
private

Referenced by IsWithinBoundaryArea().

◆ _cay

double const TriangleBoundary::_cay
private

Referenced by IsWithinBoundaryArea().