Jump to content
  • Advertisement
Sign in to follow this  
paulm19

Detecting closed spaces between lines

This topic is 4630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to figure out the best way of detecting enclosed spaces between lines, then computing the area of the encolosed space. I am using C# and I have a collection of lines that the user can draw onto the screen. I then need to detect any enclosed areas (think photoshop fill tool). Once I detect the enclosed areas I need to compute the area. I have a function that can compute the area of a polygon by passin in all it's points. Does anyone have any thoughts or suggestions on where to start?

Share this post


Link to post
Share on other sites
Advertisement
Start with Google or Wikipedia ;)

Point in Polygon: http://en.wikipedia.org/wiki/Point_in_polygon

That won't reliably detect the condition of a closed polygon. That's something you'd maintain during line-input from the user. So they use a menu command to start drawing a polygon and they click, click, click and you add those points to a buffer and when they are done you make the last point in the buffer the same as the first.

Detecting conditions like twistings (i.e. figure 8) are a separate issue. As are overlaps and cutouts, islands, etc, etc, etc.

The flood fill type operations, which work on polygons that aren't formalized (that is to say are just pixels on the screen) are done along scanlines and are intrinsically raster-based.

There is a HUGE amount of literature on these subjects out there on the web. You just need to learn a little of the jargon so you know what to search on and that Wikipedia article is as good a place as any to start.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!