C# Class AForge.Math.Geometry.PointsCloud

Set of tools for processing collection of points in 2D space.

The static class contains set of routines, which provide different operations with collection of points in 2D space. For example, finding the furthest point from a specified point or line.

Sample usage:

// create points' list List<IntPoint> points = new List<IntPoint>( ); points.Add( new IntPoint( 10, 10 ) ); points.Add( new IntPoint( 20, 15 ) ); points.Add( new IntPoint( 15, 30 ) ); points.Add( new IntPoint( 40, 12 ) ); points.Add( new IntPoint( 30, 20 ) ); // get furthest point from the specified point IntPoint p1 = PointsCloud.GetFurthestPoint( points, new IntPoint( 15, 15 ) ); Console.WriteLine( p1.X + ", " + p1.Y ); // get furthest point from line IntPoint p2 = PointsCloud.GetFurthestPointFromLine( points, new IntPoint( 50, 0 ), new IntPoint( 0, 50 ) ); Console.WriteLine( p2.X + ", " + p2.Y );
Show file Open project: noxryan/Claro-Shader Class Usage Examples

Public Methods

Method Description
FindQuadrilateralCorners ( IEnumerable cloud ) : List

Find corners of quadrilateral or triangular area, which contains the specified collection of points.

The method makes an assumption that the specified collection of points form some sort of quadrilateral/triangular area. With this assumption it tries to find corners of the area.

The method does not search for bounding quadrilateral/triangular area, where all specified points are inside of the found quadrilateral/triangle. Some of the specified points potentially may be outside of the found quadrilateral/triangle, since the method takes corners only from the specified collection of points, but does not calculate such to form true bounding quadrilateral/triangle.

See QuadrilateralRelativeDistortionLimit property for additional information.

GetBoundingRectangle ( IEnumerable cloud, IntPoint &minXY, IntPoint &maxXY ) : void

Get bounding rectangle of the specified list of points.

GetCenterOfGravity ( IEnumerable cloud ) : DoublePoint

Get center of gravity for the specified list of points.

GetFurthestPoint ( IEnumerable cloud, IntPoint referencePoint ) : IntPoint

Find furhtest point from the specified point.

GetFurthestPointFromLine ( IEnumerable cloud, IntPoint linePoint1, IntPoint linePoint2 ) : IntPoint

Find the furhtest point from the specified line.

The method finds the furthest point from the specified line. Unlike the GetFurthestPointsFromLine( IEnumerable{IntPoint}, IntPoint, IntPoint, out IntPoint, out IntPoint ) method, this method find only one point, which is the furthest away from the line regardless of side from the line.

GetFurthestPointFromLine ( IEnumerable cloud, IntPoint linePoint1, IntPoint linePoint2, double &distance ) : IntPoint

Find the furhtest point from the specified line.

The method finds the furthest point from the specified line. Unlike the GetFurthestPointsFromLine( IEnumerable{IntPoint}, IntPoint, IntPoint, out IntPoint, out double, out IntPoint, out double ) method, this method find only one point, which is the furthest away from the line regardless of side from the line.

GetFurthestPointsFromLine ( IEnumerable cloud, IntPoint linePoint1, IntPoint linePoint2, IntPoint &furthestPoint1, IntPoint &furthestPoint2 ) : void

Find two furhtest points from the specified line.

The method finds two furhtest points from the specified line, where one point is on one side from the line and the second point is on another side from the line.

GetFurthestPointsFromLine ( IEnumerable cloud, IntPoint linePoint1, IntPoint linePoint2, IntPoint &furthestPoint1, double &distance1, IntPoint &furthestPoint2, double &distance2 ) : void

Find two furhtest points from the specified line.

The method finds two furhtest points from the specified line, where one point is on one side from the line and the second point is on another side from the line.

Shift ( IList cloud, IntPoint shift ) : void

Shift cloud by adding specified value to all points in the collection.

Method Details

FindQuadrilateralCorners() public static method

Find corners of quadrilateral or triangular area, which contains the specified collection of points.

The method makes an assumption that the specified collection of points form some sort of quadrilateral/triangular area. With this assumption it tries to find corners of the area.

The method does not search for bounding quadrilateral/triangular area, where all specified points are inside of the found quadrilateral/triangle. Some of the specified points potentially may be outside of the found quadrilateral/triangle, since the method takes corners only from the specified collection of points, but does not calculate such to form true bounding quadrilateral/triangle.

See QuadrilateralRelativeDistortionLimit property for additional information.

public static FindQuadrilateralCorners ( IEnumerable cloud ) : List
cloud IEnumerable Collection of points to search quadrilateral for.
return List

GetBoundingRectangle() public static method

Get bounding rectangle of the specified list of points.
public static GetBoundingRectangle ( IEnumerable cloud, IntPoint &minXY, IntPoint &maxXY ) : void
cloud IEnumerable Collection of points to get bounding rectangle for.
minXY IntPoint Point comprised of smallest X and Y coordinates.
maxXY IntPoint Point comprised of biggest X and Y coordinates.
return void

GetCenterOfGravity() public static method

Get center of gravity for the specified list of points.
public static GetCenterOfGravity ( IEnumerable cloud ) : DoublePoint
cloud IEnumerable List of points to calculate center of gravity for.
return DoublePoint

GetFurthestPoint() public static method

Find furhtest point from the specified point.
public static GetFurthestPoint ( IEnumerable cloud, IntPoint referencePoint ) : IntPoint
cloud IEnumerable Collection of points to search furthest point in.
referencePoint IntPoint The point to search furthest point from.
return IntPoint

GetFurthestPointFromLine() public static method

Find the furhtest point from the specified line.

The method finds the furthest point from the specified line. Unlike the GetFurthestPointsFromLine( IEnumerable{IntPoint}, IntPoint, IntPoint, out IntPoint, out IntPoint ) method, this method find only one point, which is the furthest away from the line regardless of side from the line.

public static GetFurthestPointFromLine ( IEnumerable cloud, IntPoint linePoint1, IntPoint linePoint2 ) : IntPoint
cloud IEnumerable Collection of points to search furthest point in.
linePoint1 IntPoint First point forming the line.
linePoint2 IntPoint Second point forming the line.
return IntPoint

GetFurthestPointFromLine() public static method

Find the furhtest point from the specified line.

The method finds the furthest point from the specified line. Unlike the GetFurthestPointsFromLine( IEnumerable{IntPoint}, IntPoint, IntPoint, out IntPoint, out double, out IntPoint, out double ) method, this method find only one point, which is the furthest away from the line regardless of side from the line.

public static GetFurthestPointFromLine ( IEnumerable cloud, IntPoint linePoint1, IntPoint linePoint2, double &distance ) : IntPoint
cloud IEnumerable Collection of points to search furthest points in.
linePoint1 IntPoint First point forming the line.
linePoint2 IntPoint Second point forming the line.
distance double Distance between the furhtest found point and the given line.
return IntPoint

GetFurthestPointsFromLine() public static method

Find two furhtest points from the specified line.

The method finds two furhtest points from the specified line, where one point is on one side from the line and the second point is on another side from the line.

public static GetFurthestPointsFromLine ( IEnumerable cloud, IntPoint linePoint1, IntPoint linePoint2, IntPoint &furthestPoint1, IntPoint &furthestPoint2 ) : void
cloud IEnumerable Collection of points to search furthest points in.
linePoint1 IntPoint First point forming the line.
linePoint2 IntPoint Second point forming the line.
furthestPoint1 IntPoint First found furthest point.
furthestPoint2 IntPoint Second found furthest point (which is on the /// opposite side from the line compared to the );
return void

GetFurthestPointsFromLine() public static method

Find two furhtest points from the specified line.

The method finds two furhtest points from the specified line, where one point is on one side from the line and the second point is on another side from the line.

public static GetFurthestPointsFromLine ( IEnumerable cloud, IntPoint linePoint1, IntPoint linePoint2, IntPoint &furthestPoint1, double &distance1, IntPoint &furthestPoint2, double &distance2 ) : void
cloud IEnumerable Collection of points to search furthest points in.
linePoint1 IntPoint First point forming the line.
linePoint2 IntPoint Second point forming the line.
furthestPoint1 IntPoint First found furthest point.
distance1 double Distance between the first found point and the given line.
furthestPoint2 IntPoint Second found furthest point (which is on the /// opposite side from the line compared to the );
distance2 double Distance between the second found point and the given line.
return void

Shift() public static method

Shift cloud by adding specified value to all points in the collection.
public static Shift ( IList cloud, IntPoint shift ) : void
cloud IList Collection of points to shift their coordinates.
shift IntPoint Point to shift by.
return void