comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: problem computing area
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: problem computing area [message #68123] Mon, 05 October 2009 17:56
aetherlux is currently offline  aetherlux
Messages: 12
Registered: July 2006
Junior Member
On Oct 5, 9:02 am, jameskuyper <jameskuy...@verizon.net> wrote:
> aetherlux wrote:
>> Hi everybody,
>
>> I am trying to compute the area of this figure with
>> IDLanROI:ComputeGeometry
>
>> http://juan.gulo.org/area2.png
>
>> but I obtain a negative area. I have checked it and there is not lines
>> crossing over others. For the "horizontal" part of the figure the line
>> begins and finishes in negative values of "y" (that is, the first and
>> last point), but is it a problem?
>
>> Ideas? I have been looking at it all the weekend but I don't have any
>> clue about the possible problem.
>
> A closed planar curve can represent either the area inside the curve,
> or the area outside the curve; the distinction is typically
> represented by listing the points either in the clockwise or counter-
> clockwise order around the curve. I'm not sure which convention is
> used by IDLanROI. The formula usually used for calculating the area
> gives you a positive value when the points are in the correct order,
> and a negative value of the same magnitude when the points are in the
> wrong order. If the number you are getting seems to have the correct
> size, but the wrong sign, you may simply have listed the points on the
> curve in the wrong order.
>
> If the size of the number is wrong, then you have some other problem.
> For instance, the points on the upper parabolic curve must be listed
> in the opposite order of x values, than the points on the bottom
> curve; if the upper one is in the wrong order, you'll get a negative
> number, but one that is not simply the negative of the correct number.
>
> In order to figure out what really is going wrong here, we need to see
> how your code for creating the IDLanROI object - which is what David
> was elliptically referring to.

After applying "reverse" of the x and y vectors I have obtained a
correct positive area. It is weird. I have tested this routine with a
bunch of different contours working in the same way and the area is
positive without need of being counter-clockwise.

So, although I have not a clear idea about what was going wrong, now
it is solved.

Thank you very much.
Re: problem computing area [message #68129 is a reply to message #68123] Mon, 05 October 2009 08:02 Go to previous message
jameskuyper is currently offline  jameskuyper
Messages: 79
Registered: October 2007
Member
aetherlux wrote:
> Hi everybody,
>
> I am trying to compute the area of this figure with
> IDLanROI:ComputeGeometry
>
> http://juan.gulo.org/area2.png
>
> but I obtain a negative area. I have checked it and there is not lines
> crossing over others. For the "horizontal" part of the figure the line
> begins and finishes in negative values of "y" (that is, the first and
> last point), but is it a problem?
>
> Ideas? I have been looking at it all the weekend but I don't have any
> clue about the possible problem.

A closed planar curve can represent either the area inside the curve,
or the area outside the curve; the distinction is typically
represented by listing the points either in the clockwise or counter-
clockwise order around the curve. I'm not sure which convention is
used by IDLanROI. The formula usually used for calculating the area
gives you a positive value when the points are in the correct order,
and a negative value of the same magnitude when the points are in the
wrong order. If the number you are getting seems to have the correct
size, but the wrong sign, you may simply have listed the points on the
curve in the wrong order.

If the size of the number is wrong, then you have some other problem.
For instance, the points on the upper parabolic curve must be listed
in the opposite order of x values, than the points on the bottom
curve; if the upper one is in the wrong order, you'll get a negative
number, but one that is not simply the negative of the correct number.

In order to figure out what really is going wrong here, we need to see
how your code for creating the IDLanROI object - which is what David
was elliptically referring to.
Re: problem computing area [message #68134 is a reply to message #68129] Mon, 05 October 2009 05:05 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
aetherlux writes:

> I am trying to compute the area of this figure with
> IDLanROI:ComputeGeometry
>
> http://juan.gulo.org/area2.png
>
> but I obtain a negative area. I have checked it and there is not lines
> crossing over others. For the "horizontal" part of the figure the line
> begins and finishes in negative values of "y" (that is, the first and
> last point), but is it a problem?
>
> Ideas? I have been looking at it all the weekend but I don't have any
> clue about the possible problem.

The code you are using is incorrect. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Slow GUI on linux
Next Topic: Earn Free cash From DoEarn

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 16:00:38 PDT 2025

Total time taken to generate the page: 0.00456 seconds