471,092 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 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 3352
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

Post your reply

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

Similar topics

4 posts views Thread by lars.gundersen | last post: by
reply views Thread by =?Utf-8?B?U2ViYXN0aWFuIEZyw6Ruaw==?= | last post: by
8 posts views Thread by jpatchak | last post: by

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.