       Re: Obtain smooth plot of free-hand contour

• To: mathgroup at smc.vnet.net
• Subject: [mg107242] Re: [mg107174] Obtain smooth plot of free-hand contour
• From: "David Park" <djmpark at comcast.net>
• Date: Sat, 6 Feb 2010 03:25:53 -0500 (EST)
• References: <31131058.1265361368248.JavaMail.root@n11>

```In Version 7 you could use a BSplineCurve with the option SplineClosed ->
True.

David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/

From: Dominic [mailto:miliotodc at rtconline.com]

Hi,

I'm working on a contour integral over a contour I'd like to draw
free-hand via the graphics tools, then obtain a smooth plot of the
curve.  So first I do a
Show[mypoint,Axes-True,PlotRange->{{-2,2},{-2,2}}] to just get the
graphics box of a single point.  Then I use the graphics tools to draw
in the contour, then I select the contour and assign it to
myfreehandcontour to obtain the x and y points.  Then I extract the
points and then do a FindFit on the x and y values.  However, I cannot
get the end-points to meet so the contour is not even close to closed.
Here is the code I use once I have pasted the plot to myfreehandcontour
and I don't know if it's ok to post JPEG images to the group but I'll
try below of the points and resulting FindFit curve. Note the start and
end points are not closing the contour in the contour of the resulting
ParametricPlot[{xcod[t],{ycod[t]},{t,1,1100}].  I don't know, maybe this
is too much..

Can you guys suggest a way to input a free-hand closed contour into
Mathematica and obtain a nice smooth {x(t),y(t)} representation of it?

Thanks!

Dominic

lns = Cases[Normal[First[myfreehandcontour]], Line[pts_] -> pts,
{0, Infinity}];

lplot1 = ListPlot[lns]

myvals = First[lns];
myxval = (#1[] & ) /@ myvals;
myyval = (#1[] & ) /@ myvals;
nmax = 100;
myfun = Sum[Subscript[a, n]*t^n, {n, 0, nmax}];
mycoef = Table[Subscript[a, n], {n, 0, nmax}]
clist = FindFit[myxval, myfun, mycoef, t];
xcod[t_] = myfun /. clist
myyfun = Sum[Subscript[b, n]*t^n, {n, 0, nmax}];
myycoef = Table[Subscript[b, n], {n, 0, nmax}];
cylist = FindFit[myyval, myyfun, myycoef, t];
ycod[t_] = myyfun /. cylist

pp1 = ParametricPlot[{xcod[t], ycod[t]}, {t, 1, 1100}]

GraphicsGrid[{{lplot1, pp1}}]

```

• Prev by Date: Re: Re: DeleteDuplicates is too slow?
• Next by Date: Re: Weird vanishing syntax coloring
• Previous by thread: Re: Obtain smooth plot of free-hand contour
• Next by thread: Weird vanishing syntax coloring