Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8994007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:19:29+00:00 2026-06-15T23:19:29+00:00

Given a point and a set of arbitrary 2D entities (circles, polygons, lines, polylines,

  • 0

Given a point and a set of arbitrary 2D entities (circles, polygons, lines, polylines, arcs, etc.), does anyone know of existing strategies to:

  1. Determine if the point is enclosed (bounded) by any combination of entities? I know that it is easy enough to do an ‘inside’ test on the closed shapes, but this won’t always give me what I want – particularly with nested or intersecting shapes.

  2. Find the smallest (closest?) set of lines / entities that form a closed polygon around my point? (think of a flood-fill, but without relying on colour)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:19:30+00:00Added an answer on June 15, 2026 at 11:19 pm

    I’ve addressed this problem in a commercial product in the past. You’ve asked about analytic curves, but I’ll address it more generally for curves that are at least twice differentiable. Handle polygons as a set of separate line segments. There is no need to segment the curves, but if you want to you can and adapt the algorithm slightly.

    Also, you might want to see my paper Matrix-Based Ellipse Geometry in Graphics Gems V to find the intersections between your ellipses.

    Basic idea:

    1. Consider a ray from your test point in the +x direction.
    2. Now consider an ant walking along your ray from the test point.
    3. When the ant hits the first intersection with one of the curves, it makes the sharpest left it can, and leaves an arrow at that intersection indicating the direction it’s chosen. (If there is no intersection, then obviously the point isn’t bounded.)
    4. If it comes to the end of a curve, it doubles back on itself.
    5. If there are multiple curves intersecting at that point, it chooses the curve that is most to the left.
    6. If one or more of the curves is in fact tangent to the ray at the intersection, higher derivatives can be used decide which curve and direction to choose. (This ant knows calculus.)
    7. Now as the ant strolls along the curves, it always makes the biggest left turn it can as above. If there is tangency between curves at the intersection, use higher derivatives to decide the one that is “most to the left”. (Details are left to the ant).
    8. In its travels, the ant may come to the starting intersection with the ray multiple times. But as soon as it finds itself proceeding in the direction of the arrow (the one it left in step 3), it’s travels are done and it has traversed a “contour”. The problem is reduced to deciding if the point is in that contour.

    A “contour” is a topological entity. It’s closed ring of “segments” connected at “vertices”.

    A “segment” is a piece of a curve used by the contour in a particular direction.

    A “vertex” is a connection between segments. A vertex is associated with a (x, y) position on the plane, but there may be multiple vertices at the same position, one for each pair of segments in the contour that meet at that point. There is a vertex for each curve endpoint (a spur vertex), or curve-curve intersection encountered by the ant.

    A contour (in this context) is not a geometric entity! Don’t think of it as a simple closed path on the plane. The ant might go along a segment, get to the end, and go back the way it came–this is called a “spur” and includes two contour segments, one for either direction. Or it might go along one direction of a curve segment, wander around a bit along other curves, and return along the other direction of the segment.

    So even if your set of curves has only one line in it from A to B (I’m assuming you don’t have infinite lines) and your ray hits it at P, you still have the contour V0(P)-V1(A)-V2(P)-V3(B)-V0 with 4 segments V0-V1, V1-V2, V2-V3, V3-V0. Note that V0 and V2 are distinct vertices, both positioned at P.

    Now to test if your point is in the contour.

    Find the intersections of your ray (any ray originating at your test point will do) with the contour. We only really want the parity (even or odd) of the number of intersections with the contour. If the parity is odd, the point is bounded by the curves, if it’s even it’s not.

    Because doubly traversed segments contribute nothing to the parity, we can ignore them. This is because there are always an even number of intersections on doubly traversed segments, since they’re in the contour twice.

    Examples:

    Consider this curve set. I use lines so I don’t work too hard:

    Curve Set

    Case 1 – The point is not bounded. The contour’s use of the curve segments is indicated by the dotted arrows. The number of ray-contour intersection parity is even.

    Unbounded point

    Case 2 – The point is bounded. The ray-contour intersection parity is odd.

    Bounded point

    Here’s what can go wrong:

    1. You can’t find a contour for various numerical reasons. For example, you might miss intersections, e.g. two curves are almost tangent at a curve. You might see it as a single intersection, but when you do the ray intersection parity test you see a single crossing so that the parity flips when it shouldn’t.

    2. You might not be able to compute enough derivatives to make the correct turn decisions. In the case of analytic geometry this should never be the case.

    3. Your ray hits a vertex (connections between segments) of your contour. (Note that there can be multiple vertices at a single (x, y) point. Each of these has to be handled separately.)

    In this case, you have to decide if the incoming and outgoing segments of the vertex are on the same side of the ray at the vertex. If they’re on the same side, the parity is not affected. Otherwise the parity flips. If one of the curves is tangent to the ray at the vertex, you may have to use higher derivatives to decide this.

    1. A line segment is collinear with your test ray. This is actually a special case of 2, but easy to handle: Ignore it.

    There are lots of details, but you should be able to handle them. Be sure to use spatial trees to avoid computing unnecessary intersections.

    The answer to your second question comes from removing from the contour any doubly traversed segments. This may yield multiple sub-contours. One of them will contain your point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a set of points p , I would like to find a point
The given set of points is arbitrary and not something that will be constant,
Given a non-negative integer n and an arbitrary set of inequalities that are user-defined
I have a set of point (x,y) on a 2d plane. Given a point
I can draw a circle around a given point (x,y) with a command like
I'm trying to find rows which are within ____meters from the given point. THis
For given floating point numbers x and a , I would like to compute
Given a floating point number, I'm looking to get a String representation of a
Given a table where the first column is seconds past a certain reference point
Someone can point me reliable method to run given application in different session of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.