473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to get the points inside the polygon?

Hi,

Is anyone know that how to get the x and y points inside the polygon using C++ program?

I have the given polygon data to draw the polygon, but i don't know how to get all the points inside the polygon.

Eg. Let's say we have 5 points to draw a polygon.
Expand|Select|Wrap|Line Numbers
  1.                  Polygon
  2.                   ---------------------
  3.                  |  Region A          /
  4.                  |                   \
  5.                  \--------------------  
  6.  
In above polygon, I am trying to get all the integer points(x and y coordinates) inside the polygon.

Above polygon is just to show you as example. In reality, the polygon is not that simple and really complex.


Any algorithm or ideas to get the points?

Thanks.

-Jason
Aug 21 '07 #1
3 6114
RRick
463 Expert 256MB
What you're describing is a polygon fill technique used in computer graphics. One of the most common fill algorithms is the scan-line algorithm. Also, there are different ways to define polygons that allows you to define polygons with holes and self intersections. A book on basic computer graphics algorithms should have a chapter or two devoted to this topic.

The general purpose scan algorithms use a list of edges (or buckets) to define the line segments inside a polygon for each integer line that intersects the polygon. This technique should be good for integer or double sized vertices. There are a lot of variations on this algorithm so find one that fits your needs. There is probably a graphics library out there with a scan algorithm that you use and/or modify.
Aug 21 '07 #2
What you're describing is a polygon fill technique used in computer graphics. One of the most common fill algorithms is the scan-line algorithm. Also, there are different ways to define polygons that allows you to define polygons with holes and self intersections. A book on basic computer graphics algorithms should have a chapter or two devoted to this topic.

The general purpose scan algorithms use a list of edges (or buckets) to define the line segments inside a polygon for each integer line that intersects the polygon. This technique should be good for integer or double sized vertices. There are a lot of variations on this algorithm so find one that fits your needs. There is probably a graphics library out there with a scan algorithm that you use and/or modify.
Thanks alot. I
The algorithm works only on kind of simple polygon.
It doesn't fill completely to very complex (self intersecting) polygon.

Is there any idea why it doesn't fill completely? ( I use polygon fill alg)
Aug 28 '07 #3
RRick
463 Expert 256MB
It all depends on the algorithm. Some algorithms make assumptions about the polygon for simplicity and calculations. There is definitely more than one polygon fill algorithm.

Also, there are two schools of thought on self intersecting polygons. One says to switch the interior fill on and off as each intersection line is crossed. This results in a complex polygon with interior holes. The other idea says that all of the interior should be filled no matter how many times the polygon intersects itself.

While it is nice to have the most capable and complex algorithm available, sometimes its better to get the simplest one that does the job.
Aug 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: paul | last post by:
library for querying virtual polygon over raster spatial data in my c++ application, after calculating my polygon i wish to define it (simple 4 sided polygon with floats or line parameters) and...
1
by: G.A.Mashaqbeh via DotNetMonster.com | last post by:
can anybody help me?? using the mouse i let the user to draw a shape about a set of points, i want to define the points enclosed within this shape, the shape is irregular, i have saved all the...
6
by: ljlevend | last post by:
In my app the user can draw an arbitrary path onto an image. Now I need to determine all of the pixels that are contained within that path. Note that the path can intersect itself and I can...
4
by: lars.gundersen | last post by:
I need to find some kind of polygon map search JavaScript that allows me to draw a polygon on a map an passed it on so i can define a search from the coordinates Have anyone see any sites using...
1
by: jojojjose | last post by:
function draw() { var s=''; s+='<v:polygon points="'; s+= //points from server s+="> </v:polygon>'"; document.wrie(s); }
1
by: farooq.omar | last post by:
I have a list of points (point array) and I want to create a polygon using the graphics path addPolygon routine. Is there a way to sort/ arrange the points in a clockwise manner so that the polygon...
3
by: friendkitty | last post by:
Hi All, I m a new member here.I am now writing a program that render Vertex Normals.I m now trying to implement a data structure that will best suit computing vertex normals.For that computation ,...
0
by: =?Utf-8?B?U2ViYXN0aWFuIEZyw6Ruaw==?= | last post by:
In several locations in the MSDN Mappoint Web Service SDK it says: "Creating Polygons There are several ways you can create and prepare polygon data for upload to the Customer Service Site: 1....
8
by: jpatchak | last post by:
Hello, I am having a problem using intersects method of a class I made that extends Polygon. Basically, I am trying to write code that allows the user to drag these polygons. I create a 1x1...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.