We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › how to know if a group of points are inside circle
Page Index Toggle Pages: 1
how to know if a group of points are inside circle (Read 550 times)
how to know if a group of points are inside circle
Apr 26th, 2010, 9:24am
 
hello, how can i know if a group of points are inside a circle?

For example if i have a program that consist on a random points or agents moving randomly and an ellipse, how can i know which points are inside my ellipse?

is there any specific approach for making this?

and my second question is how, about if i dont have a sphere but a irregular form, how can i know the points that are inside the irregular form?

thanks

M.
Re: how to know if a group of points are inside circle
Reply #1 - Apr 26th, 2010, 9:43am
 
Moving target, there... Let's address them.

- Point in circle?
-> dist(point, center of circle) < radius of circle

- Point in ellipse?
-> Not sure, but there must be a formula for that...

- Point in sphere?
We are going 3D?

- Point in irregular form?
2D or 3D?
3D should be fairly hard...
2D with arbitrary shape can be solved the classical way: draw the shape in a PGraphics with some color. Do drawnShape.get(pointToTestX, pointToTestY). If that's the drawing color, the point is in the shape.
Page Index Toggle Pages: 1