473,396 Members | 1,666 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,396 software developers and data experts.

polygon filling

BSOB
77
im gone for a long weekend so plenty of time for anyone to answer.
if i have 4 points representing a polygon and each point is represented by an x and a y coordinate, is there an easy (or slightly less painfull) way to decide whether or not a point (a,b) lays within that polygon?

please note that this polygon DOES NOT take the shape of a square and has NO right angles and all side lengths are somewhat random.

the application:
say i wanted to draw a picture on the screen. i had the computer pick 8 random numbers (within screen limits) representing 4 random points. and now i want to fill in the area created by this polygon using point(x,y),z.
the polygon is convex in all situations. i also already know which points make up a side. for example, if there is point a, b, c, and d. I know a_b is a line, and b_c is a line, and c_d is a line and d_a is a line. i know which points are which so i can assume that point a has no relation to point c.

um.. yah, help?
Jul 19 '06 #1
6 3629
sashi
1,754 Expert 1GB
Hi BSOB,

enjoy your holiday for the time being.. have a great time out there.. hope to find a solution for your question.. take care my fren.. :)
Jul 19 '06 #2
BSOB
77
I have solved my problem with a simple few lines. If anyone is interested in my solution, post here and i will be happy to share it.
Jul 25 '06 #3
Kang
1
Hi, I really would like to know how you manage to solve that, been looking around on the web but so far still have no clue on how to do it. Thanks in advance.
Sep 6 '06 #4
please share the solution, for future projects.... thanks
Sep 6 '06 #5
BSOB
77
'in general declaration
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As PointLocation, ByVal nCount As Long) As Long
Public Type PointLocation
X As Long
Y As Long
End Type
Private m_Points(1 To 255) As PointLocation
m_Points(1).X = X1
m_Points(1).Y = Y1
m_Points(2).X = x2
m_Points(2).Y = y2
m_Points(3).X = X3
m_Points(3).Y = Y3
m_Points(4).X = X4
m_Points(4).Y = Y4
Polygon Me.hdc, m_Points(1), 4
'the 4 is the number of points of the polygon, you can set more points then 4 but you have to set values to those m_points x and y.


'it sets that polygon (i think only pixels entirly within borders) to the forecolor (or maybe it was fill color).

'if this doesnt work, let me know, ill see how i coded it.
Sep 8 '06 #6
BSOB
77
oh yah, and from m_points(x)=... and down
that isnt in general declaration any more, that is in your subroutine.
Sep 8 '06 #7

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...
2
by: Shamli | last post by:
I am looking for an algorithm that enlarge a 2D polygon. cheers,
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); }
3
by: jojo41300000 | last post by:
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...
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....
2
by: Swan666 | last post by:
I have a function which creates a polygon of blue color. I call this function inside a loop of 128 iterations. For every iteration, i change the value of x and y so that my polygon is rendered on new...
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.