How can I draw a square whose side is 6 inscribed in a circle and make the program display the shaded region between the square and the circle
[Tex/LaTex] Shaded region between the area and a circle
tikz-pgf
Related Solutions
You can fill the area by drawing a closed path which is a combination of the curves and a corresponding arc.
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
thick,
every node/.style={
circle,
scale=.5,
fill
}
]
\draw (0,0) ++(160:3) arc (160:-160:3);
\node (e1) at (160:3) {};
\node (e2) at (-160:3) {};
\draw(e1) -- node[fill=none,left,scale=2] {$e$} (e2);
\fill[cyan,draw=black] plot[smooth] coordinates {
(160:3)
(130:2)
(110:2.5)
(100:2.5)
(90:3)
} arc[radius=3,start angle=90,end angle=160];
\fill[cyan,draw=black] plot[smooth] coordinates {
(40:3)
(30:1)
(-40:1.5)
(-80:3)
} arc[radius=3,start angle=-80,end angle=40];
\end{tikzpicture}
\end{document}
The choice of the fill color is of course left to you. The chosen one here is only for demonstration purposes.
One option:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\definecolor{mypurple}{RGB}{236,145,191}
\newlength\Radius
\setlength\Radius{2cm}
\begin{document}
\begin{tikzpicture}[line join=round]
\filldraw[fill=mypurple,even odd rule]
(0,0) -- node[above] {$R$} (210:\Radius) arc [start angle=210,end angle=90,radius=\Radius] -- (0,0)
(210:\Radius) -- (90:\Radius) -- (0,0)
(0,0) -- (30:0.5\Radius) arc [start angle=30,end angle=-90,radius=0.5\Radius] --(0,0)
(30:0.5\Radius) -- (-30:\Radius) -- (-90:0.5\Radius) -- (0,0);
\draw
(0,0) circle [radius=\Radius]
(0,0) circle [radius=0.5\Radius]
(90:\Radius) -- (210:\Radius) -- (-30:\Radius) -- cycle
(0,0) -- (-30:0.5\Radius) node[midway,above] {$r$};
\fill (0,0) circle [radius=1.5pt];
\end{tikzpicture}
\end{document}
The square case:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\definecolor{mypurple}{RGB}{236,145,191}
\newlength\Radius
\setlength\Radius{2cm}
\begin{document}
\begin{tikzpicture}[line join=round]
\fill[fill=mypurple,even odd rule,draw=white]
(0,0) -- (0:{\Radius/sqrt(2)}) arc[start angle=0,end angle=-90,radius=\Radius/sqrt(2)] -- (0,0) rectangle (-45:\Radius)
(0,0) -- (45:\Radius) arc[start angle=45,end angle=135,radius=\Radius] -- (0,0) -- (45:\Radius) -- (135:\Radius) -- cycle ;
\draw
(0,0) circle [radius=\Radius]
(225:\Radius) rectangle (45:\Radius)
(0,0) circle [radius=\Radius/sqrt(2)];
\fill (0,0) circle [radius=1.5pt];
\draw
(225:\Radius) -- node[above left=-1pt] {$R$} (0,0) -- node[above right=-1pt] {$r$} (-45:{\Radius/sqrt(2)});
\end{tikzpicture}
\end{document}
Update:
Without even odd rule
:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\definecolor{mypurple}{RGB}{236,145,191}
\newlength\Radius
\setlength\Radius{2cm}
\begin{document}
\begin{tikzpicture}[line join=round]
\fill[fill=mypurple]
(210:\Radius) arc [start angle=210,end angle=90,radius=\Radius] -- cycle
(30:0.5\Radius) arc [start angle=30,end angle=-90,radius=0.5\Radius] -- (-30:\Radius) -- cycle;
\draw
(0,0) circle [radius=\Radius]
(0,0) circle [radius=0.5\Radius]
(90:\Radius) -- (210:\Radius) -- (-30:\Radius) -- cycle
(0,0) -- (210:\Radius) node[midway,above] {$R$}
(0,0) -- (-30:0.5\Radius) node[midway,above] {$r$}
(90:\Radius) -- (90:-0.5\Radius);
\fill (0,0) circle [radius=1.5pt];
\end{tikzpicture}
\begin{tikzpicture}[line join=round]
\fill[fill=mypurple]
(0:{\Radius/sqrt(2)}) arc[start angle=0,end angle=-90,radius=\Radius/sqrt(2)] -- (-45:\Radius) -- cycle
(45:\Radius) arc[start angle=45,end angle=135,radius=\Radius] -- cycle ;
\draw
(0,0) circle [radius=\Radius]
(225:\Radius) rectangle (45:\Radius)
(0,0) circle [radius=\Radius/sqrt(2)];
\fill (0,0) circle [radius=1.5pt];
\draw
(225:\Radius) -- node[above left=-1pt] {$R$} (0,0) -- node[above right=-1pt] {$r$} (-45:{\Radius/sqrt(2)});
\end{tikzpicture}
\end{document}
Best Answer
Here's a simple option; the value for
\side
controls half the side of the square:Another option using the intersections library; this time the value for
\radius
controls the radius of the circle: