Obtain smooth plot of free-hand contour
- To: mathgroup at smc.vnet.net
- Subject: [mg107174] Obtain smooth plot of free-hand contour
- From: "Dominic" <miliotodc at rtconline.com>
- Date: Fri, 5 Feb 2010 03:18:42 -0500 (EST)
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[[1]] & ) /@ myvals; myyval = (#1[[2]] & ) /@ 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}}]
- Follow-Ups:
- Re: Obtain smooth plot of free-hand contour
- From: Patrick Scheibe <pscheibe@trm.uni-leipzig.de>
- Re: Obtain smooth plot of free-hand contour