PARP Research Group | Universidad de Murcia |
QVPolylineF Class Reference
|
Public Member Functions | |
bool | surrounds (const QPointF &p) const |
Test if a point is contained inside the polygon. |
Floating point polyline representation.
A polyline is a continuous line composed of one or more straight line segments. A QVPolylineF is a implementation of a polyline, specified by a list of the points located at the intersection of the segments. Thus, any QVPolylineF object inherits from the class QList<QPointF>.
When a polyline is closed, then it is considered to be a polygon. In that case it is supposed to have an implicit final straight line segment, that links the first and the last point in the polyline. The property QVPolylineF::closed will store the value TRUE if the polyline is a polygon, else storing FALSE.
A QVPolylineF has the property QVPolylineF::direction, that will indicate if it is a direct polyline, or a reverse polyline. It has only meaning for some algorithms, like getConnectedSetBorderContoursThreshold.
Definition at line 54 of file qvpolylinef.h.
bool QVPolylineF::surrounds | ( | const QPointF & | p | ) | const |
Test if a point is contained inside the polygon.
The polygon is supposed to be closed in any case. The following image shows the result of applying this method with a polyline (drawn in red) over a set of points lying inside it (drawn in green) and outside it (drawn in red):
The source of the algorithm is the following:
[...] Another solution forwarded by Philippe Reverdy is to compute the sum of the angles made between the test point and each pair of points making up the polygon. If this sum is 2pi then the point is an interior point, if 0 then the point is an exterior point. This also works for polygons with holes given the polygon is defined with a path made up of coincident edges into and out of the hole as is common practice in many CAD packages. [...] http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/
Definition at line 128 of file qvpolylinef.cpp.