![]() |
Eclipse SUMO - Simulation of Urban MObility
|
A simple triangle defined in 3D. More...
#include <Triangle.h>
Public Member Functions | |
const Boundary & | getBoundary () const |
get triangle boundary | |
const PositionVector | getShape () const |
get shape boundary | |
bool | intersectWithCircle (const Position ¢er, 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< Triangle > | triangulate (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 ¢er, 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 | |
A simple triangle defined in 3D.
Definition at line 35 of file Triangle.h.
Triangle::Triangle | ( | ) |
default constructor
Definition at line 35 of file Triangle.cpp.
Referenced by triangulate().
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 | ( | ) |
destructor
Definition at line 49 of file Triangle.cpp.
|
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().
const Boundary & Triangle::getBoundary | ( | ) | const |
const PositionVector Triangle::getShape | ( | ) | const |
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().
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().
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().
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().
|
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().
|
staticprivate |
Definition at line 181 of file Triangle.cpp.
References crossProduct().
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().
|
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().
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().
|
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().
bool Triangle::operator!= | ( | const Triangle & | other | ) | const |
inequality operator
Definition at line 175 of file Triangle.cpp.
bool Triangle::operator== | ( | const Triangle & | other | ) | const |
|
private |
Definition at line 215 of file Triangle.cpp.
References Position::x(), and Position::y().
Referenced by segmentsIntersect().
|
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().
|
static |
Definition at line 129 of file Triangle.cpp.
References isEar(), PositionVector::openPolygon(), and Triangle().
Referenced by GNEViewNet::onCmdTriangulatePolygon(), and GNEViewNet::updateObjectsInShape().
invalid triangle
Definition at line 39 of file Triangle.h.
Referenced by GUIViewObjectsHandler::checkBoundaryParentObject(), GUIViewObjectsHandler::selectingUsingRectangle(), and GUIViewObjectsHandler::setSelectionPosition().
|
private |
first triangle position
Definition at line 114 of file Triangle.h.
Referenced by getShape(), intersectWithCircle(), intersectWithShape(), isPositionWithin(), lineIntersectsTriangle(), and operator==().
|
private |
second triangle position
Definition at line 117 of file Triangle.h.
Referenced by getShape(), intersectWithCircle(), intersectWithShape(), isPositionWithin(), lineIntersectsTriangle(), and operator==().
|
private |
triangle boundary
Definition at line 123 of file Triangle.h.
Referenced by getBoundary(), and Triangle().
|
private |
third triangle position
Definition at line 120 of file Triangle.h.
Referenced by getShape(), intersectWithCircle(), intersectWithShape(), isPositionWithin(), lineIntersectsTriangle(), and operator==().