nielsie95
09-30-2008, 01:05 PM
Grouping TPA's
by Nielsie95
Grouping TPA's can be very useful when finding objects. There are 2 main ways to group your points: TPAtoATPA and SplitTPA. In this tutorial I will try to explain the differences between the two. If you have zero knowledge about TPointArrays or T2DPointArrays, I suggest you read some other tutorials first.
You have two flavours of each function (TPAtoATPA - TPAtoATPAEx and SplitTPA - SplitTPAEx). The ex-function uses with and height to determine whether a point is close, while the non-ex uses distance.
So basicly, Ex creates a rectangle around a point, while non-ex creates a circle around a point.
function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray;
function SplitTPA(arr: TPointArray; Dist: Integer): T2DPointArray;
function TPAtoATPAEx(TPA: TPointArray; w, h: Integer): T2DPointArray;
function TPAtoATPA(TPA: TPointArray; Dist: Integer): T2DPointArray;
Now the big difference between TPAtoATPA and SplitTPA. SplitTPA will look for a close point with every point in the group, while TPAtoATPA will only use the first point. I tried my best to translate this into two pictures:
http://img513.imageshack.us/img513/9851/image1mc0.jpg
SplitTPA (using distance) - checks every point for distance.
http://img513.imageshack.us/img513/8057/image3ed2.jpg
TPAtoATPA (using w and h) - uses one point to find all near points.
The results will be a bit similar, but not totally (in same order as above):
http://img508.imageshack.us/img508/9416/image2me8.jpg
---------------
http://img210.imageshack.us/img210/4710/image4uq8.jpg
In the example above there is not really a big difference between the two, but take a look at the following:
http://img89.imageshack.us/img89/4581/image5ur3.jpg
TPAtoATPA will only find the first two points here, while SplitTPA will find all.
Another difference is that TPAtoATPA, because there is only looked at the first point, can give different results with different "first points".
http://img294.imageshack.us/img294/7039/image6bc0.jpg
If the most left point is the first point in this image, TPAtoATPA will only find the first three points. But when a point that is more in the middle is "the first point", it will group 5 points.
I hope this tutorial helped to clear things up a bit :)
Nielsie95
by Nielsie95
Grouping TPA's can be very useful when finding objects. There are 2 main ways to group your points: TPAtoATPA and SplitTPA. In this tutorial I will try to explain the differences between the two. If you have zero knowledge about TPointArrays or T2DPointArrays, I suggest you read some other tutorials first.
You have two flavours of each function (TPAtoATPA - TPAtoATPAEx and SplitTPA - SplitTPAEx). The ex-function uses with and height to determine whether a point is close, while the non-ex uses distance.
So basicly, Ex creates a rectangle around a point, while non-ex creates a circle around a point.
function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray;
function SplitTPA(arr: TPointArray; Dist: Integer): T2DPointArray;
function TPAtoATPAEx(TPA: TPointArray; w, h: Integer): T2DPointArray;
function TPAtoATPA(TPA: TPointArray; Dist: Integer): T2DPointArray;
Now the big difference between TPAtoATPA and SplitTPA. SplitTPA will look for a close point with every point in the group, while TPAtoATPA will only use the first point. I tried my best to translate this into two pictures:
http://img513.imageshack.us/img513/9851/image1mc0.jpg
SplitTPA (using distance) - checks every point for distance.
http://img513.imageshack.us/img513/8057/image3ed2.jpg
TPAtoATPA (using w and h) - uses one point to find all near points.
The results will be a bit similar, but not totally (in same order as above):
http://img508.imageshack.us/img508/9416/image2me8.jpg
---------------
http://img210.imageshack.us/img210/4710/image4uq8.jpg
In the example above there is not really a big difference between the two, but take a look at the following:
http://img89.imageshack.us/img89/4581/image5ur3.jpg
TPAtoATPA will only find the first two points here, while SplitTPA will find all.
Another difference is that TPAtoATPA, because there is only looked at the first point, can give different results with different "first points".
http://img294.imageshack.us/img294/7039/image6bc0.jpg
If the most left point is the first point in this image, TPAtoATPA will only find the first three points. But when a point that is more in the middle is "the first point", it will group 5 points.
I hope this tutorial helped to clear things up a bit :)
Nielsie95