使用 tkz-euclide 重现 tikz 半圆和截面

使用 tkz-euclide 重现 tikz 半圆和截面

我正在尝试重现Tikz使用 制作的以下前三个图形tkz-euclide。到目前为止,我已经成功完成了第三个,第一个我无法在没有剪切标签和 的情况下剪切半圆\tkzDrawSegment。中间的红色我仍然没有头绪。

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tkz-euclide}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning,angles,arrows,calc}
\tikzset{>=stealth}


\begin{document}


\begin{tikzpicture}
\draw (0,0) rectangle (2,2);
\node[left] at (-.2,1) {a};
\draw[thick,<->] (-.2,0) to (-.2,2);
\fill[blue!20] (0,0) -- (2,0) arc (0:90:2) -- (0,0);
\end{tikzpicture}


\begin{tikzpicture}
\draw (0,0) rectangle (2,2);
\node[left] at (-.2,1) {a};
\draw[thick,<->] (-.2,0) to (-.2,2);
%\fill[blue!20] (0,0) -- (2,0) arc (0:90:2) -- (0,0);
\fill[red] (0,2) arc [start angle=90,end angle=0,radius=2cm];
%\fill[blue!20] (2,0) -- (2,0) arc (0:45:2) -- (0,0);
\fill[red] (2,0) arc [start angle=-90,end angle=-180,radius=2cm];
\end{tikzpicture}

\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (2,2);
\node[left] at (-.2,1) {a};
\draw[thick,<->] (-.2,0) to (-.2,2);
\fill[blue!20] (0,0) -- (2,0) arc (0:180:1) -- (0,0);
\fill[blue!20] (0,2) -- (2,2) arc (0:-180:1) -- (0,0);
\end{tikzpicture}



\bigskip


%p. 93
\begin{tikzpicture}%[scale=.75]
\tkzDefPoint(0,0){A} 
\tkzDefPoint(2,0){B}
\tkzDefPoint(1,2){F}
\tkzDefSquare(A,B) 
\tkzGetPoints{C}{D}
\tkzDrawPolygon(B,C,D,A)
\tkzLabelPoints[right](B,C)
\tkzLabelPoints[left](A,D)
\tkzDrawSemiCircle[fill = green!20](F,D)%
\tkzDefPoint(1,0){G}
\tkzDrawSemiCircle[fill = green!20](G,B)%
\tkzMarkRightAngle(B,A,D)
\tkzCalcLength[cm](A,D)\tkzGetLength{ad}
%\tkzDrawSegment[dim={2cm,16pt,transform shape}](A,D)
\tkzDrawSegment[dim={\pgfmathprintnumber\ad cm,16pt,transform shape}](A,D)
\end{tikzpicture}



\begin{tikzpicture}%[scale=.75]
\tkzDefPoint(0,0){A} 
\tkzDefPoint(2,0){B}
\tkzDefPoint(1,2){F}
\tkzDefSquare(A,B) 
\tkzGetPoints{C}{D}
\tkzDrawPolygon(B,C,D,A)
%\tkzClipPolygon(B,C,D,A)
\tkzDrawSemiCircle[fill = green!20](A,B)%
\tkzLabelPoints[right](B,C)
\tkzLabelPoints[left](A,D)
\tkzMarkRightAngle(B,A,D)
\tkzCalcLength[cm](A,D)\tkzGetLength{ad}
%\tkzDrawSegment[dim={2cm,16pt,transform shape}](A,D)
\tkzDrawSegment[dim={\pgfmathprintnumber\ad cm,16pt,transform shape}](A,D)

\end{tikzpicture}

\end{document}

答案1

好的,我终于找到了解决方案。我会在这里发布它,以防其他人觉得它有用。

在此处输入图片描述

\documentclass{mwart}
\usepackage{tkz-euclide}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning,angles,arrows,calc}
\tikzset{>=stealth}


\begin{document}

\section{With Tikz}

\begin{tikzpicture}
\draw (0,0) rectangle (2,2);
\node[left] at (-.2,1) {a};
\draw[thick,<->] (-.2,0) to (-.2,2);
\fill[blue!20] (0,0) -- (2,0) arc (0:90:2) -- (0,0);
%\fill[red] (0,2) -- (0,0) arc (0:90:2) -- (0,2);
%\draw (-2,0)arc (180:-45:2);
%\draw (2,0)arc (180:90:2);
%\draw (2,0)arc (-90:90:2);
\end{tikzpicture}


\begin{tikzpicture}
\draw (0,0) rectangle (2,2);
\node[left] at (-.2,1) {a};
\draw[thick,<->] (-.2,0) to (-.2,2);
%\fill[blue!20] (0,0) -- (2,0) arc (0:90:2) -- (0,0);
\fill[red] (0,2) arc [start angle=90,end angle=0,radius=2cm];
%\fill[blue!20] (2,0) -- (2,0) arc (0:45:2) -- (0,0);
\fill[red] (2,0) arc [start angle=-90,end angle=-180,radius=2cm];
\end{tikzpicture}

\begin{tikzpicture}
\draw[fill=blue] (0,0) rectangle (2,2);
\node[left] at (-.2,1) {a};
\draw[thick,<->] (-.2,0) to (-.2,2);
\fill[blue!20] (0,0) -- (2,0) arc (0:180:1) -- (0,0);
\fill[blue!20] (0,2) -- (2,2) arc (0:-180:1) -- (0,0);
\end{tikzpicture}

\section{With tkz-euclide}

First one:

\begin{tikzpicture}%[scale=.75]
    \tkzDefPoint(0,0){A} 
    \tkzDefPoint(2,0){B}
    \tkzDefPoint(1,2){F}
    \tkzDefSquare(A,B) 
    \tkzGetPoints{C}{D}
    \tkzLabelPoints[above right](B,C)
    \tkzLabelPoints[above left](A,D)
    \tkzCalcLength[cm](A,D)\tkzGetLength{ad}
    %\tkzDrawSegment[dim={2cm,16pt,transform shape}](A,D)
    \tkzDrawSegment[dim={\pgfmathprintnumber\ad cm,16pt,transform shape}](A,D)
    \tkzDrawPolygon(B,C,D,A)
    \tkzClipPolygon(B,C,D,A)
    \tkzDrawSemiCircle[fill = green!20](A,B)%
    %\tkzDrawPolygon(B,C,D,A)
    \tkzMarkRightAngle(B,A,D)
    
    
\end{tikzpicture}

\bigskip

Now the red one:

\medskip


\begin{tikzpicture}%[scale=.75]
    \tkzDefPoint(0,0){A} 
    \tkzDefPoint(2,0){B}
    \tkzDefPoint(1,2){F}
    \tkzDefSquare(A,B) 
    \tkzGetPoints{C}{D}
    \tkzLabelPoints[above right](B,C)
    \tkzLabelPoints[above left](A,D)
    \tkzCalcLength[cm](A,D)\tkzGetLength{ad}
    %\tkzDrawSegment[dim={2cm,16pt,transform shape}](A,D)
    \tkzDrawSegment[dim={\pgfmathprintnumber\ad cm,16pt,transform shape}](A,D)
    \tkzDrawPolygon(B,C,D,A)
    \tkzClipPolygon(B,C,D,A)
    \tkzDrawArc[R with nodes,fill=green](A,2cm)(B,D)
    \tkzDrawArc[R with nodes,fill=green](C,2cm)(D,B)
    %\tkzDrawPolygon(B,C,D,A)
    \tkzMarkRightAngle(B,A,D)   
\end{tikzpicture}



\bigskip

And the last one:

%p. 93
\begin{tikzpicture}%[scale=.75]
\tkzDefPoint(0,0){A} 
\tkzDefPoint(2,0){B}
\tkzDefPoint(1,2){F}


\tkzDefSquare(A,B) 
\tkzGetPoints{C}{D}
\tkzDrawPolygon(B,C,D,A)
\tkzLabelPoints[right](B,C)
\tkzLabelPoints[left](A,D)
\tkzDrawSemiCircle[fill = green!20](F,D)%
%=\tkzDrawSemiCircle[diameter,fill = green!20](D,C)%
\tkzDefPoint(1,0){G}
\tkzDrawSemiCircle[fill = green!20](G,B)%
\tkzMarkRightAngle(B,A,D)
\tkzCalcLength[cm](A,D)\tkzGetLength{ad}
%\tkzDrawSegment[dim={2cm,16pt,transform shape}](A,D)
\tkzDrawSegment[dim={\pgfmathprintnumber\ad cm,16pt,transform shape}](A,D)
\end{tikzpicture}



\end{document}

相关内容