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

#include <AreaBoundary.h>

Public Member Functions

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

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

TriangleBoundary::TriangleBoundary ( Position const pointA,
Position const pointB,
Position const pointC,
bool  isInverted = false 
)
75  :
76  TriangleBoundary(DoublePosition(pointA), DoublePosition(pointB), DoublePosition(pointC), isInverted) { }
TriangleBoundary(Position const &pointA, Position const &pointB, Position const &pointC, bool isInverted=false)
Definition: AreaBoundary.cpp:75
TriangleBoundary::TriangleBoundary ( DoublePosition const pointA,
DoublePosition const pointB,
DoublePosition const pointC,
bool  isInverted = false 
)
77  :
double GetDoublePositionX() const
Definition: AreaBoundary.h:49
const double _bcx
Definition: AreaBoundary.h:123
const DoublePosition _b
Definition: AreaBoundary.h:122
const double _bcy
Definition: AreaBoundary.h:123
const double _abx
Definition: AreaBoundary.h:123
const DoublePosition _c
Definition: AreaBoundary.h:122
double GetDoublePositionY() const
Definition: AreaBoundary.h:50
const double _cax
Definition: AreaBoundary.h:123
const double _aby
Definition: AreaBoundary.h:123
const double _cay
Definition: AreaBoundary.h:123
const DoublePosition _a
Definition: AreaBoundary.h:122
AreaBoundary(BoundaryType bType, bool isInverted)
Definition: AreaBoundary.h:63

Member Function Documentation

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

Implements AreaBoundary.

80 {
81  if (!pos)
82  return false;
83 
84  // half-plane signs
85  bool sign1 = ((-_b.GetDoublePositionX() + pos->GetPositionX()) * _aby - (-_b.GetDoublePositionY() + pos->GetPositionY()) * _abx) < 0;
86  bool sign2 = ((-_c.GetDoublePositionX() + pos->GetPositionX()) * _bcy - (-_c.GetDoublePositionY() + pos->GetPositionY()) * _bcx) < 0;
87  bool sign3 = ((-_a.GetDoublePositionX() + pos->GetPositionX()) * _cay - (-_a.GetDoublePositionY() + pos->GetPositionY()) * _cax) < 0;
88 
89  // if all signs are the same, the point is inside the triangle
90  return ((sign1 == sign2) && (sign2 == sign3));
91 }
double GetDoublePositionX() const
Definition: AreaBoundary.h:49
const double _bcx
Definition: AreaBoundary.h:123
const DoublePosition _b
Definition: AreaBoundary.h:122
const double _bcy
Definition: AreaBoundary.h:123
const double _abx
Definition: AreaBoundary.h:123
float GetPositionY() const
Definition: Position.h:105
const DoublePosition _c
Definition: AreaBoundary.h:122
double GetDoublePositionY() const
Definition: AreaBoundary.h:50
const double _cax
Definition: AreaBoundary.h:123
const double _aby
Definition: AreaBoundary.h:123
float GetPositionX() const
Definition: Position.h:104
const double _cay
Definition: AreaBoundary.h:123
const DoublePosition _a
Definition: AreaBoundary.h:122

+ Here is the call graph for this function:

Member Data Documentation

const DoublePosition TriangleBoundary::_a
private
const double TriangleBoundary::_abx
private
const double TriangleBoundary::_aby
private
const DoublePosition TriangleBoundary::_b
private
const double TriangleBoundary::_bcx
private
const double TriangleBoundary::_bcy
private
const DoublePosition TriangleBoundary::_c
private
const double TriangleBoundary::_cax
private
const double TriangleBoundary::_cay
private

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