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 7569751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:14:42+00:00 2026-05-30T15:14:42+00:00

I need the ability to determine which Shape a given point falls within. There

  • 0

I need the ability to determine which Shape a given point falls within. There will be overlapped shapes and I need to find the Shape with the smallest area. For example, given the Shapes and points illustrated in the image below the following would be true:

  • Point 3 – collides with star
  • Point 2 – collides with diamond
  • Point 1 – collides with circle

enter image description here

Given this, I would like to know if there is a built in way to do what is needed.

  • 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-05-30T15:14:43+00:00Added an answer on May 30, 2026 at 3:14 pm

    I’ve arrived at a solution that meets the requirements, still interested in hearing if there is a better way of doing this. My approach is as follows: do a hit-test by bounding box, then a geometric hit test based on the type of geometry.

    For Polygons, I’ve adapted the C code mentioned http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes /pnpoly.html to work in C#.

    int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
    {
      int i, j, c = 0;
      for (i = 0, j = nvert-1; i < nvert; j = i++) {
        if ( ((verty[i]>testy) != (verty[j]>testy)) &&
         (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
           c = !c;
      }
      return c;
    }
    

    For Ellipses, I’ve adaptated this code: http://msdn.microsoft.com/en-us/library/aa231172%28v=vs.60%29.aspx

    BOOL CCircCtrl::InCircle(CPoint& point)
    {
        CRect rc;
        GetClientRect(rc);
        GetDrawRect(&rc);
    
        // Determine radii
        double a = (rc.right - rc.left) / 2;
        double b = (rc.bottom - rc.top) / 2;
    
        // Determine x, y
        double x = point.x - (rc.left + rc.right) / 2;
        double y = point.y - (rc.top + rc.bottom) / 2;
    
        // Apply ellipse formula
        return ((x * x) / (a * a) + (y * y) / (b * b) <= 1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a Magento based webstore which will need the ability to: Allow
So I have a MultiSelect box with x values which I need the ability
I need the ability to sort a collection of customers which contains a property
I need ability to display content in Hex View, like this from WinHex Offset
I need the ability to run an arbitrary command when I try and commit
I need the ability to use custom locks at a session level (outside the
i am working on a small project that i need the ability to let
I have an app using a SQLite db, and I need the ability for
I was in need of the ability to create a PDF Envelope, and hadn't
Any recommended crypto libraries for Java. What I need is the ability to parse

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.