Drawing a filled arc of an ellipse -- not aligning the ellipses

I am trying to follow the guidance from this answer to a previous question:

How to draw a ellipse sector from focus

In my own code I have written:

\begin{tikzpicture}

\draw[variable=\t, domain=0:360] plot ({8*(cos(\t))}, {4*sin(\t)});
\fill ({8*cos(30)},{4*sin(30}) circle (.05);
\fill ({8*cos(60)},{4*sin(60}) circle (.05);

\fill ({-sqrt(12)},0) -- ({8*cos(30)},{4*sin(30)}) arc[start angle = 30, end angle = 60, x radius = 4, y radius = 2] -- cycle;
\end{tikzpicture}


The perimeter of the ellipse isn't lining up with filled sector, and I'm not sure what I'm doing wrong. I suspect that I'm not sure how arc works out the center of the ellipse, but I thought that I was basically doing whatever that answer is doing. It's also possible that I'm misunderstanding or miscalculating some of the relevant geometry.

The last line must be:

\fill ({-sqrt(12)},0) -- ({8*cos(30)},{4*sin(30)}) arc[start angle = 30, end angle = 60, x radius = 8, y radius = 4];


Result:

• Ah right, I was stupidly dividing the radius by half. Commented Jun 25, 2023 at 14:29

While Raffaele Santoro found the actual problem, TikZ can draw ellipses and has polar coordinates that can be used with two different radii:

\draw circle [x radius=8, y radius=4];

\draw ({-sqrt(12)},0) -- (30:8 and 4)


(There is no difference between the path operations circle and ellipse, it just comes down to the values of x radius and y radius.)

The key system also allows you to specify both x and y radius for a whole scope and it will be used for all circles, ellipses and arcs unless they're specified again:

\begin{tikzpicture}[x radius=8, y radius=4]
\draw circle[];
\fill[radius=1pt] (30:8 and 4) coordinate (30) circle []
(60:8 and 4)                 circle [];
\fill ({-sqrt(12)},0) -- (30) arc[start angle = 30, end angle = 60] -- cycle;
\end{tikzpicture}


But this still needs you to specify the radii more than once for the polar coordinates.

You can use, of course, always TeX macros, say \newcommand*\radiusX{8}:

\begin{tikzpicture}[x radius=\xRadius, y radius=\yRadius]
\draw circle[];
\fill ({-sqrt(12)},0) -- (30) arc[start angle = 30, end angle = 60] -- cycle;
\end{tikzpicture}


Or special PGFMath functions that access those values (of course, this could also just be TeX macros again):

\pgfset{declare function={xR=\pgfkeysvalueof{/tikz/x radius};
\draw circle[];
\fill (30:xR and yR) coordinate (30) circle [radius=1pt]
\fill ({-sqrt(12)},0) -- (30) arc[start angle = 30, end angle = 60] -- cycle;
\end{tikzpicture}


Or you just declare your own PGFMath functions which is the most convenient way to me:

\begin{tikzpicture}[declare function={a=8; b=4;}, x radius=a, y radius=b]
\draw circle[];
\fill[radius=1pt] (30:a and b) coordinate (30) circle []
(60:a and b)                 circle [];
\fill ({-sqrt(12)},0) -- (30) arc[start angle = 30, end angle = 60] -- cycle;
\end{tikzpicture}


Using plot needs bigger number of sample to get a smoother curve. Below is a simple way using avaiable smooth curves ellipse and arc. To get a point on an ellipse, we take polar coordinates, for instance,

(30:a and b)


where 30 is the angle, a and b are the major and minor semi-axes.

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={a=4;b=2;}]
\fill[cyan,opacity=.5] (0,0)--(30:a and b) arc(30:60:a and b)--cycle;
\draw (0,0) ellipse(a and b);
\draw[fill=white] (30:a and b) circle(1pt) (60:a and b) circle(1pt);
\end{tikzpicture}
\end{document}