遮蔽特定區域

遮蔽特定區域

我使用來自 的程式碼得到了下圖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}

相關內容