polygon.bmx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ' ISC License
  2. '
  3. ' Copyright (c) 2023-2024, Bruce A Henderson
  4. '
  5. ' Permission to use, copy, modify, and/or distribute this software for any purpose
  6. ' with or without fee is hereby granted, provided that the above copyright notice
  7. ' and this permission notice appear in all copies.
  8. '
  9. ' THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  10. ' REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  11. ' FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. ' INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  13. ' OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. ' TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  15. ' THIS SOFTWARE.
  16. '
  17. SuperStrict
  18. Rem
  19. bbdoc: Math/Polygons
  20. End Rem
  21. Module Math.Polygon
  22. ModuleInfo "Version: 1.02"
  23. ModuleInfo "Author: Bruce A Henderson"
  24. ModuleInfo "License: ISC"
  25. ModuleInfo "earcut - Copyright: 2015 mapbox"
  26. ModuleInfo "Copyright: 2023-2024 Bruce A Henderson"
  27. ModuleInfo "History: 1.02"
  28. ModuleInfo "History: Update to Clipper 1.3.0.a4ae9e4"
  29. ModuleInfo "History: 1.01"
  30. ModuleInfo "History: Moved to Math.Polygon"
  31. ModuleInfo "History: 1.00"
  32. ModuleInfo "History: Initial Release"
  33. ModuleInfo "CPP_OPTS: -std=c++17"
  34. Import "common.bmx"
  35. Type TPolygonI
  36. Field path:Byte Ptr
  37. End Type
  38. Rem
  39. bbdoc: Runs a tesselation against a polygon #SVec2I array, returning a list of triangle indices.
  40. returns: An array of indices that refer to the vertices of the input polygon. Three subsequent indices form a triangle.
  41. End Rem
  42. Function TriangulatePoly:Int[](poly:SVec2I[])
  43. Return bmx_polygon_tri_svec2i(poly, poly.Length)
  44. End Function
  45. Rem
  46. bbdoc: Runs a tesselation against a polygon #SVec2F array, returning a list of triangle indices.
  47. returns: An array of indices that refer to the vertices of the input polygon. Three subsequent indices form a triangle.
  48. End Rem
  49. Function TriangulatePoly:Int[](poly:SVec2F[])
  50. Return bmx_polygon_tri_svec2f(poly, poly.Length)
  51. End Function
  52. Rem
  53. bbdoc: Runs a tesselation against a polygon #Float array, returning a list of triangle indices.
  54. returns: An array of indices that refer to the vertices of the input polygon. Three subsequent indices form a triangle.
  55. about: The array consists of pairs of x, y vertices. Output triangles are clockwise.
  56. End Rem
  57. Function TriangulatePoly:Int[](poly:Float[])
  58. Return bmx_polygon_tri_svec2f(poly, poly.Length / 2)
  59. End Function