Posts

Showing posts from December 30, 2018

Test whether a circle fully lies within a polygon in TikZ

Image
6 0 Given the following TikZ picture with an irregularly shaped polygon: documentclass{article} usepackage{tikz} begin{document} begin{tikzpicture} path[draw=blue] (0,3) -- (5,4) -- (3,2) -- (4,0) -- (1,1) -- cycle; node [circle,draw=none,fill=green,inner sep=0pt,minimum size=0.3cm] at (3.5,0.4) {}; node [circle,draw=none,fill=green,inner sep=0pt,minimum size=0.3cm] at (1.03,1.3) {}; node [circle,draw=none,fill=red,inner sep=0pt,minimum size=0.3cm] at (3.3,2) {}; node [circle,draw=none,fill=red,inner sep=0pt,minimum size=0.3cm] at (0.7,1.8) {}; end{tikzpicture} end{document} The two green circles in the picture lie completely inside the polygon, while the red ones lie partially or fully outside. Is there a way to automate that "ownership" test in TikZ? I know algorithms exist for such kind of