MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Calculating the area surrounded by a closed contour curve.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35927] Re: Calculating the area surrounded by a closed contour curve.
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Thu, 8 Aug 2002 06:06:17 -0400 (EDT)
  • References: <aiqrui$4jf$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

For your example:

cn=ContourPlot[x^2+y^2,{x,-1.5,1.5},{y,-1.5,1.5},
    Contours->{1}]

Express the contour lines as explicit line obects.

gr=Graphics[cn]

Extract the point lists from the lines

lsts =Cases[gr,Line[pts_]:>pts, Infinity];

Code for area.

ClosedLineArea[pts_] :=
        (#1.RotateLeft[#2] - RotateLeft[#1].#2)&@@Transpose[pts]/2

Take the first, here the only, list of points and find the area.

ClosedLineArea[lsts[[1]]]

NOTE: in general you will have to deal many lines, some non-closed.

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Jun Lin" <jl_03824 at yahoo.com> wrote in message
news:aiqrui$4jf$1 at smc.vnet.net...
> Does anybody know how to calculate the area surrounded by a closed
> contour? For example, using ContourPlot[x^2+y^2,
> {x,-1.5,1.5},{y,-1.5,1.5},Contours->{1}], I create a circular contour
> of unity radius. How can I further calculate the area of the region
> surrounded by the contour? Thanks very much for your help.
>
> Jun Lin
>






  • Prev by Date: Re: How can I write inside the frame.
  • Next by Date: Determining whether a function is periodic
  • Previous by thread: Re: Calculating the area surrounded by a closed contour curve.
  • Next by thread: Coding of built in functions