TPointArray
TPointArray related methods
TPointArray.Mean
function TPointArray.Mean(): TPoint; constref;
Wraps Simba’s TPAMiddle
TPointArray.MeanEx
function TPointArray.MeanEx(): Vector2; constref;
Middle as a Vector.
TPointArray.Sort
procedure TPointArray.Sort(From:TPoint=[0,0]);
Wraps Simba’s SortTPAFrom
TPointArray.Sorted
function TPointArray.Sorted(From:TPoint=[0,0]): TPointArray;
Wraps Simba’s SortTPAFrom, produces a sorted copy.
TPointArray.SortByX
procedure TPointArray.SortByX(LowToHi:Boolean=True);
Wraps Simba’s SortTPAByX
TPointArray.SortByY
procedure TPointArray.SortByY(LowToHi:Boolean=True);
Wraps Simba’s SortTPAByY
TPointArray.SortByRow
procedure TPointArray.SortByRow(reverse:Boolean=False);
Sorts a given TPointArray TPA row-by-row, starting from the smallest Y coordinate to the largest Y coordinate, and for every row from the smallest X coordinate to the largest X coordinate.
TPointArray.SortByColumn
procedure TPointArray.SortByColumn(reverse:Boolean=False);
much like SortByRow, but the order of the column comes first
TPointArray.SortFromLine
procedure TPointArray.SortFromLine(p,q:TPoint; reverse:Boolean=False);
The name tells the story
TPointArray.Bounds
function TPointArray.Bounds(): TBox; constref;
Wraps Simba’s GetTPABounds
TPointArray.Edges
function TPointArray.Edges(): TPointArray; constref;
Filters all points out of the given TPointArray which aren’t edge-points. Edge-points are points that are on the edge of the TPA, not completely surrounded by other points. Same as Simba’s FindTPAEdges
TPointArray.Cluster
function TPointArray.Cluster(dist:Int32): T2DPointArray; constref;
function TPointArray.Cluster(distX,distY:Int32): T2DPointArray; constref; overload;
Smart wrapper of Simba’s ClusterTPA and ClusterTPAEx (fall backs to SplitTPA when it’s better suited)
TPointArray.Split
function TPointArray.Split(dist:Int32): T2DPointArray; constref;
function TPointArray.Split(distX,distY:Int32): T2DPointArray; constref; overload;
Wraps Simba’s SplitTPA and SplitTPAEx
TPointArray.ToATPA
function TPointArray.ToATPA(WH:Int32): T2DPointArray; constref;
function TPointArray.ToATPA(W,H:Int32): T2DPointArray; constref; overload;
Wraps Simba’s TPAToATPA and TPAToATPAEx
TPointArray.Offset
function TPointArray.Offset(off: TPoint): TPointArray;
Wraps Simba’s OffsetTPA
TPointArray.Invert
function TPointArray.Invert(Area:TBox=[0,0,-1,-1]): TPointArray; constref;
Inverts the shape based on the area covered, alternatively the given area. Same as ReturnPointsNotInTPA in Simba.
TPointArray.FilterBox
function TPointArray.FilterBox(Box: TBox): TPointArray; constref;
Returns a filtered version of the TPA. Same as Simba’s FilterPointsBox
TPointArray.FilterBox
function TPointArray.FilterDist(MinDist,MaxDist: Double; Mx,My: Int32): TPointArray; constref;
Returns a filtered version of the TPA. Same as Simba’s FilterPointsDist
TPointArray.FilterDuplicates
function TPointArray.FilterDuplicates(): TPointArray;
Returns a copy where all duplicate points are removed.
TPointArray.ClearDuplicates
procedure TPointArray.ClearDuplicates();
Removes all the duplicate points from self.
TPointArray.Rotate
function TPointArray.Rotate(AngleRad, MidX, MidY: Double): TPointArray;
Returns a copy where all points are rotated around MidX, MidY. Same as Simba’s RotatePoints.
TPointArray.SplitRows
function TPointArray.SplitRows(dist:Int32): T2DPointArray; constref;
Splits a TPA Arr into TPAs of each row, it then proceeds to further split the rows
in to separate TPAs when the given distance dist
is less than the distance between the points
Same output as SplitTPAEx(TPA,dist,0), but generally faster.
Note
by slacky
Example:
ATPA := TPA.SplitRows(5);
TPointArray.Connect
function TPointArray.Connect(): TPointArray; constref;
Fills a line between all the points (by their order), can be used to get the edges around a polygon
Note
by slacky
Example:
edges := TPA.ConvexHull().Connect();
TPointArray.ConvexHull
function TPointArray.ConvexHull(): TPointArray; constref;
Computes the convex hull around the given TPA. Imagine placing a rubber band around the points, the points which strech the band are the points returned by this function.
See: http://en.wikipedia.org/wiki/Convex_hull for more information.
Note
by slacky
Example:
Smart.Image.DrawTPA(TPA.ConvexHull());
TPointArray.MinAreaRect
function TPointArray.MinAreaRect(): TRectangle;
Computes the minimum bounding box (defined by area) around the given shape. Four points (which are in order) are always returned.
See: http://en.wikipedia.org/wiki/Minimum_bounding_box for more information.
Note
by slacky
Example:
WriteLn('The four box corners are: ', TPA.MinAreaRect());
TPointArray.MinAreaCircle
function TPointArray.MinAreaCircle(): TCircle;
Computes the minimum bounding circle around the given shape.
See: https://en.wikipedia.org/wiki/Smallest-circle_problem for more information.
Implementation is a mixture of a few implementations I’ve seen.
TPointArray.Density
function TPointArray.Density(): Double; constref;
Returns the TPA’s density (Length(TPA)/(width*height))
ExpandPolygon
function ExpandPolygon(Poly:TPointArray; inc:Int32): TPointArray;
A method for increasing the size of any convex polygon.
Note
by slacky
TPointArray.PointsInRangeOf
function TPointArray.PointsInRangeOf(constref Other: TPointArray; MinDist, MaxDist: Double): TPointArray; constref;
Returns all the points from self that are within range of any point in other. The parameters mindist and maxdist determine what “within range” means.
TPointArray.PointsInRangeOf
function TPointArray.PointsInRangeOf(constref Other: TPointArray; MinDistX, MinDistY, MaxDistX, MaxDistY: Double): TPointArray; constref; overload;
Same as the above but lets you specify X- and Y-wise min & max distance separately.