Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Triangle Class Reference

A simple triangle defined in 3D. More...

#include <Triangle.h>

Collaboration diagram for Triangle:
[legend]

Public Member Functions

const BoundarygetBoundary () const
 get triangle boundary
 
const PositionVector getShape () const
 get shape boundary
 
bool intersectWithCircle (const Position &center, const double radius) const
 check if the given circle intersect with this triangle
 
bool intersectWithShape (const PositionVector &shape) const
 check if the given shape is within or intersect with this triangle
 
bool intersectWithShape (const PositionVector &shape, const Boundary &shapeBoundary) const
 check if the given shape is within or intersect with this triangle
 
bool isBoundaryFullWithin (const Boundary &boundary) const
 check if the given position is FULL within this triangle
 
bool isPositionWithin (const Position &pos) const
 check if the given position is within this triangle
 
bool operator!= (const Triangle &other) const
 inequality operator
 
bool operator== (const Triangle &other) const
 equalityoperators
 
 Triangle ()
 default constructor
 
 Triangle (const Position &positionA, const Position &positionB, const Position &positionC)
 parameter constructor
 
 ~Triangle ()
 destructor
 

Static Public Member Functions

static std::vector< Triangletriangulate (PositionVector shape)
 

Static Public Attributes

static const Triangle INVALID = Triangle()
 invalid triangle
 

Private Member Functions

bool lineIntersectCircle (const Position &posA, const Position &posB, const Position &center, const double radius) const
 function to check if line between posA and posB intersect circle
 
functions used for check if a shape intersect with the triangle

Compute the orientation of ordered triplet (p, q, r)

int orientation (const Position &p, const Position &q, const Position &r) const
 
bool onSegment (const Position &p, const Position &q, const Position &r) const
 check if point q lies on segment pr
 
bool segmentsIntersect (const Position &p1, const Position &q1, const Position &p2, const Position &q2) const
 check if two line segments (p1,q1) and (p2,q2) intersect
 
bool lineIntersectsTriangle (const Position &p1, const Position &p2) const
 check if a line segment (p1, p2) intersects this triangle
 

Static Private Member Functions

functions used for triangulation

check if the given position is within this triangle

static bool isPositionWithin (const Position &A, const Position &B, const Position &C, const Position &pos)
 
static bool isEar (const Position &a, const Position &b, const Position &c, const PositionVector &shape)
 Check if the triangle (A, B, C) is an ear.
 
static double crossProduct (const Position &a, const Position &b, const Position &c)
 calculate cross product of the given points
 

Private Attributes

Position myA = Position::INVALID
 first triangle position
 
Position myB = Position::INVALID
 second triangle position
 
Boundary myBoundary
 triangle boundary
 
Position myC = Position::INVALID
 third triangle position
 

Detailed Description

A simple triangle defined in 3D.

Definition at line 35 of file Triangle.h.

Constructor & Destructor Documentation

◆ Triangle() [1/2]

Triangle::Triangle ( )

default constructor

Definition at line 35 of file Triangle.cpp.

Referenced by triangulate().

Here is the caller graph for this function:

◆ Triangle() [2/2]

Triangle::Triangle ( const Position positionA,
const Position positionB,
const Position positionC 
)

parameter constructor

Definition at line 38 of file Triangle.cpp.

References Boundary::add(), and myBoundary.

◆ ~Triangle()

Triangle::~Triangle ( )

destructor

Definition at line 49 of file Triangle.cpp.

Member Function Documentation

◆ crossProduct()

double Triangle::crossProduct ( const Position a,
const Position b,
const Position c 
)
staticprivate

calculate cross product of the given points

Definition at line 209 of file Triangle.cpp.

References Position::x(), and Position::y().

Referenced by isEar(), and isPositionWithin().

Here is the caller graph for this function:

◆ getBoundary()

const Boundary & Triangle::getBoundary ( ) const

get triangle boundary

Definition at line 117 of file Triangle.cpp.

References myBoundary.

◆ getShape()

const PositionVector Triangle::getShape ( ) const

get shape boundary

Definition at line 123 of file Triangle.cpp.

References myA, myB, and myC.

◆ intersectWithCircle()

bool Triangle::intersectWithCircle ( const Position center,
const double  radius 
) const

check if the given circle intersect with this triangle

Definition at line 104 of file Triangle.cpp.

References Position::distanceSquaredTo2D(), isPositionWithin(), lineIntersectCircle(), myA, myB, and myC.

Referenced by GUIViewObjectsHandler::checkCircleObject(), and GUIViewObjectsHandler::checkGeometryPoint().

Here is the caller graph for this function:

◆ intersectWithShape() [1/2]

bool Triangle::intersectWithShape ( const PositionVector shape) const

check if the given shape is within or intersect with this triangle

Definition at line 68 of file Triangle.cpp.

References PositionVector::getBoxBoundary(), and intersectWithShape().

Referenced by GUIViewObjectsHandler::checkShapeObject(), intersectWithShape(), and GNENetHelper::AttributeCarriers::isNetworkElementAroundTriangle().

Here is the caller graph for this function:

◆ intersectWithShape() [2/2]

bool Triangle::intersectWithShape ( const PositionVector shape,
const Boundary shapeBoundary 
) const

check if the given shape is within or intersect with this triangle

Definition at line 74 of file Triangle.cpp.

References PositionVector::around(), isPositionWithin(), lineIntersectsTriangle(), myA, myB, myC, Boundary::xmax(), Boundary::xmin(), Boundary::ymax(), and Boundary::ymin().

◆ isBoundaryFullWithin()

bool Triangle::isBoundaryFullWithin ( const Boundary boundary) const

check if the given position is FULL within this triangle

Definition at line 59 of file Triangle.cpp.

References isPositionWithin(), Boundary::xmax(), Boundary::xmin(), Boundary::ymax(), and Boundary::ymin().

Referenced by GNEEdge::calculateEdgeContour(), and GNEJunction::calculateJunctioncontour().

Here is the caller graph for this function:

◆ isEar()

bool Triangle::isEar ( const Position a,
const Position b,
const Position c,
const PositionVector shape 
)
staticprivate

Check if the triangle (A, B, C) is an ear.

Definition at line 193 of file Triangle.cpp.

References crossProduct(), and isPositionWithin().

Referenced by triangulate().

Here is the caller graph for this function:

◆ isPositionWithin() [1/2]

bool Triangle::isPositionWithin ( const Position A,
const Position B,
const Position C,
const Position pos 
)
staticprivate

Definition at line 181 of file Triangle.cpp.

References crossProduct().

◆ isPositionWithin() [2/2]

bool Triangle::isPositionWithin ( const Position pos) const

check if the given position is within this triangle

Definition at line 53 of file Triangle.cpp.

References isPositionWithin(), myA, myB, and myC.

Referenced by GUIViewObjectsHandler::checkCircleObject(), GUIViewObjectsHandler::checkGeometryPoint(), intersectWithCircle(), intersectWithShape(), isBoundaryFullWithin(), isEar(), GNENetHelper::AttributeCarriers::isNetworkElementAroundTriangle(), and isPositionWithin().

Here is the caller graph for this function:

◆ lineIntersectCircle()

bool Triangle::lineIntersectCircle ( const Position posA,
const Position posB,
const Position center,
const double  radius 
) const
private

function to check if line between posA and posB intersect circle

Definition at line 270 of file Triangle.cpp.

References Position::x(), and Position::y().

Referenced by intersectWithCircle().

Here is the caller graph for this function:

◆ lineIntersectsTriangle()

bool Triangle::lineIntersectsTriangle ( const Position p1,
const Position p2 
) const
private

check if a line segment (p1, p2) intersects this triangle

Definition at line 262 of file Triangle.cpp.

References myA, myB, myC, and segmentsIntersect().

Referenced by intersectWithShape().

Here is the caller graph for this function:

◆ onSegment()

bool Triangle::onSegment ( const Position p,
const Position q,
const Position r 
) const
private

check if point q lies on segment pr

Definition at line 231 of file Triangle.cpp.

References Position::x(), and Position::y().

Referenced by segmentsIntersect().

Here is the caller graph for this function:

◆ operator!=()

bool Triangle::operator!= ( const Triangle other) const

inequality operator

Definition at line 175 of file Triangle.cpp.

◆ operator==()

bool Triangle::operator== ( const Triangle other) const

equalityoperators

Definition at line 169 of file Triangle.cpp.

References myA, myB, and myC.

◆ orientation()

int Triangle::orientation ( const Position p,
const Position q,
const Position r 
) const
private

Definition at line 215 of file Triangle.cpp.

References Position::x(), and Position::y().

Referenced by segmentsIntersect().

Here is the caller graph for this function:

◆ segmentsIntersect()

bool Triangle::segmentsIntersect ( const Position p1,
const Position q1,
const Position p2,
const Position q2 
) const
private

check if two line segments (p1,q1) and (p2,q2) intersect

Definition at line 238 of file Triangle.cpp.

References onSegment(), and orientation().

Referenced by lineIntersectsTriangle().

Here is the caller graph for this function:

◆ triangulate()

std::vector< Triangle > Triangle::triangulate ( PositionVector  shape)
static

Definition at line 129 of file Triangle.cpp.

References isEar(), PositionVector::openPolygon(), and Triangle().

Referenced by GNEViewNet::onCmdTriangulatePolygon(), and GNEViewNet::updateObjectsInShape().

Here is the caller graph for this function:

Field Documentation

◆ INVALID

◆ myA

Position Triangle::myA = Position::INVALID
private

first triangle position

Definition at line 114 of file Triangle.h.

Referenced by getShape(), intersectWithCircle(), intersectWithShape(), isPositionWithin(), lineIntersectsTriangle(), and operator==().

◆ myB

Position Triangle::myB = Position::INVALID
private

second triangle position

Definition at line 117 of file Triangle.h.

Referenced by getShape(), intersectWithCircle(), intersectWithShape(), isPositionWithin(), lineIntersectsTriangle(), and operator==().

◆ myBoundary

Boundary Triangle::myBoundary
private

triangle boundary

Definition at line 123 of file Triangle.h.

Referenced by getBoundary(), and Triangle().

◆ myC

Position Triangle::myC = Position::INVALID
private

third triangle position

Definition at line 120 of file Triangle.h.

Referenced by getShape(), intersectWithCircle(), intersectWithShape(), isPositionWithin(), lineIntersectsTriangle(), and operator==().


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