Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Static Public Member Functions | List of all members
Loyc.Geometry.PolygonMath Class Reference

Contains useful basic polygon algorithms: hit testing, area calculation, orientation detection. More...


Source file:

Remarks

Contains useful basic polygon algorithms: hit testing, area calculation, orientation detection.

Static Public Member Functions

static long PolygonArea (IEnumerable< Point > polygon)
 Computes the area of a polygon. More...
 
static long PolygonArea (IEnumerator< Point > e)
 
static int Orientation (IEnumerable< Point > poly)
 Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward. More...
 
static int Orientation (IEnumerator< Point > poly)
 
static bool IsPointInPolygon (IEnumerable< Point > poly, Point p)
 Finds out if a point is inside the polygon using a winding test. More...
 
static bool IsPointInPolygon (IEnumerator< Point > e, Point p)
 
static int GetWindingNumber (this IEnumerable< Point > poly, Point p)
 Counts the number of times the polygon winds around a test point, using a rightward raycasting test. More...
 
static int GetWindingNumber (this IEnumerator< Point > e, Point p)
 
static float PolygonArea (IEnumerable< Point > polygon)
 Computes the area of a polygon. More...
 
static float PolygonArea (IEnumerator< Point > e)
 
static int Orientation (IEnumerable< Point > poly)
 Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward. More...
 
static int Orientation (IEnumerator< Point > poly)
 
static bool IsPointInPolygon (IEnumerable< Point > poly, Point p)
 Finds out if a point is inside the polygon using a winding test. More...
 
static bool IsPointInPolygon (IEnumerator< Point > e, Point p)
 
static int GetWindingNumber (this IEnumerable< Point > poly, Point p)
 Counts the number of times the polygon winds around a test point, using a rightward raycasting test. More...
 
static int GetWindingNumber (this IEnumerator< Point > e, Point p)
 
static double PolygonArea (IEnumerable< Point > polygon)
 Computes the area of a polygon. More...
 
static double PolygonArea (IEnumerator< Point > e)
 
static int Orientation (IEnumerable< Point > poly)
 Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward. More...
 
static int Orientation (IEnumerator< Point > poly)
 
static bool IsPointInPolygon (IEnumerable< Point > poly, Point p)
 Finds out if a point is inside the polygon using a winding test. More...
 
static bool IsPointInPolygon (IEnumerator< Point > e, Point p)
 
static int GetWindingNumber (this IEnumerable< Point > poly, Point p)
 Counts the number of times the polygon winds around a test point, using a rightward raycasting test. More...
 
static int GetWindingNumber (this IEnumerator< Point > e, Point p)
 
static FPL16 PolygonArea (IEnumerable< Point > polygon)
 Computes the area of a polygon. More...
 
static FPL16 PolygonArea (IEnumerator< Point > e)
 
static int Orientation (IEnumerable< Point > poly)
 Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward. More...
 
static int Orientation (IEnumerator< Point > poly)
 
static bool IsPointInPolygon (IEnumerable< Point > poly, Point p)
 Finds out if a point is inside the polygon using a winding test. More...
 
static bool IsPointInPolygon (IEnumerator< Point > e, Point p)
 
static int GetWindingNumber (this IEnumerable< Point > poly, Point p)
 Counts the number of times the polygon winds around a test point, using a rightward raycasting test. More...
 
static int GetWindingNumber (this IEnumerator< Point > e, Point p)
 
static FPL32 PolygonArea (IEnumerable< Point > polygon)
 Computes the area of a polygon. More...
 
static FPL32 PolygonArea (IEnumerator< Point > e)
 
static int Orientation (IEnumerable< Point > poly)
 Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward. More...
 
static int Orientation (IEnumerator< Point > poly)
 
static bool IsPointInPolygon (IEnumerable< Point > poly, Point p)
 Finds out if a point is inside the polygon using a winding test. More...
 
static bool IsPointInPolygon (IEnumerator< Point > e, Point p)
 
static int GetWindingNumber (this IEnumerable< Point > poly, Point p)
 Counts the number of times the polygon winds around a test point, using a rightward raycasting test. More...
 
static int GetWindingNumber (this IEnumerator< Point > e, Point p)
 

Member Function Documentation

static int Loyc.Geometry.PolygonMath.GetWindingNumber ( this IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Counts the number of times the polygon winds around a test point, using a rightward raycasting test.

Returns
Returns the winding number: the number of times that the polygon winds around the point. Positive means clockwise (assuming a coordinate system in which increasing Y goes upward), negative means counterclockwise. Always returns -1, 0 or +1 when the polygon does not self-intersect. Returns 0 for a degenerate polygon.

The test point is considered to be within the polygon if it lies on a top or left edge, but not on a bottom or right edge (within the precision limits of 'double' arithmetic). The test point will never be considered inside a degenerate (zero-width) area.

References Loyc.Geometry.PolygonMath.GetWindingNumber().

Referenced by Loyc.Geometry.PolygonMath.GetWindingNumber().

static int Loyc.Geometry.PolygonMath.GetWindingNumber ( this IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Counts the number of times the polygon winds around a test point, using a rightward raycasting test.

Returns
Returns the winding number: the number of times that the polygon winds around the point. Positive means clockwise (assuming a coordinate system in which increasing Y goes upward), negative means counterclockwise. Always returns -1, 0 or +1 when the polygon does not self-intersect. Returns 0 for a degenerate polygon.

The test point is considered to be within the polygon if it lies on a top or left edge, but not on a bottom or right edge (within the precision limits of 'double' arithmetic). The test point will never be considered inside a degenerate (zero-width) area.

References Loyc.Geometry.PolygonMath.GetWindingNumber().

Referenced by Loyc.Geometry.PolygonMath.GetWindingNumber().

static int Loyc.Geometry.PolygonMath.GetWindingNumber ( this IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Counts the number of times the polygon winds around a test point, using a rightward raycasting test.

Returns
Returns the winding number: the number of times that the polygon winds around the point. Positive means clockwise (assuming a coordinate system in which increasing Y goes upward), negative means counterclockwise. Always returns -1, 0 or +1 when the polygon does not self-intersect. Returns 0 for a degenerate polygon.

The test point is considered to be within the polygon if it lies on a top or left edge, but not on a bottom or right edge (within the precision limits of 'double' arithmetic). The test point will never be considered inside a degenerate (zero-width) area.

References Loyc.Geometry.PolygonMath.GetWindingNumber().

Referenced by Loyc.Geometry.PolygonMath.GetWindingNumber().

static int Loyc.Geometry.PolygonMath.GetWindingNumber ( this IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Counts the number of times the polygon winds around a test point, using a rightward raycasting test.

Returns
Returns the winding number: the number of times that the polygon winds around the point. Positive means clockwise (assuming a coordinate system in which increasing Y goes upward), negative means counterclockwise. Always returns -1, 0 or +1 when the polygon does not self-intersect. Returns 0 for a degenerate polygon.

The test point is considered to be within the polygon if it lies on a top or left edge, but not on a bottom or right edge (within the precision limits of 'double' arithmetic). The test point will never be considered inside a degenerate (zero-width) area.

References Loyc.Geometry.PolygonMath.GetWindingNumber().

Referenced by Loyc.Geometry.PolygonMath.GetWindingNumber().

static int Loyc.Geometry.PolygonMath.GetWindingNumber ( this IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Counts the number of times the polygon winds around a test point, using a rightward raycasting test.

Returns
Returns the winding number: the number of times that the polygon winds around the point. Positive means clockwise (assuming a coordinate system in which increasing Y goes upward), negative means counterclockwise. Always returns -1, 0 or +1 when the polygon does not self-intersect. Returns 0 for a degenerate polygon.

The test point is considered to be within the polygon if it lies on a top or left edge, but not on a bottom or right edge (within the precision limits of 'double' arithmetic). The test point will never be considered inside a degenerate (zero-width) area.

References Loyc.Geometry.PolygonMath.GetWindingNumber().

Referenced by Loyc.Geometry.PolygonMath.GetWindingNumber().

static bool Loyc.Geometry.PolygonMath.IsPointInPolygon ( IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Finds out if a point is inside the polygon using a winding test.

static bool Loyc.Geometry.PolygonMath.IsPointInPolygon ( IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Finds out if a point is inside the polygon using a winding test.

static bool Loyc.Geometry.PolygonMath.IsPointInPolygon ( IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Finds out if a point is inside the polygon using a winding test.

static bool Loyc.Geometry.PolygonMath.IsPointInPolygon ( IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Finds out if a point is inside the polygon using a winding test.

static bool Loyc.Geometry.PolygonMath.IsPointInPolygon ( IEnumerable< Point >  poly,
Point  p 
)
inlinestatic

Finds out if a point is inside the polygon using a winding test.

static int Loyc.Geometry.PolygonMath.Orientation ( IEnumerable< Point >  poly)
inlinestatic

Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward.

A common approach to this problem is to look at the topmost point and the two points on either side. However, if one is not careful, this technique may be unable to detect the orientation in case the polygon has duplicate points, horizontal lines on top, or a degenerate top in which the top part of the polygon is zero-width (these problems can occur even if the polygon's lines do not cross one another.) That's why I chose to compute orientation based on area instead.

static int Loyc.Geometry.PolygonMath.Orientation ( IEnumerable< Point >  poly)
inlinestatic

Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward.

A common approach to this problem is to look at the topmost point and the two points on either side. However, if one is not careful, this technique may be unable to detect the orientation in case the polygon has duplicate points, horizontal lines on top, or a degenerate top in which the top part of the polygon is zero-width (these problems can occur even if the polygon's lines do not cross one another.) That's why I chose to compute orientation based on area instead.

static int Loyc.Geometry.PolygonMath.Orientation ( IEnumerable< Point >  poly)
inlinestatic

Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward.

A common approach to this problem is to look at the topmost point and the two points on either side. However, if one is not careful, this technique may be unable to detect the orientation in case the polygon has duplicate points, horizontal lines on top, or a degenerate top in which the top part of the polygon is zero-width (these problems can occur even if the polygon's lines do not cross one another.) That's why I chose to compute orientation based on area instead.

static int Loyc.Geometry.PolygonMath.Orientation ( IEnumerable< Point >  poly)
inlinestatic

Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward.

A common approach to this problem is to look at the topmost point and the two points on either side. However, if one is not careful, this technique may be unable to detect the orientation in case the polygon has duplicate points, horizontal lines on top, or a degenerate top in which the top part of the polygon is zero-width (these problems can occur even if the polygon's lines do not cross one another.) That's why I chose to compute orientation based on area instead.

static int Loyc.Geometry.PolygonMath.Orientation ( IEnumerable< Point >  poly)
inlinestatic

Returns Math.Sign(PolygonArea(poly)): positive when clockwise and increasing Y goes upward.

A common approach to this problem is to look at the topmost point and the two points on either side. However, if one is not careful, this technique may be unable to detect the orientation in case the polygon has duplicate points, horizontal lines on top, or a degenerate top in which the top part of the polygon is zero-width (these problems can occur even if the polygon's lines do not cross one another.) That's why I chose to compute orientation based on area instead.

static long Loyc.Geometry.PolygonMath.PolygonArea ( IEnumerable< Point >  polygon)
inlinestatic

Computes the area of a polygon.

Returns
The area. The result is positive if the polygon is clockwise (assuming a coordinate system in which increasing Y goes upward), or negative if the polygon is counterclockwise.

http://www.codeproject.com/Tips/601272/Calculating-the-area-of-a-polygon

References Loyc.Geometry.PolygonMath.PolygonArea().

Referenced by Loyc.Geometry.PolygonMath.PolygonArea().

static float Loyc.Geometry.PolygonMath.PolygonArea ( IEnumerable< Point >  polygon)
inlinestatic

Computes the area of a polygon.

Returns
The area. The result is positive if the polygon is clockwise (assuming a coordinate system in which increasing Y goes upward), or negative if the polygon is counterclockwise.

http://www.codeproject.com/Tips/601272/Calculating-the-area-of-a-polygon

References Loyc.Geometry.PolygonMath.PolygonArea().

Referenced by Loyc.Geometry.PolygonMath.PolygonArea().

static double Loyc.Geometry.PolygonMath.PolygonArea ( IEnumerable< Point >  polygon)
inlinestatic

Computes the area of a polygon.

Returns
The area. The result is positive if the polygon is clockwise (assuming a coordinate system in which increasing Y goes upward), or negative if the polygon is counterclockwise.

http://www.codeproject.com/Tips/601272/Calculating-the-area-of-a-polygon

References Loyc.Geometry.PolygonMath.PolygonArea().

Referenced by Loyc.Geometry.PolygonMath.PolygonArea().

static FPL16 Loyc.Geometry.PolygonMath.PolygonArea ( IEnumerable< Point >  polygon)
inlinestatic

Computes the area of a polygon.

Returns
The area. The result is positive if the polygon is clockwise (assuming a coordinate system in which increasing Y goes upward), or negative if the polygon is counterclockwise.

http://www.codeproject.com/Tips/601272/Calculating-the-area-of-a-polygon

References Loyc.Geometry.PolygonMath.PolygonArea().

Referenced by Loyc.Geometry.PolygonMath.PolygonArea().

static FPL32 Loyc.Geometry.PolygonMath.PolygonArea ( IEnumerable< Point >  polygon)
inlinestatic

Computes the area of a polygon.

Returns
The area. The result is positive if the polygon is clockwise (assuming a coordinate system in which increasing Y goes upward), or negative if the polygon is counterclockwise.

http://www.codeproject.com/Tips/601272/Calculating-the-area-of-a-polygon

References Loyc.Geometry.PolygonMath.PolygonArea().

Referenced by Loyc.Geometry.PolygonMath.PolygonArea().