Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 169893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:42:42+00:00 2026-05-11T12:42:42+00:00

This question is a little involved. I wrote an algorithm for breaking up a

  • 0

This question is a little involved. I wrote an algorithm for breaking up a simple polygon into convex subpolygons, but now I’m having trouble proving that it’s not optimal (i.e. minimal number of convex polygons using Steiner points (added vertices)). My prof is adamant that it can’t be done with a greedy algorithm such as this one, but I can’t think of a counterexample.

So, if anyone can prove my algorithm is suboptimal (or optimal), I would appreciate it.

The easiest way to explain my algorithm with pictures (these are from an older suboptimal version)

What my algorithm does, is extends the line segments around the point i across until it hits a point on the opposite edge.

If there is no vertex within this range, it creates a new one (the red point) and connects to that:

If there is one or more vertices in the range, it connects to the closest one. This usually produces a decomposition with the fewest number of convex polygons:

However, in some cases it can fail — in the following figure, if it happens to connect the middle green line first, this will create an extra unneeded polygon. To this I propose double checking all the edges (diagonals) we’ve added, and check that they are all still necessary. If not, remove it:

In some cases, however, this is not enough. See this figure:

Replacing a-b and c-d with a-c would yield a better solution. In this scenario though, there’s no edges to remove so this poses a problem. In this case I suggest an order of preference: when deciding which vertex to connect a reflex vertex to, it should choose the vertex with the highest priority:

lowest) closest vertex

med) closest reflex vertex

highest) closest reflex that is also in range when working backwards (hard to explain) —

In this figure, we can see that the reflex vertex 9 chose to connect to 12 (because it was closest), when it would have been better to connect to 5. Both vertices 5 and 12 are in the range as defined by the extended line segments 10-9 and 8-9, but vertex 5 should be given preference because 9 is within the range given by 4-5 and 6-5, but NOT in the range given by 13-12 and 11-12. i.e., the edge 9-12 elimates the reflex vertex at 9, but does NOT eliminate the reflex vertex at 12, but it CAN eliminate the reflex vertex at 5, so 5 should be given preference.

It is possible that the edge 5-12 will still exist with this modified version, but it can be removed during post-processing.

Are there any cases I’ve missed?


Pseudo-code (requested by John Feminella) — this is missing the bits under Figures 3 and 5

assume vertices in `poly` are given in CCW order let 'good reflex' (better term??) mean that if poly[i] is being compared with poly[j], then poly[i] is in the range given by the rays poly[j-1], poly[j] and poly[j+1], poly[j]  for each vertex poly[i]     if poly[i] is reflex         find the closest point of intersection given by the ray starting at poly[i-1] and extending in the direction of poly[i] (call this lower bound)         repeat for the ray given by poly[i+1], poly[i] (call this upper bound)          if there are no vertices along boundary of the polygon in the range given by the upper and lower bounds             create a new vertex exactly half way between the lower and upper bound points (lower and upper will lie on the same edge)             connect poly[i] to this new point         else             iterate along the vertices in the range given by the lower and upper bounds, for each vertex poly[j]                 if poly[j] is a 'good reflex'                     if no other good reflexes have been found                         save it (overwrite any other vertex found)                     else                         if it is closer then the other good reflexes vertices, save it                 else                     if no good reflexes have been found and it is closer than the other vertices found, save it             connect poly[i] to the best candidate         repeat entire algorithm for both halves of the polygon that was just split // no reflex vertices found, then `poly` is convex save poly 

Turns out there is one more case I didn’t anticipate: [Figure 5]

My algorithm will attempt to connect vertex 1 to 4, unless I add another check to make sure it can. So I propose stuffing everything ‘in the range’ onto a priority queue using the priority scheme I mentioned above, then take the highest priority one, check if it can connect, if not, pop it off and use the next. I think this makes my algorithm O(r n log n) if I optimize it right.


I’ve put together a website that loosely describes my findings. I tend to move stuff around, so get it while it’s hot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:42:42+00:00Added an answer on May 11, 2026 at 12:42 pm

    I believe the regular five pointed star (e.g. with alternating points having collinear segments) is the counterexample you seek.

    Edit in response to comments

    In light of my revised understanding, a revised answer: try an acute five pointed star (e.g. one with arms sufficiently narrow that only the three points comprising the arm opposite the reflex point you are working on are within the range considered ‘good reflex points’). At least working through it on paper it appears to give more than the optimal. However, a final reading of your code has me wondering: what do you mean by ‘closest’ (i.e. closest to what)?

    Note

    Even though my answer was accepted, it isn’t the counter example we initially thought. As @Mark points out in the comments, it goes from four to five at exactly the same time as the optimal does.

    Flip-flop, flip flop

    On further reflection, I think I was right after all. The optimal bound of four can be retained in a acute star by simply assuring that one pair of arms have collinear edges. But the algorithm finds five, even with the patch up.

    I get this:

    removing dead ImageShack link

    When the optimal is this:

    removing dead ImageShack link

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 108k
  • Answers 108k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Six minutes later, I find the answer to my own… May 11, 2026 at 9:14 pm
  • Editorial Team
    Editorial Team added an answer Will, WebTestRequest and WebTestResponse aren't designed to be used like… May 11, 2026 at 9:14 pm
  • Editorial Team
    Editorial Team added an answer public List<T> FindOpenWindows<T>(Predicate<T> constraint) where T : Form { var… May 11, 2026 at 9:14 pm

Related Questions

I want to write something like Skype, i.e. I have a constant audio stream
I've been a web developer for some time now, and have recently started learning
So, I'm getting more and more engulfed with test driven development these days and
I have recently been put in charge of debugging two different programs which will

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.