When you do polar plots you are stuck with parametrizations of the limited form $$x(\varphi)=r(\varphi)\cos \varphi, \quad y(\varphi)=r(\varphi)\sin(\varphi).$$
The parametrization that you gave is not of that form. This is apparent already from the observation that the parametrization gives the full trefoil, when $t\in[0,2\pi]$, but the trefoil wraps around the origin twice, so $\varphi$ should range over $[0,4\pi]$.
Let us look at the Wikipedia parametrization of the trefoil on the surface of a torus:
$$
x=(2+\cos3t)\cos2t,\quad y=(2+\cos3t)\sin2t,\quad z=\sin 3t.
$$
If we ignore that $z$-coordinate for a moment, we see $(x,y)\uparrow\uparrow(\cos 2t,\sin 2t)$, which is a tell-tale sign that here $\varphi=2t$ is the polar angle coordinate. As $t$ ranges over $[0,2\pi]$, we should, indeed, have $\varphi\in[0,4\pi]$. Thus the projection of that trefoil onto the $xy$-plane comes from the polar equation
$$
r=2+\cos\frac{3\varphi}2,
$$
as suggested by heropup (+1). The plot is not quite what you may have expected:
Here the additive constant $2$ represents the ratio of the radius of the "wire" inside the torus to that of the "tube" around the wire. IMVHO the projection looks a bit cleaner, if we use ratio $4$ and equation $r=4+\cos\frac{3\varphi}2$ instead:
For a better view here is a 3D-image of how the trefoil wraps itself around the torus.
The trefoil is the thin tube on the surface of the doughnut.
I have come up with a simpler equation while formulating my question.
Idea is to interpolate between X and Y axis proportionally to distance to them.
Let me guide you through with an example:
// Input
X = 0.5; Y = 0.1
// This is base interpolation that prefers closer edge
x = A * (1-Y) + B * X + C * Y + D * (1-X); // Sum = 2
// Now calculate proportion between distances to edges
distX = 0.5 - Abs(X-0.5); // Distance to edge 0..0.5 range
distY = 0.5 - Abs(Y-0.5); // Distance to edge 0..0.5 range
if distX + distY > 0.001 then //0.001 is to deal with FP precision loss
begin
distSum = distX + distY;
coefX := distX / distSum; // 0..1 range
coefY := distY / distSum; // 0..1 range
end
else
begin
coefX := 0.5;
coefY := 0.5;
end;
// Our example values
coefX = 0.5 / 0.6 = 0.83
coefY = 0.1 / 0.6 = 0.17
// Add X/Y weights into equation, to get Sum = 1
x = A * (1-Y) * coefX + B * X * coefY + C * Y * coefX + D * (1-X) * coefY;
// Our example values
x = A * 0.747 + B * 0.085 + C * 0.083 + D * 0.085; // Sum = 1
Sorry I'm not familiar with Excel formulas close enough to build a diagram, but it looks much alike this:
Benefits are: no need for iterations, knowing ABCD
values and X
Y
position of x
is enough.
Best Answer
In order to preserve the convexity of the shape, one should make sure that the function $r=r(\theta)$ has "flat" minima; in contrast, the maxima can and should be relatively sharp. Applied to your data, the cosine interpolation yields $r=2+\cos 2\theta$ while the ellipse would have equation $r=3/\sqrt{5-4\cos 2\theta}$. While the large-scale behavior of these functions is the same, their extrema look rather different.
You can fix this by preprocessing the $r$-values. Instead of $(r,\theta)$ pairs, interpolate between $(1/r^2,\theta)$ pairs and then apply the inverse function $1/\sqrt{r}$. In your problem, this means interpolating between
which yields $(5-4\cos 2\theta)/9$. Hence, the shape is $r=1/\sqrt{(5-4\cos 2\theta)/9}$ which is exactly the ellipse with your four points as vertices.
To show that this works for shapes other than ellipses, I replaced the first point with $(5,0)$. The result is a nice convex egg with equation $r= 15/\sqrt{121-8\cos \theta -104 \cos 2\theta}$