Jump to content

Area within a curve - Green / Kelvin-Stokes Theorem


gyc

Recommended Posts

Hi there.

I need to compute the area within a closed shape (on XY plane) defined by an array of XY points (XY graph).

Can't find anything for labview related to this. (not using Vision, of course)

"splitting" the curve in two halves, integrating both along the diving (straight ) line and subtracting the resulting areas does not always yield a correct result because the shape may not always perfectly regular (check picture).

Any suggestions?

 

XY shape.png

Edited by gyc
Link to comment
On 12/01/2017 at 7:34 PM, infinitenothing said:

How accurate do you have to be? Maybe implement your own flood fill? Otherwise, you have to define some sort of point to point interpolation which could be as simple as defining a polygon

Accurate: not a problem. It depends on how many (x,y) points i have, so I can control that beforehand.

Floodfill: I am not working with images/pixels. (x,y) are actual floating point values in a measurement space.

This is green theorem (which in turn is a particular case of Kelvin-Stokes) but I can't seem to find anything in LV help.

Link to comment
On 12/01/2017 at 9:51 PM, Tim_S said:

Wat you are describing is the concept of an integral. Rather than sum up a large rectangle (which you don't have), you break up the object into little rectangles and sum those up.

Exactly, but I find it difficult to 'split' the figure into rectangles.

What I thought of is to split it into triangles, of which one vertex is the center of mass of the figure itself. (good old romans already did that!)

Link to comment

Ensegre, don't you need a convex polygon for that?

3 hours ago, gyc said:

Accurate: not a problem. It depends on how many (x,y) points i have, so I can control that beforehand.

Floodfill: I am not working with images/pixels. (x,y) are actual floating point values in a measurement space.

This is green theorem (which in turn is a particular case of Kelvin-Stokes) but I can't seem to find anything in LV help.

You could convert the vectors to discrete pixels using Bresenham's Algorithm

Link to comment
34 minutes ago, infinitenothing said:

Ensegre, don't you need a convex polygon for that?

No. https://en.wikipedia.org/wiki/Shoelace_formula, http://mathworld.wolfram.com/PolygonArea.html. Just with an alternative arrangement of the terms.

59 minutes ago, infinitenothing said:

You could convert the vectors to discrete pixels using Bresenham's Algorithm

You could if you want to rasterize your image. Do you need that?

  • Like 1
Link to comment
On 16/01/2017 at 5:52 PM, ensegre said:

Why arguing? If you have the coordinates you have the analytical solution. You may decompose it in summation of areas of oriented triangles with a common vertex (any point of the plane), or in trapezes based on the y axis, you will get to the same result.

area.png

Not arguing, just learning (always learning).

Excellent implementation, btw!

Link to comment
38 minutes ago, GregSands said:

In fact there's Polygon Area.vi in the Mathematics/Geometry/Computational Geometry palette.  Slightly different but equivalent implementation.  Typing "area" into Quick Drop found it immediately

Doh, completely right. That would be the first of the alternatives given in https://en.wikipedia.org/wiki/Shoelace_formula, plus argument checks. It occurred me to think that among the various alternatives, both the one I thought and this one are the most efficient needing only two array allocations and one multiplication. The determinant form in http://mathworld.wolfram.com/PolygonArea.html needs two.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.