The central red curve defined by 4 points in the diagram above is called a "quadriellipse" (not sure). How do I plot it in Mathematica?
-
$\begingroup$ what have you tried? Do you know anything about the mathematics of the figure you've shown? $\endgroup$– george2079Mar 6, 2018 at 2:45
-
$\begingroup$ I tried to find there are blue,pink,green, yellow 4 Cardioid. $\endgroup$– kittygirlMar 6, 2018 at 2:55
-
$\begingroup$ Where did you get this picture from? $\endgroup$– J. M.'s eventual burnout ♦Mar 6, 2018 at 3:23
-
$\begingroup$ @J.M.from this link $\endgroup$– kittygirlMar 6, 2018 at 3:45
-
1$\begingroup$ Next time, please include the sources of any image you are using that you did not generate yourself. $\endgroup$– J. M.'s eventual burnout ♦Mar 6, 2018 at 4:34
1 Answer
Converting the multipolar equation in the link into Cartesian form, here is a $4$-ellipse where the four foci are arranged in a square:
With[{pts = CirclePoints[{1, 0}, 4], d = 24/5 (* sum of distances *)},
ContourPlot[Sum[EuclideanDistance[{x, y}, pt], {pt, pts}] == d,
{x, -3/2, 3/2}, {y, -3/2, 3/2},
Epilog -> {Directive[Red, AbsolutePointSize[4]], Point[pts]}]]
This is only a portion of the full Cartesian curve; to see the full curve, we can use GroebnerBasis[]
to obtain the rationalized Cartesian equation:
With[{d = 24/5},
ContourPlot[First[GroebnerBasis[Sum[Sqrt[#.#] &[{x, y} - pt],
{pt, CirclePoints[{1, 0}, 4]}] - d,
{x, y}]] == 0 // Evaluate,
{x, -3, 3}, {y, -3, 3}, PlotPoints -> 105]]
It was simple enough to make a Manipulate[]
for playing with general $n$-ellipses, so I made one:
Manipulate[ContourPlot[Sum[EuclideanDistance[{x, y}, pt], {pt, pts}] == d,
{x, -5, 5}, {y, -5, 5}],
{{d, 5}, 0, 20}, {{pts, N[CirclePoints[4]]}, Locator, LocatorAutoCreate -> All}]