For each TPA in the First ATPA, gettpabounds. For each TPA in the Second ATPA, gettpabounds. For each box, check if they intersect.
If they do, use a forloop to get each point within the intersection.
Printable View
Something like this is what I've been trying but it takes way to long to be practical in most uses, if there are alot of TPA results
Was considering some kind of tradeoff and finding the middle of the two ATPA boxes and checking if they are within X distance from each other and then doing the calculation for those boxes? Might still take a long time if both ATPA's have alot of boxes
Simba Code:Function ATPAIntersections(ATPAOne, ATPATwo: T2DPointArray): TPointArray;
var
I, J, K, L, Index: Integer;
Begin
For I := 0 To High(ATPAOne) Do
For K := 0 To High(ATPAOne[I]) Do
For J := 0 To High(ATPATwo) Do
For L := 0 To High(ATPATwo[J]) Do
If (ATPAOne[I][K] = ATPATwo[J][L]) Then
Begin
SetLength(Result, Index + 1);
Result[Index] := ATPAOne[I][K];
Inc(Index);
End;
End;
var
ATPAOne, ATPATwo: T2DPointArray;
begin
ATPAOne := [TPointArray([Point(0, 0), Point(1, 1)]), TPointArray([Point(10, 10), Point(11, 11), Point(14, 0), Point(20, 20), Point(12, 12)])];
ATPATwo := [TPointArray([Point(0, 0), Point(1, 1)]), TPointArray([Point(10, 10), Point(11, 11), Point(12, 12), Point(13, 13)])];
writeln(ATPAIntersections(ATPAOne, ATPATwo));
end.
You can easily change the result to a TBoxArray and it'll hold a list of all boxes that intersect.. I chose to leave it as a TPA.. You get a list of all points that are in both ATPA's. I see it as more useful than the boxes.
The two ATPA's can also be of different sizes/lengths.
Seems pretty fast to me :S
It works in RS and normally as well.. It's just with a ton of points, there's a ton of iterations and thus it gets extremely slow..
The below will print one point because the two boxes only intersect at one point. So yeah the algorithm and stuff works. It could of course be optimized a bit but for a lot of points it's slow :c
Simba Code:{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/Debug.Simba}
Function ATPAIntersections(ATPAOne, ATPATwo: T2DPointArray): TPointArray;
var
I, J, K, L, Index: Integer;
Begin
For I := 0 To High(ATPAOne) Do
For K := 0 To High(ATPAOne[I]) Do
For J := 0 To High(ATPATwo) Do
For L := 0 To High(ATPATwo[J]) Do
If (ATPAOne[I][K] = ATPATwo[J][L]) Then
Begin
SetLength(Result, Index + 1);
Result[Index] := ATPAOne[I][K];
Inc(Index);
End;
End;
var
A, A2: T2DPointArray;
T, T2: TPointArray;
begin
SetupSRL;
T := TPAFromBox(IntToBox(0, 0, 25, 25));
T2 := TPAFromBox(IntToBox(25, 25, 50, 50));
A := TPAToATPAEx(T, 30, 35);
A2 := TPAToATPAEx(T2, 40, 10);
writeln(ATPAIntersections(A, A2));
end.
nvm scratch that LOL
a sound plugin!!!
Simba Code:function ATPAOverlapping(Limit : Integer; ATPA, ATPA2 : T2DPointArray; Var ATPAResult: T2DPointarray) : Boolean;
Var
I, II, III, IIII : Integer;
TempTPA : TpointArray;
begin
For I := 0 to High(ATPA) do
begin
TBOX := GetTPABounds(ATPA[I]);
For II := 0 to high ATPA2 do
begin
for III:= 0 to High(ATPA2[i]) do
begin
if PointInBox(ATPA2[ii][iii], Tbox) then
begin
inc(Count);
IIII := GetArrayLength(TempTPA);
SetArrayLength(TempTPA, IIII + 1);
TempTPA[IIII] := ATPA[ii][iii];
end;
If Count > Limit then
begin
IIII := GetArrayLength(ATPAResult);
SetArrayLength(ATPAResult, IIII + 1);
ATPAResult[IIII] := TempTPA;
end;
SetArraylength(ATPAresult, 0);
SetArrayLength(TempTPA, 0);
end;
Something like that anyway. Just a method off the top of my head. This was not done in simba so likely all the code is worng but this is just to illustrate the method.
Edit Ninja'd by brandon. :p
This definitely sounds interesting, can't wait to see it :)Quote:
I've worked on a much more secure way to log the player into RS that will render any and all keyloggers powerless. It's still not fully operational and still being discussed in the higher up boards, but should I (we) get it working correctly it would be an ideal option way to login for the high security-wise user.
Moar support for Linux :)
(Though I guess this is just SRL6)