TeX - LaTeX Asked by Mario Vago Marzal on July 6, 2021
I’m learning TikZ and I would like to learn how to fill a ellipse section determined by the center and two points on the curve wich coordinates are, obviously, known. I mean something like this:
Thank you in advance!
A solution with clipping around the ellipse.
documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}
defa{-20} defb{115} % Angles for the filling
defr{4} defR{3} % Radii of the ellipse
defell{(0,0) ellipse (r cm and R cm)}
begin{scope}
clip ell;
filldraw[red,draw=black,thick] (0,0) -- (a:2*r cm) |- (b:2*r cm)-- cycle;
end{scope}
draw[thick] ell;
end{tikzpicture}
end{document}
Answered by SebGlav on July 6, 2021
A simple approach using polar coordinates that does not require clipping:
documentclass[tikz,border=1mm]{standalone}
begin{document}
begin{tikzpicture}[thick]
draw (0:0) ellipse (4 and 3);
draw[fill=red] (0:0) -- (-20:4 and 3) arc (-20:115:4 and 3) -- cycle;
end{tikzpicture}
end{document}
Polar coordinates in TikZ are defines as (t:r)
where t
is the angular coordinate and r
the radial coordinate (that is the distance from the center). The radius of the ellipse (which is equal to that of the arc part of the sector) is 4 and 3
which means that the larger radius is 4cm and the smaller radius is 3cm. This radius is also used as radial coordinate for the starting point of the arc of the sector.
Answered by Jasper Habicht on July 6, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP