MathGroup Archive 2003

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

Search the Archive

RE: Pick up coordinates along different contours.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43399] RE: [mg43382] Pick up coordinates along different contours.
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 29 Aug 2003 07:15:59 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Jun,

You can extract the points by digging into the graphics. Here is an example.

f[x_, y_] := x^2 + y^2

plot1 = ContourPlot[f[x, y], {x, -1.5, 1.5}, {y, -1.5, 1.5},
    Contours -> {0.5, 1.0}, ContourShading -> False]

Now if we convert plot1 from ContourGraphics to Graphics we will obtain
Lines for the contours, which we can then extract using Cases.

clines = Cases[First[Graphics[plot1]], Line[_], Infinity]

You will notice that this contains a number of spurious lines that contain
only one point or the same point repeated. We can massage clines to get rid
of these cases.

clines2 =
  clines /.
        Line[{begin___List, a_List, b_List, end___List}] /;
            Sqrt[(a - b).(a - b)] < 10.*^-10 -> Line[{begin, end}] /.
      Line[{}] -> Sequence[] /. Line[{a_}] -> Sequence[]

Then you can extract the points themselves with

points = Cases[clines2, Line[pts_] -> pts, Infinity]

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: Jun Lin [mailto:jl_03824 at yahoo.com]
To: mathgroup at smc.vnet.net

I plot a couple of 2D contours by using ContourPlot. Now, I want to
pick up the coordinate of each point along each contour for next step
calculation purposes. I appreciate with your any suggestion of how to
get the coordinates of each point along a specific contour (suppose
two contours have been created).

Jun


  • Prev by Date: matlab calling mathematica
  • Next by Date: How Does ImportAutoReplacement Work?
  • Previous by thread: Re: Pick up coordinates along different contours.
  • Next by thread: Re: Pick up coordinates along different contours.