Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function MSSL_TPADistanceToPt(TPA: TPointArray; p: TPoint; method: (dtpClosest, dtpFarthest)): Integer;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns the distance from TPA to point (p).
- Contains 2 methods: dtpClosest (closest distance) & dtpFarthest (farthest distance)
- Result is based on SCAR's Distance() function.
- [==============================================================================}
- var
- h, i, d: Integer;
- begin
- Result := -1;
- h := High(TPA);
- if (h < 0) then
- Exit;
- Result := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- if (h > 0) then
- case method of
- dtpClosest:
- for i := 1 to h do
- begin
- d := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- if (d < Result) then
- Result := d;
- end;
- dtpFarthest:
- for i := 1 to h do
- begin
- d := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- if (d > Result) then
- Result := d;
- end;
- end;
- end;
- function MSSL_TPADistanceToPtEx(TPA: TPointArray; p: TPoint; method: (dtpClosest, dtpFarthest); var m_pt: TPoint): Integer;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns the distance from TPA to point (p).
- Contains 2 methods: dtpClosest (closest distance) & dtpFarthest (farthest distance)
- TPA's matched (closest/farthest) point is stored to m_pt.
- Result is based on SCAR's Distance() function.
- [==============================================================================}
- var
- h, i, d: Integer;
- begin
- Result := -1;
- h := High(TPA);
- if (h < 0) then
- Exit;
- Result := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- if (h > 0) then
- case method of
- dtpClosest:
- for i := 1 to h do
- begin
- d := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- if (d < Result) then
- begin
- Result := d;
- m_pt := TPA[i];
- end;
- end;
- dtpFarthest:
- for i := 1 to h do
- begin
- d := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- if (d > Result) then
- begin
- Result := d;
- m_pt := TPA[i];
- end;
- end;
- end;
- end;
- function MSSL_TPADistanceToPtEx2(TPA: TPointArray; p: TPoint; method: (dtpClosest, dtpFarthest); var m_pts: TPointArray): Integer;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns the distance from TPA to point (p).
- Contains 2 methods: dtpClosest (closest distance) & dtpFarthest (farthest distance)
- TPA's matched (closest/farthest) points are stored to m_pts.
- Result is based on SCAR's Distance() function.
- [==============================================================================}
- var
- h, i, d, r: Integer;
- begin
- Result := -1;
- h := High(TPA);
- if (h < 0) then
- Exit;
- Result := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- SetLength(m_pts, (h + 1));
- m_pts[i] := TPA[i];
- if (h > 0) then
- begin
- case method of
- dtpClosest:
- for i := 1 to h do
- begin
- d := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- if (d <= Result) then
- begin
- if (d < Result) then
- begin
- Result := d;
- r := 0;
- end;
- m_pts[r] := TPA[i];
- Inc(r);
- end;
- end;
- dtpFarthest:
- for i := 1 to h do
- begin
- d := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- if (d >= Result) then
- begin
- if (d > Result) then
- begin
- Result := d;
- r := 0;
- end;
- m_pts[r] := TPA[i];
- Inc(r);
- end;
- end;
- end;
- SetLength(m_pts, r);
- end;
- end;
- function MSSL_TPADistanceToTPA(TPA1, TPA2: TPointArray; method: (dtpClosest, dtpFarthest)): Integer;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns the distance from TPA1 to TPA2.
- Contains 2 methods: dtpClosest (closest distance) & dtpFarthest (farthest distance)
- Matched (closest/farthest) points are stored to m_pt.
- Result is based on SCAR's Distance() function.
- [==============================================================================}
- var
- h1, h2, i1, i2, d: Integer;
- begin
- Result := -1;
- h1 := High(TPA1);
- h2 := High(TPA2);
- if ((h1 < 0) or (h2 < 0)) then
- Exit;
- Result := Distance(TPA1[0].X, TPA1[0].Y, TPA2[0].X, TPA2[0].Y);
- case method of
- dtpClosest:
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- d := Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y);
- if (d < Result) then
- Result := d;
- end;
- dtpFarthest:
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- d := Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y);
- if (d > Result) then
- Result := d;
- end;
- end;
- end;
- function MSSL_TPADistanceToTPAEx(TPA1, TPA2: TPointArray; method: (dtpClosest, dtpFarthest); var m_pt1, m_pt2: TPoint): Integer;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns the distance from TPA1 to TPA2.
- Contains 2 methods: dtpClosest (closest distance) & dtpFarthest (farthest distance)
- Matched (closest/farthest) points are stored to m_pt1 & m_pt2.
- Result is based on SCAR's Distance() function.
- [==============================================================================}
- var
- h1, i1, h2, i2, d: Integer;
- begin
- Result := -1;
- h1 := High(TPA1);
- h2 := High(TPA2);
- if ((h1 < 0) or (h2 < 0)) then
- Exit;
- Result := Distance(TPA1[0].X, TPA1[0].Y, TPA2[0].X, TPA2[0].Y);
- m_pt1 := TPA1[0];
- m_pt2 := TPA2[0];
- case method of
- dtpClosest:
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- d := Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y);
- if (d < Result) then
- begin
- Result := d;
- m_pt1 := TPA1[i1];
- m_pt2 := TPA2[i2];
- end;
- end;
- dtpFarthest:
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- d := Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y);
- if (d > Result) then
- begin
- Result := d;
- m_pt1 := TPA1[i1];
- m_pt2 := TPA2[i2];
- end;
- end;
- end;
- end;
- function MSSL_TPADistanceToTPAEx2(TPA1, TPA2: TPointArray; method: (dtpClosest, dtpFarthest); var m_pts1, m_pts2: TPointArray): Integer;
- {==============================================================================]
- Created: November 5th, 2012.
- Updated: November 6th, 2012.
- Contributors: Janilabo
- Explanation: Returns the distance from TPA1 to TPA2.
- Contains 2 methods: dtpClosest (closest distance) & dtpFarthest (farthest distance)
- ALL matched (closest/farthest) points are stored to m_pts1 & m_pts2.
- Result is based on SCAR's Distance() function.
- [==============================================================================}
- var
- h1, i1, h2, i2, d, r: Integer;
- begin
- Result := -1;
- h1 := High(TPA1);
- h2 := High(TPA2);
- if ((h1 < 0) or (h2 < 0)) then
- Exit;
- Result := Distance(TPA1[0].X, TPA1[0].Y, TPA2[0].X, TPA2[0].Y);
- SetLength(m_pts1, (((h1 * h2) * 2) + 1));
- SetLength(m_pts2, (((h1 * h2) * 2) + 1));
- m_pts1[0] := TPA1[0];
- m_pts2[0] := TPA2[0];
- case method of
- dtpClosest:
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- d := Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y);
- if (d <= Result) then
- begin
- if (d < Result) then
- begin
- Result := d;
- r := 0;
- end;
- m_pts1[r] := TPA1[i1];
- m_pts2[r] := TPA2[i2];
- Inc(r);
- end;
- end;
- dtpFarthest:
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- d := Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y);
- if (d >= Result) then
- begin
- if (d > Result) then
- begin
- Result := d;
- r := 0;
- end;
- m_pts1[r] := TPA1[i1];
- m_pts2[r] := TPA2[i2];
- Inc(r);
- end;
- end;
- end;
- SetLength(m_pts1, r);
- SetLength(m_pts2, r);
- end;
- function MSSL_TPAInDistanceWithPt(TPA: TPointArray; p: TPoint; dist: Integer): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if point (p) is in distance (dist) with TPA.
- [==============================================================================}
- var
- h, i: Integer;
- begin
- h := High(TPA);
- if ((h > -1) and (dist >= 0)) then
- for i := 0 to h do
- begin
- Result := (Distance(TPA[i].X, TPA[i].Y, p.X, p.Y) <= dist);
- if Result then
- Break;
- end;
- end;
- function MSSL_TPAInDistanceWithPtEx(TPA: TPointArray; p: TPoint; dist: Integer; var m_pt: TPoint): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if point (p) is in distance (dist) with TPA.
- Stores the matched point to m_pt.
- [==============================================================================}
- var
- h, i: Integer;
- begin
- h := High(TPA);
- if ((h > -1) and (dist >= 0)) then
- for i := 0 to h do
- begin
- Result := (Distance(TPA[i].X, TPA[i].Y, p.X, p.Y) <= dist);
- if Result then
- begin
- m_pt := TPA[i];
- Break;
- end;
- end;
- end;
- function MSSL_TPAInDistanceWithPtEx2(TPA: TPointArray; p: TPoint; dist: Integer; var m_pts: TPointArray): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if point (p) is in distance (dist) with TPA.
- Stores ALL the matched points to m_pts.
- [==============================================================================}
- var
- h, i, r: Integer;
- begin
- h := High(TPA);
- if ((h > -1) and (dist >= 0)) then
- begin
- SetLength(m_pts, (h + 1));
- for i := 0 to h do
- begin
- if (Distance(TPA[i].X, TPA[i].Y, p.X, p.Y) <= dist) then
- begin
- m_pts[r] := TPA[i];
- Inc(r);
- end;
- end;
- Result := (r > 0);
- SetLength(m_pts, r);
- end;
- end;
- function MSSL_TPAInDistanceWithPt2(TPA: TPointArray; p: TPoint; minDist, maxDist: Integer): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if point (p) is in distance (minDist / maxDist) with TPA.
- [==============================================================================}
- var
- d, h, i: Integer;
- begin
- h := High(TPA);
- if ((h > -1) and (minDist >= 0) and (minDist <= maxDist)) then
- for i := 0 to h do
- begin
- d := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- Result := ((d >= minDist) and (d <= maxDist));
- if Result then
- Break;
- end;
- end;
- function MSSL_TPAInDistanceWithPt2Ex(TPA: TPointArray; p: TPoint; minDist, maxDist: Integer; var m_pt: TPoint): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if point (p) is in distance (minDist / maxDist) with TPA.
- Stores the matched point to m_pt.
- [==============================================================================}
- var
- d, h, i: Integer;
- begin
- h := High(TPA);
- if ((h > -1) and (minDist >= 0) and (minDist <= maxDist)) then
- for i := 0 to h do
- begin
- d := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- Result := ((d >= minDist) and (d <= maxDist));
- if Result then
- begin
- m_pt := TPA[i];
- Break;
- end;
- end;
- end;
- function MSSL_TPAInDistanceWithPt2Ex2(TPA: TPointArray; p: TPoint; minDist, maxDist: Integer; var m_pts: TPointArray): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if point (p) is in distance (minDist / maxDist) with TPA.
- Stores ALL the matched points to m_pts.
- [==============================================================================}
- var
- d, h, i, r: Integer;
- begin
- h := High(TPA);
- if ((h > -1) and (minDist >= 0) and (minDist <= maxDist)) then
- begin
- SetLength(m_pts, (h + 1));
- for i := 0 to h do
- begin
- d := Distance(TPA[i].X, TPA[i].Y, p.X, p.Y);
- if ((d >= minDist) and (d <= maxDist)) then
- begin
- m_pts[r] := TPA[i];
- Inc(r);
- end;
- end;
- Result := (r > 0);
- SetLength(m_pts, r);
- end;
- end;
- function MSSL_TPAInDistanceWithTPA(TPA1, TPA2: TPointArray; dist: Integer): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if TPA1 is in distance (dist) with TPA2.
- [==============================================================================}
- var
- h1, i1, h2, i2: Integer;
- begin
- h1 := High(TPA1);
- h2 := High(TPA2);
- if ((h1 > -1) and (h2 > -1) and (dist >= 0)) then
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- Result := (dist >= Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y));
- if Result then
- Break;
- end;
- end;
- function MSSL_TPAInDistanceWithTPAEx(TPA1, TPA2: TPointArray; dist: Integer; var m_pt1, m_pt2: TPoint): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if TPA1 is in distance (dist) with TPA2.
- Stores the matched points from TPAs to m_pt1 & m_pt2.
- [==============================================================================}
- var
- h1, i1, h2, i2: Integer;
- begin
- h1 := High(TPA1);
- h2 := High(TPA2);
- if ((h1 > -1) and (h2 > -1) and (dist >= 0)) then
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- Result := (dist >= Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y));
- if Result then
- begin
- m_pt1 := TPA1[i1];
- m_pt2 := TPA2[i2];
- Break;
- end;
- end;
- end;
- function MSSL_TPAInDistanceWithTPAEx2(TPA1, TPA2: TPointArray; dist: Integer; var m_pts1, m_pts2: TPointArray): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Updated: November 6th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if TPA1 is in distance (dist) with TPA2.
- Stores ALL the matched points from TPAs to m_pts1 & m_pts2.
- [==============================================================================}
- var
- h1, i1, h2, i2, r: Integer;
- begin
- h1 := High(TPA1);
- h2 := High(TPA2);
- if ((h1 > -1) and (h2 > -1) and (dist >= 0)) then
- begin
- SetLength(m_pts1, (((h1 * h2) * 2) + 1));
- SetLength(m_pts2, (((h1 * h2) * 2) + 1));
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- if (dist >= Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y)) then
- begin
- m_pts1[r] := TPA1[i1];
- m_pts2[r] := TPA2[i2];
- Inc(r);
- end;
- end;
- Result := (r > 0);
- SetLength(m_pts1, r);
- SetLength(m_pts2, r);
- end;
- end;
- function MSSL_TPAInDistanceWithTPA2(TPA1, TPA2: TPointArray; minDist, maxDist: Integer): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if TPA1 is in distance (minDist / maxDist) with TPA2.
- [==============================================================================}
- var
- d, h1, i1, h2, i2: Integer;
- begin
- h1 := High(TPA1);
- h2 := High(TPA2);
- if ((h1 > -1) and (h2 > -1) and (minDist >= 0) and (minDist <= maxDist)) then
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- d := Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y);
- Result := ((d >= minDist) and (d <= maxDist));
- if Result then
- Break;
- end;
- end;
- function MSSL_TPAInDistanceWithTPA2Ex(TPA1, TPA2: TPointArray; minDist, maxDist: Integer; var m_pt1, m_pt2: TPoint): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if TPA1 is in distance (minDist / maxDist) with TPA2.
- Stores the matched points from TPAs to m_pt1 & m_pt2.
- [==============================================================================}
- var
- d, h1, i1, h2, i2: Integer;
- begin
- h1 := High(TPA1);
- h2 := High(TPA2);
- if ((h1 > -1) and (h2 > -1) and (minDist >= 0) and (minDist <= maxDist)) then
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- d := Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y);
- Result := ((d >= minDist) and (d <= maxDist));
- if Result then
- begin
- m_pt1 := TPA1[i1];
- m_pt2 := TPA2[i2];
- Break;
- end;
- end;
- end;
- function MSSL_TPAInDistanceWithTPA2Ex2(TPA1, TPA2: TPointArray; minDist, maxDist: Integer; var m_pts1, m_pts2: TPointArray): Boolean;
- {==============================================================================]
- Created: November 5th, 2012.
- Updated: November 6th, 2012.
- Contributors: Janilabo
- Explanation: Returns true if TPA1 is in distance (minDist / maxDist) with TPA2.
- Stores ALL the matched points from TPAs to m_pts1 & m_pts2.
- [==============================================================================}
- var
- d, h1, i1, h2, i2, r: Integer;
- begin
- h1 := High(TPA1);
- h2 := High(TPA2);
- if ((h1 > -1) and (h2 > -1) and (minDist >= 0) and (minDist <= maxDist)) then
- begin
- SetLength(m_pts1, (((h1 * h2) * 2) + 1));
- SetLength(m_pts2, (((h1 * h2) * 2) + 1));
- for i1 := 0 to h1 do
- for i2 := 0 to h2 do
- begin
- d := Distance(TPA1[i1].X, TPA1[i1].Y, TPA2[i2].X, TPA2[i2].Y);
- if ((d >= minDist) and (d <= maxDist)) then
- begin
- m_pts1[r] := TPA1[i1];
- m_pts2[r] := TPA2[i2];
- Inc(r);
- end;
- end;
- Result := (r > 0);
- SetLength(m_pts1, r);
- SetLength(m_pts2, r);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment