遮蔽特定区域

遮蔽特定区域

我有下图,使用来自的代码GeoGebra。对于第三幅图,我想遮蔽半圆和线段之间的区域,但我不知道如何做到这一点。
在此处输入图片描述

\documentclass[french,12pt,a4paper,titlepage]{article}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usepackage{marginnote}
\usetikzlibrary{arrows}
\definecolor{qqwuqq}{rgb}{0,0.39215686274509803,0}
\definecolor{zzttqq}{rgb}{0.6,0.2,0}
\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}
\definecolor{dyrbwq}{rgb}{0.8470588235294118,0.10588235294117647,0.3764705882352941}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1}
\definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1}


\begin{document}
        \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
            % Grid
            \draw [color=cqcqcq,, xstep=1cm,ystep=1cm] (-6,-2) grid (9,4); (11.566219733339873,8.525002520591164);
            
            % Whole circle
            \draw [line width=.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.12] (-3,1) circle (2cm);
            
            % Quarter circle
            \draw [shift={(3,0)},line width=.8pt,color=zzttqq,fill=zzttqq,fill opacity=0.12]  (0,0) --  plot[domain=1.5707963267948966:3.141592653589793,variable=\t]({1*3*cos(\t r)+0*3*sin(\t r)},{0*3*cos(\t r)+1*3*sin(\t r)}) -- cycle ;
            
            % 3e figure
            \draw [line width=.8pt,color=zzttqq] (4,1)-- (4,3);
            \draw [line width=.8pt,color=zzttqq] (4,3)-- (8,3);
            \draw [line width=.8pt,color=zzttqq] (8,3)-- (8,1);
            \draw [shift={(6,1)},line width=.8pt,color=zzttqq]  plot[domain=0:3.141592653589793,variable=\t]({1*2*cos(\t r)+0*2*sin(\t r)},{0*2*cos(\t r)+1*2*sin(\t r)});
            \draw [line width=.8pt,color=zzttqq] (4,1)-- (4,3);
            \draw [line width=.8pt,color=zzttqq] (4,3)-- (8,3);
            \draw [line width=.8pt,color=zzttqq] (8,3)-- (8,1);
            
            % Vector
            \draw [line width=.8pt, latex-latex] (-1,3)-- (0,3);
            \draw (-1.,3.8) node[anchor=north west] {$\mathbf{15 \ mm}$};
            
            % Centers
            \draw [fill=black] (-3,1) circle (1pt);
            \draw[color=black] (-2.8359128474830912,1.271089406461309) node {$C_{1}$};
            \draw [fill=black] (3,0) circle (1pt);
            \draw[color=black] (3.1,-0.3) node {$C_{2}$};
            \draw [fill=black] (6,1) circle (1pt);
            \draw[color=black] (5.774154770848989,0.850353117956426) node {$C_{3}$};
        \end{tikzpicture}
    
\end{document}

答案1

您无需逐一追踪每个线段和圆弧,只需定义一条定义每个图形轮廓的路径即可。

% 3e figure
            \draw [line width=.8pt,remplissage] (4,1)-- (4,3)-- (8,3)-- (8,1) arc[start angle=0,end angle=180,radius=2];

我添加了一种样式以避免代码重复。

\tikzset{remplissage/.style={color=zzttqq,fill=zzttqq,fill opacity=0.12}} 

完整代码:

\documentclass[french,12pt,a4paper,titlepage]{article}

\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usepackage{marginnote}
\usetikzlibrary{arrows}
\definecolor{qqwuqq}{rgb}{0,0.39215686274509803,0}
\definecolor{zzttqq}{rgb}{0.6,0.2,0}
\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}
\definecolor{dyrbwq}{rgb}{0.8470588235294118,0.10588235294117647,0.3764705882352941}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1}
\definecolor{ududff}{rgb}{0.30196078431372547,0.30196078431372547,1}

\tikzset{remplissage/.style={color=zzttqq,fill=zzttqq,fill opacity=0.12}}
\begin{document}
        \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
            % Grid
            \draw [color=cqcqcq,, xstep=1cm,ystep=1cm] (-6,-2) grid (9,4); (11.566219733339873,8.525002520591164);
            
            % Whole circle
            \draw [line width=.8pt,remplissage] (-3,1) circle (2cm);
            
            % Quarter circle
            \draw [line width=.8pt,remplissage]  (3,0) --++(0,3)arc[start angle=90,end angle=180,radius=3]   -- cycle ;
            
            % 3e figure
            \draw [line width=.8pt,remplissage] (4,1)-- (4,3)-- (8,3)-- (8,1) arc[start angle=0,end angle=180,radius=2];

            
            % Vector
            \draw [line width=.8pt, latex-latex] (-1,3)-- (0,3);
            \draw (-1.,3.8) node[anchor=north west] {$\mathbf{15 \ mm}$};
            
            % Centers
            \draw [fill=black] (-3,1) circle (1pt);
            \draw[color=black] (-2.8359128474830912,1.271089406461309) node {$C_{1}$};
            \draw [fill=black] (3,0) circle (1pt);
            \draw[color=black] (3.1,-0.3) node {$C_{2}$};
            \draw [fill=black] (6,1) circle (1pt);
            \draw[color=black] (5.774154770848989,0.850353117956426) node {$C_{3}$};
        \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

Geogebra 图形可以导出为 TikZ 或 Asymptote 代码。不过,直接使用 TikZ 或 Asymptote 进行编码会更好。

蒂克兹 在此处输入图片描述

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[mydot/.style={circle,fill=black,inner sep=1pt}]
\draw[gray!30] (-3,-3) grid (12,3);
\draw[<->,thick] (2,2)--(3,2) node[scale=.8,above=2mm,midway]{$15$ mm};
\draw[red,fill=yellow,fill opacity=.5]
(0,0) node[mydot]{} node[above,black]{$C_1$} circle(2)
(6,-1) node[mydot]{} node[below right,black]{$C_2$}--+(0,3) arc(90:180:3)--cycle
(11,0) arc(0:180:2)--+(0,2)-|cycle
(9,0) node[mydot]{} node[below,black,fill=white]{$C_3$}
;
\end{tikzpicture}
\end{document}

渐近线

在此处输入图片描述

// http://asymptote.ualberta.ca/
import math;
unitsize(1cm);

// grid and a label
add(shift(-3,-3)*grid(15,6,lightgray));
draw(scale(.8)*"$15$ mm",align=2N,(2,2)--(3,2),Arrows);

// starting points and pens
pair C1=(0,0),C2=(6,-1),C3=(9,0);
pen p=brown;
pen q=p+opacity(.1);

// 3 pics with dots
filldraw(circle(C1,2),q,p);
filldraw(C2--arc(C2,3,90,180)--cycle,q,p);
filldraw(arc(C3,2,0,180)--C3+(-2,2)--C3+(2,2)--cycle,q,p);

dot("$C_1$",C1,N);
dot("$C_2$",C2,SE);
dot(Label("$C_3$",Fill(white)),C3,N);

shipout(bbox(5mm,invisible));

答案3

我建议使用 AndréC 的代码(和结果!),无需使用繁琐的颜色代码(来自 GeoGebra)。我使用更多tikz来代替pgfplots

\documentclass[french,12pt,a4paper]{article}

\usepackage{tikz}

\usetikzlibrary{arrows}

\tikzset{remplissage/.style={orange!90,fill=orange!80,fill opacity=0.12}}
\begin{document}
        \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
            % Grid
            \draw [gray!20, xstep=1cm,ystep=1cm] (-6,-2) grid (9,4);
            
            % Whole circle
            \draw [line width=.8pt,remplissage] (-3,1) circle (2cm);
            
            % Quarter circle
            \draw [line width=.8pt,remplissage]  (3,0) --++(0,3)arc[start angle=90,end angle=180,radius=3]   -- cycle ;
            
            % 3e figure
            \draw [line width=.8pt,remplissage] (4,1)-- (4,3)-- (8,3)-- (8,1) arc[start angle=0,end angle=180,radius=2];

            % Vector
            \draw [line width=.8pt, latex-latex] (-1,3)-- (0,3);
            \draw (-1.,3.8) node[anchor=north west] {$\mathbf{15 \ mm}$};
            
            % Centers
            \draw [fill=black] (-3,1) circle (1pt) node[above] {$C_{1}$};
            \draw [fill=black] (3,0) circle (1pt) node[below] {$C_{2}$};
            \draw [fill=black] (6,1) circle (1pt) node[below] {$C_{3}$};
        \end{tikzpicture}
\end{document}

相关内容