Jump to content
  • Advertisement
Sign in to follow this  
Striken

Point in (skewed) circle sector

This topic is 3408 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I have two circles - one inside the other, and I need to and I'm trying to figure out which sector (of which circle) a given point is inside. The obvious easy scenario is when one circle is perfectly centered within another; but if the inner circle isn't centered, how do I find out what I want to know? The sector edges are (2pi / #sectors) on the circumference on the outer circle. Diagram to explain: Image Hosted by ImageShack.us<br/> Thanks - I'd very much appreciate any tips / pointers in the right direction!

Share this post


Link to post
Share on other sites
Advertisement
Off-the-top-of-my-head solution:

1. Run point-in-circle tests on the given point for both circles. This will tell you if the point is outside both circles, inside the larger circle but not the smaller circle, or inside both.

2. Construct hyperplanes corresponding to each of the 'spokes' that define the sectors. These will be lines in the form ax+by+d = 0. (Post back if you're not sure how to do this.)

3. Each consecutive pair of hyperplanes forms an unbounded triangle. For each of these triangles, test the point for inclusion by performing a 'which side' test against each of the two bounding hyperplanes.

You now have enough info to determine which circle and sector (if any) the point is in (assuming I didn't mess anything up).

Post back if you have any questions about this.

Share this post


Link to post
Share on other sites
You can also use the CCW function to determine on which side of a spoke you are

From http://www.macs.hw.ac.uk/~alison/ds98/node114.html :
int ccw(point p1, point p2, point p3)

// Slightly deficient function to determine if the two lines p1, p2 and
// p2, p3 turn in counter clockwise direction}
{
int dx1, dx2, dy1, dy2;
dx1 = p2.x - p1.x; dy1 = p2.y - p1.y;
dx2 = p3.x - p2.x; dy2 = p3.y - p2.y;
if(dy1*dx2 < dy2*dx1) return 1;
else return 0;
}

Share this post


Link to post
Share on other sites
Thanks for the ideas - I hadn't even thought about just performing a above/below plane test, that seems in theory to be the best way to tackle this.

Much appreciated :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!