CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 06:13:12 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=b62fd210c11b0ce819a74063216ca502ca3f749916556d4f8280f91bcae164d7a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22rD4rygk3KAjyZEvcHxBP012xrMSaKTqS%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cc35cd8c1d6cd6-BLR
Simple ConvexityDefects using concavehull - Pastebin.com
SHARE
TWEET

Simple ConvexityDefects using concavehull
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- EConvexityDefects = (cdNone, cdAll, cdMinimal);
- (*
- Finds the defects in relation to a convex hull of the given concave hull.
- cdAll -> Keeps all convex points as well.
- cdMinimal -> keeps the convex points that was linked to a defect
- cdNone -> Only defects
- *)
- function ConvexityDefects(ConcavePoly: TPointArray; Epsilon: Single; Mode:EConvexityDefects=cdNone): TPointArray;
- var
- x,y,i,j,k: Int32;
- dist, best: Single;
- pt: TPoint;
- convex: TPointArray;
- begin
- convex := ConcavePoly.ConvexHull();
- for x:=0 to High(ConcavePoly) do
- begin
- i := convex.IndexOf(ConcavePoly[x]);
- if i <> -1 then
- begin
- j := (i+1) mod Length(convex);
- y := ConcavePoly.IndexOf(convex[j]);
- best := 0;
- for k:=y to x do
- begin
- dist := DistToLine(ConcavePoly[k], convex[i], convex[j]);
- if (dist > best) then
- begin
- best := dist;
- pt := ConcavePoly[k];
- end;
- end;
- if best >= Epsilon then
- begin
- if (Mode = cdMinimal) and ((Length(Result) = 0) or (Result[High(Result)] <> convex[j])) then Result += convex[j];
- Result += pt;
- if Mode = cdMinimal then Result += convex[i];
- end;
- if Mode = cdAll then
- Result += convex[i];
- end;
- end;
- end;
- // original simpler function returns only defects
- function ConvexityDefects(ConcavePoly: TPointArray; Epsilon: Single): TPointArray;
- var
- x,y,i,j,k: Int32;
- dist, best: Single;
- pt: TPoint;
- convex: TPointArray;
- begin
- convex := ConcavePoly.ConvexHull();
- for x:=0 to High(ConcavePoly) do
- begin
- i := convex.IndexOf(ConcavePoly[x]);
- if i <> -1 then
- begin
- j := (i+1) mod Length(convex);
- y := ConcavePoly.IndexOf(convex[j]);
- best := 0;
- for k:=y to x do
- begin
- dist := DistToLine(ConcavePoly[k], convex[i], convex[j]);
- if (dist > best) then
- begin
- best := dist;
- pt := ConcavePoly[k];
- end;
- end;
- if best >= Epsilon then Result += pt;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 8 sec ago | 0.24 KB
-
✅⭐ Make $2500 in 15 minutes ✅ NEVER SEEN BEFO...
JavaScript | 17 sec ago | 0.24 KB
-
⭐✅ Trading Profit Method ✅ NEVER SEEN BEFORE...
JavaScript | 30 sec ago | 0.24 KB
-
⭐ Instant BTC Profit Method ✅ NEVER SEEN BEFO...
JavaScript | 43 sec ago | 0.24 KB
-
⭐✅ MAKE $2000 INSTANTLY ✅ NEVER SEEN BEFORE ⭐...
JavaScript | 52 sec ago | 0.24 KB
-
⭐ Free Crypto Method ✅ NEVER SEEN BEFORE ⭐⭐⭐
JavaScript | 1 min ago | 0.24 KB
-
✅⭐ Make huge profits on trading ✅ NEVER SEEN...
JavaScript | 1 min ago | 0.24 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 1 min ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand