File Poly.cu
Go to the source code of this file
#include "Poly.h"
Public Functions
Type | Name |
---|---|
Polygon | CounterCWPoly (Polygon Poly) check polygon handedness and reverse if necessary. |
bool | PolygonIntersect (Polygon P, Polygon Q) Intersection between two polygons. |
bool | SegmentIntersect (Polygon P, Polygon Q) Intersection between segments. |
Vertex | VertAdd (Vertex A, Vertex B) Add two vertices. |
Vertex | VertSub (Vertex A, Vertex B) Subtract two vertices. |
bool | blockinpoly (T xo, T yo, T dx, int blkwidth, Polygon Poly) Check whether a block is inside or intersects a polygon. |
template bool | blockinpoly< double > (double xo, double yo, double dx, int blkwidth, Polygon Poly) |
template bool | blockinpoly< float > (float xo, float yo, float dx, int blkwidth, Polygon Poly) |
int | cn_PnPoly (T Px, T Py, F * Vx, F * Vy, int n) Crossing number test for a point in a polygon. |
double | dotprod (Vertex A, Vertex B) Compute dot product of two vertices. |
T | isLeft (T P0x, T P0y, T P1x, T P1y, T P2x, T P2y) Tests if a point is Left|On|Right of an infinite line. |
bool | test_SegmentIntersect () Test segment intersection function. |
bool | test_intersectpoly () Test polygon intersection function. |
bool | test_wninpoly () Test winding number inpoly function. |
int | wn_PnPoly (T Px, T Py, T * Vx, T * Vy, unsigned int n) winding number test for a point in a polygon |
int | wn_PnPoly (T Px, T Py, Polygon Poly) winding number test for a point in a polygon |
template int | wn_PnPoly< double > (double Px, double Py, Polygon Poly) |
template int | wn_PnPoly< float > (float Px, float Py, Polygon Poly) |
double | xprod (Vertex A, Vertex B) Compute cross product of two vertices. |
Public Functions Documentation
function CounterCWPoly
check polygon handedness and reverse if necessary.
Description
check polygon handedness and enforce left-handesness (Counter-clockwise). This function is used to ensure the right polygon handedness for the winding number inpoly (using the isleft())
function PolygonIntersect
Intersection between two polygons.
Checks whether two polygons intersect by testing all segment pairs. The function checks whether each segment of Polygon P intersect any segment of Poly Q. If an intersection is detected, returns true immediately.
Parameters:
P
First polygonQ
Second polygon
Returns:
True if polygons intersect, false otherwise
function SegmentIntersect
Intersection between segments.
Checks whether two polygon segments intersect. Polygon P and Q are only 2 vertex long each. i.e. they represent a segment each.
Where does this come from:
https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect Best answer from Gareth Rees
Parameters:
Returns:
True if segments intersect, false otherwise
function VertAdd
Add two vertices.
Returns the sum of two Vertex objects.
Parameters:
A
First vertexB
Second vertex
Returns:
Sum vertex
function VertSub
Subtract two vertices.
Returns the difference of two Vertex objects.
Parameters:
A
First vertexB
Second vertex
Returns:
Difference vertex
function blockinpoly
Check whether a block is inside or intersects a polygon.
Determines if any corner of the block is inside the polygon or if the block intersects the polygon.
Template parameters:
T
Coordinate type
Parameters:
xo
Block origin xyo
Block origin ydx
Block cell sizeblkwidth
Block widthPoly
Polygon to test
Returns:
True if block is inside or intersects polygon, false otherwise
function blockinpoly< double >
function blockinpoly< float >
function cn_PnPoly
Crossing number test for a point in a polygon.
Determines if a point is inside a polygon using the crossing number algorithm. cn_PnPoly(): crossing number test for a point in a polygon Input: P = a point, V[] = vertex points of a polygon V[n+1] with V[n]=V[0] Return: 0 = outside, 1 = inside
Where does this come from:
Copyright 2000 softSurfer, 2012 Dan Sunday
Original Licence
This code may be freely used and modified for any purpose providing that this copyright notice is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage resulting from its use. Users of this code must verify correctness for their application. Code modified to fit the use in DisperGPU
This code is patterned after [Franklin, 2000]
Template parameters:
T
Point coordinate typeF
Vertex coordinate type
Parameters:
Px
X coordinate of pointPy
Y coordinate of pointVx
Array of polygon vertex X coordinatesVy
Array of polygon vertex Y coordinatesn
Number of vertices
Returns:
1 if inside, 0 if outside
function dotprod
Compute dot product of two vertices.
Calculates the dot product of two Vertex objects.
Parameters:
A
First vertexB
Second vertex
Returns:
Dot product value
function isLeft
Tests if a point is Left|On|Right of an infinite line.
Returns >0 for P2 left of the line through P0 and P1, =0 for P2 on the line, <0 for P2 right of the line. See: Algorithm 1 "Area of Triangles and Polygons"
Where does this come from:
Copyright 2000 softSurfer, 2012 Dan Sunday
Original Licence
This code may be freely used and modified for any purpose providing that this copyright notice is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage resulting from its use. Users of this code must verify correctness for their application. Code modified to fit the use in DisperGPU
Template parameters:
T
Coordinate type
Parameters:
P0x
X of first pointP0y
Y of first pointP1x
X of second pointP1y
Y of second pointP2x
X of test pointP2y
Y of test point
Returns:
Relative position value
function test_SegmentIntersect
Test segment intersection function.
Tests the segment intersection function for known cases.
Returns:
True if test passes, false otherwise
function test_intersectpoly
Test polygon intersection function.
Tests the polygon intersection function for known cases.
Returns:
True if test passes, false otherwise
function test_wninpoly
Test winding number inpoly function.
Tests the winding number function for a block polygon.
Returns:
True if test passes, false otherwise
function wn_PnPoly
winding number test for a point in a polygon
Description
wn_PnPoly(): winding number test for a point in a polygon Input: P = a point, V[] = vertex points of a polygon V[n+1] with V[n]=V[0] Return: wn = the winding number (=0 only when P is outside)
Where does this come from:
Copyright 2000 softSurfer, 2012 Dan Sunday
Original Licence
This code may be freely used and modified for any purpose providing that this copyright notice is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage resulting from its use. Users of this code must verify correctness for their application. Code modified to fit the use in DisperGPU
function wn_PnPoly
winding number test for a point in a polygon
Description
wn_PnPoly(): winding number test for a point in a polygon Input: P = a point, V[] = vertex points of a polygon V[n+1] with V[n]=V[0] Return: wn = the winding number (=0 only when P is outside)
Where does this come from:
Copyright 2000 softSurfer, 2012 Dan Sunday
Original Licence
This code may be freely used and modified for any purpose providing that this copyright notice is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage resulting from its use. Users of this code must verify correctness for their application. Code modified to fit the use in DisperGPU
function wn_PnPoly< double >
function wn_PnPoly< float >
function xprod
Compute cross product of two vertices.
Calculates the cross product of two Vertex objects.
Parameters:
A
First vertexB
Second vertex
Returns:
Cross product value
The documentation for this class was generated from the following file src/Poly.cu