> The problem with the trapezoidal approach is that the shape I want to
> measure is irregular enough to make it difficult to find the point in
> the circle where there is "free sight" to all points on the edge. The
> angle will not always be less (or greater) than the last one, and I
> think the error will get too big.
>
Understood. And there might be a clever way to do this, but I thought
I'd give you obvious adhoc answer. If you don't get a better solution
and you end up writing this, the point really doesn't have to be near
the center of the circle, it just helps to think about it that way. You
can also take a point on the shape. Then, loop around doing the
triangles, detecting if the shape is complex and your point and
triangles overlap. If you detect it, pick another point, say the point
on the other side of the circle, and split the circle into two. The sum
of the areas is the same as the original area. You can also insert
points, say the midpoint on the new edge, near the center of the circle,
and attempt to use that point as your common triangle vertex. If you
write the VI to allow arbitrary splitting of any complex polygon into
simple ones and correctly sum their areas together, I think this will work.
I bet there is still a possibility that the final split makes two
triangles, both of which are simple, but they do have an overlap. For
this four pointed exception to the rule, you can compute new points at
intersection points and subtract out the duplicated triangle or the
triangle that isn't really a part of the interior of the shape. And in
fact, you can probably do this as you go around the circle without any
splitting of the shape.
I've done algorithms similar to this to determine if a point is on the
interior, edge, or exterior of an arbitrary polygon, and they do get
tricky. If you do end up implementing it, I'd suggest doing some
algorithm animation -- pretty easy in LV. Sometimes probing a strategic
point is useful, but othertimes, it is good to branch a wire off and
build an array of intermediate values. Copy the indicator, put the data
into another VI, and use a graph or picture control to loop through the
data visualizing what the algorithm accomplished in more detail to find
bugs or convince yourself of correctness.
Its also good to have test cases. Since you can take a smooth shape
with a known answer, like a circle or cardioid, and sample the shape,
you can then run the sampled points through your algorithm and see how
close you get to the canonical answer.
Greg McKaskle