PDA

View Full Version : Grouping TPA's



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

Lee Lok Hin
09-30-2008, 01:44 PM
So that's the difference between SplitTPA and TPAtoATPA.
Well, Thanks for clearing that up :p

I must say though, the circles confuzzled me slightly.

sirlaughsalot
09-30-2008, 01:57 PM
So SplitTPA forms like a chain and TPAToATPA is easy to understand :p

Edit:
Can you also explain what things like MiddleTPAEx do, and how to use other sorting techniques?

Nava2
09-30-2008, 07:28 PM
Middle gets the average x, and y. AKA its the Middle of the TPA ;).

Leech
09-30-2008, 08:08 PM
I think I understand it.

So if I do,
TPAtoATPA(TPointArray, 5); It will only group the tpoints within 5 points of eachother from a one point

and

SplitTPA(TPointArray, 5); Will group the tpoints within 5 points of each other from all points?

Like:
0: 2,2
1: 5,5
2: 8,8

Using a distance of 5
TPAtoATPA will only group 0 and 1
SplitTPA will group 0,1, and 2

I hope I am right :confused:

nielsie95
09-30-2008, 08:16 PM
Yes, that's right :)
Maybe I'll expand it later with MiddleTPA.

Leech
10-01-2008, 03:26 AM
What would be good examples of when you would want to use SplitTPA over TPAtoATPA?

Lee Lok Hin
10-01-2008, 03:37 AM
TPAtoATPA would be used when trying to find a building on the minimap, because each building will have it's own TPA, compared to SplitTPA

SplitTPA might be good for finding trees, because everybody has this same colour, and thie tpa might includ part of the ground and the tree. SplitTPA will include all TPAs, while TPAtoATPa might just miss the tree.

lordsaturn
10-01-2008, 03:38 AM
You should definitely explain all of the different sorting techniques you can use with ATPAs.
If you want to take the time, of course :)

J4Ck
12-10-2008, 05:56 AM
You should definitely explain all of the different sorting techniques you can use with ATPAs.
If you want to take the time, of course :)

That would be very helpful, I agree.