Loading...
Logo
Processing Forum

contour operations

in General Discussion  •  Other  •  7 months ago  
Hi!

Is there a way to know if a given point (x,y) or another contour is inside a given contour? or shape?

Is there a way to know the surface delimited by a given contour? or shape?

Thanks in advance!

Replies(4)

Re: contour operations

7 months ago
It is not clear what your definition of the difference between a contour and a shape would be. What is it?

I am going to work on the assumption that both contour and shape are in fact the same i.e. a continuous line in 2D space where the two ends are connected and the line does not intersect with itself and I will call this a shape

If that is the case then there are techniques to determine whether a point (x,y) is inside or outside a shape.

When considering two shapes there are 3 outcomes.
  1. they intersect
  2. they are separate
  3. one totally surrounds the other
again there are techniques for determining which outcone.

The second question is equally unclear, what do you mean by surface. I would think this a 3D artifact, if it is generated by moving or rotating a shape in 3D space then again the answer is yes.

The actual techniques depend on the type of data structures used to define the shape

Re: contour operations

7 months ago
Hi

In my understanding, in Processing, a shape is a non self-intersecting closed curve, as you defined it, and a contour is a collection of such curves, with some area of the total workspace being the "inside" and the rest being the "outside".

Anyway, I am indeed interested in knowing what is the outcome 1,2, or 3 in your propositions.

In my second question, the surface is a number, maybe I should say the "area" (I translate from the french, sorry). For instance the area of a square ,which sidelength is 1, is 1, the area of a circle with radius 1 is pi, etc...

Re: contour operations

7 months ago
Ok I undertsand now - thanks for the explaination.

A good approach would be to find a library that will do what you want, there is toxiclibs - which I know is popular but I can't promise it will provide all you need, otherwise you might look further afield for a suitable Java library that you could use in Processing.

Re: contour operations

7 months ago
thank YOU for your response. I might actually program it myself, I was looking for some kind of built-in solution...