1 / 16

Grids to shapes

Grids to shapes. A small algorithmic problem. How to turn this grid. into these shapes?. Shapes are modelled as polygonal parts, and parts as closed sequences of points, connected by straight lines, clockwise for the outer perimeter, and anticlockwise for any holes.

kaylee
Télécharger la présentation

Grids to shapes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Grids to shapes A small algorithmic problem

  2. How to turn this grid into these shapes? Shapes are modelled as polygonal parts, and parts as closed sequences of points, connected by straight lines, clockwise for the outer perimeter, and anticlockwise for any holes. Assuming the lower left corner is the origin, and that the grid squares are unit sized, the shapes in the second diagram can be defined as: 1 (Yellow): Part 1: [(0,0), (0,5), (5,5), (5, 0), (0,0)], [(1,1), (4,1), (4,4), (1,4), (1,1)] Part 2: [(2,2), (2,3), (3,3), (3,2), (2,2)] 2 (Blue): Part 1: [(1,1), (1,4), (4,4), (4,1), (1,1)], [(2,2), (3,2), (3,3), (2,3), (2,2)] In practice there can easily be 2 million grid squares containing a thousand different values. We need to be efficient!

  3. Step 1: Make horizontal boxes 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1 Boxes are modelled as closed clockwise sequences of unit vectors.

  4. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  5. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  6. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  7. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  8. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  9. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  10. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  11. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  12. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  13. Step 2: Join boxes of the same valueby removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  14. Step 2: Join boxes of the same value by removing adjacent complementary vectors 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1 How many polygons are there?

  15. Step 3: Make holes by removing complementary pairs within the same box 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1

  16. Almost done! 1 1 1 1 1 1 2 2 2 1 1 2 1 2 1 1 2 2 2 1 1 1 1 1 1 All we have to do now is mark the vertices in the order of the arrows: Green: Part 1: [(0,4), (0,5), (5,5), (5, 0), (0,0), (0,4)], [(1,1), (4,1), (4,4), (1,4), (1,1)] Part 2: [(2,2), (2,3), (3,3), (3,2), (2,2)] Blue: Part 1: [(1,3), (1,4), (4,4), (4,1), (1,1), (1,3)], [(2,2), (3,2), (3,3), (2,3), (2,2)]

More Related