Re: Novice 2D question: How to find points in a convex hull/polygon in a 2D grid (including points on the border) ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Not DX related, but perhaps a normal polygon rasterizing algorithm can do
the job?

Wessam Bahnassi
Microsoft DirectX MVP,
Lead Programmer
In|Framez

<aredo3604gif@xxxxxxxxx> wrote in message
news:limd51lpaakrfmh7ii6fea5sqvnskqnsvo@xxxxxxxxxx
>I don't have knowledge of texturing and 3D algorithms but I have to
> solve an issue for a program.
> On a integer coordinates 2D grid world I have to determine which
> points lie inside a convex hull/polygon. The convex hull vertex lists
> is given and already known in clockwise order.
> Now, I looked at Andrew, QuickHull, Graham Scan and such but I
> couldn't find any example to reverse the problem. Graham Scan actually
> checks all the points in a set to find the convex hull but I already
> got the convex hull and what I need is a way to do the reverse that
> Graham Scan does. I need to build up a list of elements inside the
> convex hull that lie on 2D grid points and their maximum number (the
> area made of 2D grid points in practice) including those that lie on
> the convex hull border (between any two vertices of the convex hull
> the 2D grid points that lie on the line joining them).
> I thought about the fact that if Graham Scan could be inverted it
> would automatically give me the number of maximum elements that could
> be contained within the convex hull as well as the list of of them,
> right ? But I couldn't find any example, not even pseucode ones to
> invert Graham Scan to obtain what I need.
>
> I tried using a cross-product approach by scanning the minimum
> rectangle of 2D grid points enclosing the convex polygon:
> E = vertex[i+1] - vertex[i]
> V = P - vertex[i]
> S = sign of (E x V)
>
> with S that should be 0 if it's on the border, and changes from -1 to
> +1 (negative to positive or viceversa) if it's outside the polygon,
> otherwise if the sign doesn't change it's inside it,right?
>
> ...but whenever I have an edge, a border line, that's aligned
> vertically or horizontally to the grid any test involving vertices
> from that edge to the point gives wrong results, with S=0 when a point
> it's not on the border as well as misdetecting vertices themselves.
> Why doesn't cross-product work ? Is the implementation wrong ? And if
> yes, what's the correct one to ensure proper detection of point
> inside/outside/on border ?
>
> What should I use ? Dot product instead ? Or any better approach? I
> need to detect grid points on the boundary of the polygon/convex hull
> (which means adding the vertices themselves to the list of points
> inside it/on the border)
>
>
> Could anyone please help me about how to solve this ?
> Thanks.


.



Relevant Pages

  • Novice 2D question: How to find points in a convex hull/polygon in a 2D grid (including points on t
    ... Now, I looked at Andrew, QuickHull, Graham Scan and such but I ... checks all the points in a set to find the convex hull but I already ... convex hull that lie on 2D grid points and their maximum number (the ... with S that should be 0 if it's on the border, ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Novice 2D question: How to find points in a convex hull/polygon in a 2D grid (including points
    ... I looked up what a hull was and from your description this ... point is inside or on the border, ... > checks all the points in a set to find the convex hull but I already ... > convex hull that lie on 2D grid points and their maximum number (the ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Creating a shape from a set of points
    ... I have a bunch of points ... Are you looking for the convex hull? ... Polygon is a particularly convenient ... home dot woh dot rr dot com slash jbmatthews ...
    (comp.lang.java.programmer)
  • Re: modification of convex hull
    ... polygon X which contains all points of P. ... don't know how to reduce properly it's number of verticies. ... Perhaps you can say why you were disappointed by starting with the convex hull and reducing it. ... did you experiment with different criteria for choosing the edge to eliminate? ...
    (comp.graphics.algorithms)
  • Re: Arrange points so polygon is not self intersecting
    ... Call your set of points S. Find the convex hull of S. ... form a polygon with non-intersecting sides. ... If the C language implements the type long long int ... typedef long long int2; ...
    (sci.math)