Skip to content

thi.ng.geom.polygon/tesselate* sometimes returns nil for certain pt orderings of polygons #91

@harold

Description

@harold

Hi, first- thanks to all involved, this library continues to boggle the brain and delight the heart. I love it and am so grateful for all the efforts of all involved.

I was extruding some polygons, and sometimes the caps were missing, and I believe the root cause to be related to this:

> (def pts [[-0.040626499149128546 -2.1993343273656203]
            [-0.5189426962437235 -2.6776505244602133]
            [-0.9972588933383101 -3.155966721554806]
            [-1.6506509696110883 -2.9808908423766187]
            [-2.128967166705682 -3.4592070394712198]
            [-0.8221830141601257 -3.8093587978275822]
            [0.13444938002906096 -2.8527264036383966]])
#'pts
> (p/tessellate* (p/polygon2 pts))
nil ;; Uh oh!
> (def pt-n (count pts))
#'pt-n
> (p/tessellate* (p/polygon2 (take pt-n (drop 1 (cycle pts)))))
nil
> (p/tessellate* (p/polygon2 (take pt-n (drop 2 (cycle pts)))))
nil
> (p/tessellate* (p/polygon2 (take pt-n (drop 3 (cycle pts)))))
nil
;; But wait, then this happens (!)
> (p/tessellate* (p/polygon2 (take pt-n (drop 4 (cycle pts)))))
[[[-1.6506509696110883 -2.9808908423766187]
  [-2.128967166705682 -3.4592070394712198]
  [-0.8221830141601257 -3.8093587978275822]]
 [[-0.8221830141601257 -3.8093587978275822]
  [0.13444938002906096 -2.8527264036383966]
  [-0.040626499149128546 -2.1993343273656203]]
 [[-0.9972588933383101 -3.155966721554806]
  [-1.6506509696110883 -2.9808908423766187]
  [-0.8221830141601257 -3.8093587978275822]]
 [[-0.8221830141601257 -3.8093587978275822]
  [-0.040626499149128546 -2.1993343273656203]
  [-0.5189426962437235 -2.6776505244602133]]
 [[-0.5189426962437235 -2.6776505244602133]
  [-0.9972588933383101 -3.155966721554806]
  [-0.8221830141601257 -3.8093587978275822]]]
> (p/tessellate* (p/polygon2 (take pt-n (drop 5 (cycle pts)))))
nil
> (p/tessellate* (p/polygon2 (take pt-n (drop 6 (cycle pts)))))
[[[-0.8221830141601257 -3.8093587978275822]
  [0.13444938002906096 -2.8527264036383966]
  [-0.040626499149128546 -2.1993343273656203]]
 [[-0.9972588933383101 -3.155966721554806]
  [-1.6506509696110883 -2.9808908423766187]
  [-2.128967166705682 -3.4592070394712198]]
 [[-0.8221830141601257 -3.8093587978275822]
  [-0.040626499149128546 -2.1993343273656203]
  [-0.5189426962437235 -2.6776505244602133]]
 [[-0.9972588933383101 -3.155966721554806]
  [-2.128967166705682 -3.4592070394712198]
  [-0.8221830141601257 -3.8093587978275822]]
 [[-0.8221830141601257 -3.8093587978275822]
  [-0.5189426962437235 -2.6776505244602133]
  [-0.9972588933383101 -3.155966721554806]]]
> (p/tessellate* (p/polygon2 (take pt-n (drop 7 (cycle pts)))))
nil

IIUC (and that's a stretch!), the tessellation shouldn't depend on the where we start in the list of points?

I've got a workaround going based on the idea in that listing, so I'm off and running.

Regardless, thanks again for your time and consideration. Stay rad.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions