Eli Brosh wrote:
Hello,
I have an interesting problem and I hope it is possible to solve it
using sage.
I have a scanned digitized graph of a magnetic hysteresis loop.
That is, I have a list of points [(H0,B0),(H1,B1)....(Hn,Bn)]
however, the points are not ordered in any meaningful way.
In order to calculate the hysteresis loss, which is the area enclosed by
the loop, I need to somehow convert the list of points into a polyngon
(clockwise or counterclockwise).
I am not sure about the definition of this polygon.
Perhaps it is a simple polygon (not intersecting) which includes all the
points in the list as vertices and encloses the maximum area.
Is there some algorithm that does it ?
Is there such a thing in sage ?

I don't think so. But maybe sage can help (as Python) with a naive approach.

If you have a closed polygon of n points with (x_n, y_n) = (x_0, y_0)
the area can be calculated with a well known(?) formula
A = 1/2 sum from i=0 to i=n-1 (y_{i+1} - y_i)(x_{i+1} + x_i)

First we sort the data set in increasing order on the first coordinate
that will give us (x_0, y_0).

Stepping through the data set we try to split it up in two parts.

If x_{i+1} = x_i and abs(y_{i+1} - y_i) < some small value we throw away
that datapoint else we move the point with the larger y value to data set 2.

If y_{i+1} - y_i > a(x_{i+1} - x_i) for some a(?) we move the
point to data set 2 else we keep it in what we call data set 1.

Now we sort data set 2 in decreasing order and put 1 and 2 together.

The formula above gives us the area.

This looks very naive and simplistic, but I hope this helps,

Jaap



--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to