Is there a way to obtain a parametrization from a level set of a 2D scalar field? Perhaps somehow using some interpolation, for instance?
I have a 2D scalar field, f[x,y,coeff], a Fourier expansion. The 3rd argument is a list of coefficients for the Fourier terms. For instance with a list coeff = {{5,6},{7,8}}
, the function is something like
5*sin(x)cos(y) + 6*sin(x)cos(2y) + 7*sin(2x)cos(y) + 8*sin(2x)cos(2y)
Firstly I need to contour this function, which I can easily accomplish with ContourPlot (see example code and plot below). In the example, the expansion is of the kind {{constant,0},{0,0}}.
Then, I would like to be able to somehow parameterize the contours for any order of the expansion. In practice up to order 10 would be more than enough, i.e., 10*10 terms). For a very low order, I can solve
f[x,y,coeff]==constant
forx
ory
, whichever I can isolate, which is not possible in general.Ncontours = 10; cplot = With[{options = {PlotLegends -> Automatic, FrameLabel -> Automatic, ColorFunction -> "ThermometerColors", ImageSize -> {400, 350}}}, ContourPlot[Evaluate[f[x, y, coeff]], {x, -Lx, Lx}, {y, -Ly, Ly}, options, Contours -> Ncontours]]
Actually what I want to do is to somehow define a curve that would connect the level sets. And I thought that I could maybe do it by parameterizing them and then defining a piecewise function including some lines leading from one contour to the other one. Something like this:
So in black are the contour lines and in faint red is a very poor sketch of what I am aiming that. To get there, I would need a parametrization of the contour lines (B-C, D-E, F-G), and having those I would define a piecewise parametric function g(t) like a straight line in the pieces connecting A-B, C-D, E-F and G-H; and going around the contours at B-C, D-E and F-G.
f[x_,y_] := 0.0026*Sin[Pi*(x+0.02)/0.04]*Cos[Pi*(y+0.02)/0.04]
The level sets are a series of concentric sort-of-rings. I would like to define some piecewise parametrizationg(t) = (g1(t),g2(t))
, such that, for instance for t belonging to[0,1.9pi[
, this would draw the innermost contour (or almost all of it). Then for[1.9pi,2.1pi[
it would be a curve leading from the innermost contour to the next one. Then, for[2.1pi,3.9pi[
it would draw the 2nd contour, and so on. $\endgroup$f(x,y)=constant
, which are analytically solvable only in the simplest cases, with very little terms in the expansion, so I am trying to figure out other ways to define the contours. Maybe by defining interpolations of the curve, or some other numerical methods. I'm not sure if it is a little clearer now. $\endgroup$f
was wrong, both functions are sines, sorry about that. The function f is actually:f[x_,y_] := 0.0026*Sin[Pi*(x+0.02)/0.04]*Sin[Pi*(y+0.02)/0.04]
$\endgroup$