How to form a Concave shape out of Convex shapes?

前端 未结 5 1627
故里飘歌
故里飘歌 2021-01-31 23:34

i\'m trying to get around the rule of only being able to form convex shapes in the SFML c++ library.

To do this I\'m planning on testing given vertices,

5条回答
  •  北海茫月
    2021-02-01 00:11

    The Boost Geometry library that was published yesterday, has an implementation of Convex Hull algorithm. A picture says more than a thousand words:

    enter image description here

    Although this constructs a 'new' shape that is non-concave (i.e. convex); This may or may not be precisely what you want. However, in the process the algorithm is bound to be able to classify shape a concave/convex, so you'd likely be interested in the library nonetheless.

    General information on convex hull algorithm:

    • http://en.wikipedia.org/wiki/Convex_hull
    • http://en.wikipedia.org/wiki/Convex_hull_algorithms

    Since Adrian Japon more or less suggested that 'hit testing' (containment test) is of a usual reason to care about convex/concave geometries, without further ado, I'll highlight the corresponding Boost Geometry algorithm for that: within.

    Again, really because the picture is so pretty. Note that though the picture suggests querying for a point against a polygon, the algorithms are fully generic and can be used to test complete containment on n-dimensional polygons in another

    enter image description here

提交回复
热议问题