@@ -217,17 +217,22 @@ procedure _LapeIsConvexPolygon(const Params: PParamArray; const Result: Pointer)
217
217
(*
218
218
TriangulatePolygon
219
219
-----------
220
- > function TriangulatePolygon(Polygon: TPointArray): TTriangleArray;
220
+ > function TriangulatePolygon(Polygon: TPointArray; MinArea: Double=0; MaxDepth: Int32=0 ): TTriangleArray;
221
221
222
222
Break the polygon into triangles, the smallest possible polygon. The order of the
223
223
input does matter, if it fails, try to reverse the Poly with Poly.Reversed()
224
224
225
225
This is a custom algorithm by slacky, based around the concept of trimming "ears",
226
226
if you dont like the output, you may have more luck with rolling the Polygon before calling.
227
+
228
+ Two default params exists as well, `MinArea` and `MaxDepth`, they work in tandom,
229
+ `MinArea` parameter is for setting a minimum size of triangles added to result, and as this method
230
+ works iteratively, removing triangles in a circle around the shape over and over, `MaxDepth` refers
231
+ to the max number of rounds it has moved around the shape before it ignores `MinArea` paramater.
227
232
*)
228
233
procedure _LapeTriangulatePolygon (const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV
229
234
begin
230
- PTriangleArray(Result)^ := TSimbaGeometry.TriangulatePolygon(PPointArray(Params^[0 ])^);
235
+ PTriangleArray(Result)^ := TSimbaGeometry.TriangulatePolygon(PPointArray(Params^[0 ])^, PSingle(Params^[ 1 ])^, PInt32(Params^[ 2 ])^ );
231
236
end ;
232
237
233
238
(*
@@ -428,7 +433,7 @@ procedure ImportMath(Compiler: TSimbaScript_Compiler);
428
433
addGlobalFunc(' function Modulo(const X, Y: Double): Double; overload' , @_LapeModuloF);
429
434
430
435
addGlobalFunc(' function IsConvexPolygon(const Polygon: TPointArray): Boolean' , @_LapeIsConvexPolygon);
431
- addGlobalFunc(' function TriangulatePolygon(const Polygon: TPointArray): TTriangleArray' , @_LapeTriangulatePolygon);
436
+ addGlobalFunc(' function TriangulatePolygon(const Polygon: TPointArray; MinArea: Single=0; MaxDepth: Int32=0 ): TTriangleArray' , @_LapeTriangulatePolygon);
432
437
addGlobalFunc(' function LineInPolygon(a1, a2: TPoint; const Polygon: TPointArray): Boolean' , @_LapeLineInPolygon);
433
438
434
439
addGlobalFunc(' function DeltaAngle(const DegreesA, DegreesB: Double; R: Double = 360): Double' , @_LapeDeltaAngle);
0 commit comments