How to approximate a level curve? Let $G$ be a $C^\infty$ function $G:\mathbb{R}^2\rightarrow\mathbb{R}$, and let $C:=G^{\leftarrow}(c)$, i.e. $C$ is a level set of $G$.
I know that $C$ is bounded (which implies that it's a closed curve) and it does not intersect itself (it's a manifold).
Given a point $P=(x_P,y_P)$ in the interior of this region, I'd like to calculate an approximation of $C$ with a curve $\gamma:[0,2\pi]\rightarrow\mathbb{R}^2$ that has this form:
\begin{equation}
\gamma(\theta) = (x_P+\varrho({\theta})\cos\theta,y_P+\varrho(\theta)\sin\theta)
\end{equation}
How should I start? 
 A: If you are not required to give $\varrho(\theta)$ on any particular form you could just discretize $\theta$, put it in a vector : ${\bf \Theta} = [\theta_1,\theta_2,\cdots,\theta_n]^T$. Then $\sin(\theta),\cos(\theta)$ become constant functions of this vector. We can call those vectors $\bf s_\Theta, c_\Theta$ for example. Assuming you can find a bunch of points on the contour and stuff them in a vector, let us call it $\bf d$, you can now build a least squares system:
$$\min_\varrho\|{\bf W}vec((\varrho c_\Theta+x_p)\hat- d_x)\|_2+ \|{\bf W}vec((\varrho s_\Theta+y_p)\hat- d_y)\|_2 + \lambda\|\varrho\|_2$$
Where $\hat -$ is a "tensor outer minus" : like a tensor outer product but minus instead of multiplication between the scalars. $\bf W$ is a diagonal matrix with non-negative entries which are a function that must be 


*

*Strictly decreasing with angle between vectors $(\cos(\theta),\sin(\theta))$ and $((x_p,y_p)-d)$. Maybe a $\cos^2$ (normed scalar product) (but nulled for negative $\cos$) would do.

*Strictly decreasing with distance $|(x_p,y_p)-d|$


It does not matter how nonlinear or ill behaved this function is as it will be constant with respect to each combination of $d$ and $\bf \theta$. But it may be more convenient to construct the W matrix as a product of matrices which are functions of 1 and 2 above.

Now if you want to you can further linearly fuse $\bf \varrho$ to a linear combination of some families of functions where you can regularize the coefficients et.c.
