TikZでかいた図形

# TikZでかいた図形


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/349076/f8198862-a381-8219-81fc-5be031fd20fc.png)



```tex
\begin{tikzpicture}
%長さを描くためのマクロ
\def\preleng#1#2#3#4#5{
\draw (#1).. controls ($(#1)!.2!(#2)!{#4}!{#5}:(#2)$)
and ($(#1)!.8!(#2)!{#4}!{#5}:(#2)$) .. (#2)
node[midway, fill=white, inner sep = 0.3pt] (#1-#2) {#3}
}

%頂点
\tikzmath{
    \O{1} = 0;
    \O{2} = 0;
    \A{1} = 0;
    \A{2} = 4.5;
    \B{1} = 0;
    \B{2} = 0;
    \C{1} = 6;
    \C{2} = 0;
    \Radii{1} = 0.5*\C{1};
    \Radii{2} = 0.5*\A{2};
}
\coordinate (O) at (\O{1},\O{2});
\coordinate (A) at (\A{1},\A{2});
\coordinate (B) at (O);
\coordinate (C) at (\C{1},\C{2});


%三角形をかく
    \draw[very thick](A) -- (B) --(C) --cycle;

%頂点の名前
\node[above left] at (A) {A}
    node[below left] at (B) {B}
    node[below right] at (C) {C};


%半円を描く
%左側
    \draw[name path = C,very thick,samples=100,domain=-90:90] plot ({\Radii{2}*cos(\x)+0.5*\A{1}},{\Radii{2}*sin(\x)+0.5*\A{2}});
%右側
    \draw[name path = L,very thick,samples=100,domain=0:180] plot ({\Radii{1}*cos(\x)+0.5*\C{1}},{\Radii{1}*sin(\x)+0.5*\C{2}});


%交点を作成
\path[name intersections={of=L and C}] (intersection-1) coordinate (D);
    \node[above right] at (D) {D};




%斜線
\begin{scope}
\tikzmath{
    \hwidth = 0.2;
    \lineRange = 20;
    \dirVecx = 2;
    \dirVecy = 1;
}
\coordinate (dirVec) at (\dirVecx,\dirVecy);

\clip
[samples=100,domain=18:90] plot ({\Radii{2}*cos(\x)+0.5*\A{1}},{\Radii{2}*sin(\x)+0.5*\A{2}}) -- (D)
[samples=100,domain=0:107] plot ({\Radii{1}*cos(\x)+0.5*\C{1}},{\Radii{1}*sin(\x)+0.5*\C{2}}) -- (C)
[samples=100,domain=107:180] plot ({\Radii{1}*cos(\x)+0.5*\C{1}},{\Radii{1}*sin(\x)+0.5*\C{2}})
[samples=100,domain=-90:18] plot ({\Radii{2}*cos(\x)+0.5*\A{1}},{\Radii{2}*sin(\x)+0.5*\A{2}})
;
\foreach \x in {-100,...,100}
    {
    \draw ($(\x*\hwidth,0)+\lineRange*(dirVec)$) -- ($(\x*\hwidth,0)-\lineRange*(dirVec)$);
    }
\end{scope}

%長さを書く
\def\wrleng(#1-#2)#3{
\preleng{#1}{#2}{#3}{25pt}{-90}
}%
\wrleng (A-B){6 \unicm };

\def\wrleng(#1-#2)#3{
\preleng{#1}{#2}{#3}{25pt}{-90}
}%
\wrleng (A-C){10 \unicm };

\def\wrleng(#1-#2)#3{
\preleng{#1}{#2}{#3}{20pt}{-90}
}%
\wrleng (B-C){8 \unicm };

\def\wrleng(#1-#2)#3{
\preleng{#1}{#2}{#3}{25pt}{-90}
}%
\wrleng (A-C){10 \unicm };
\end{tikzpicture}
\end{preview}
```

https://texclip.marutank.net/#s=%5Cusetikzlibrary%7Bmath%2Ccalc%2Cintersections%7D%0D%0A%5Cdef%5Cunicm%7B%5Crm%7Bcm%7D%7D%0D%0A%5Cbegin%7Btikzpicture%7D%0D%0A%25%E9%95%B7%E3%81%95%E3%82%92%E6%8F%8F%E3%81%8F%E3%81%9F%E3%82%81%E3%81%AE%E3%83%9E%E3%82%AF%E3%83%AD%0D%0A%5Cdef%5Cpreleng%231%232%233%234%235%7B%0D%0A%5Cdraw%20(%231)..%20controls%20(%24(%231)!.2!(%232)!%7B%234%7D!%7B%235%7D%3A(%232)%24)%0D%0Aand%20(%24(%231)!.8!(%232)!%7B%234%7D!%7B%235%7D%3A(%232)%24)%20..%20(%232)%0D%0Anode%5Bmidway%2C%20fill%3Dwhite%2C%20inner%20sep%20%3D%200.3pt%5D%20(%231-%232)%20%7B%233%7D%0D%0A%7D%0D%0A%0D%0A%25%E9%A0%82%E7%82%B9%0D%0A%5Ctikzmath%7B%0D%0A%20%20%20%20%5CO%7B1%7D%20%3D%200%3B%0D%0A%20%20%20%20%5CO%7B2%7D%20%3D%200%3B%0D%0A%20%20%20%20%5CA%7B1%7D%20%3D%200%3B%0D%0A%20%20%20%20%5CA%7B2%7D%20%3D%204.5%3B%0D%0A%20%20%20%20%5CB%7B1%7D%20%3D%200%3B%0D%0A%20%20%20%20%5CB%7B2%7D%20%3D%200%3B%0D%0A%20%20%20%20%5CC%7B1%7D%20%3D%206%3B%0D%0A%20%20%20%20%5CC%7B2%7D%20%3D%200%3B%0D%0A%20%20%20%20%5CRadii%7B1%7D%20%3D%200.5*%5CC%7B1%7D%3B%0D%0A%20%20%20%20%5CRadii%7B2%7D%20%3D%200.5*%5CA%7B2%7D%3B%0D%0A%7D%0D%0A%5Ccoordinate%20(O)%20at%20(%5CO%7B1%7D%2C%5CO%7B2%7D)%3B%0D%0A%5Ccoordinate%20(A)%20at%20(%5CA%7B1%7D%2C%5CA%7B2%7D)%3B%0D%0A%5Ccoordinate%20(B)%20at%20(O)%3B%0D%0A%5Ccoordinate%20(C)%20at%20(%5CC%7B1%7D%2C%5CC%7B2%7D)%3B%0D%0A%0D%0A%0D%0A%25%E4%B8%89%E8%A7%92%E5%BD%A2%E3%82%92%E3%81%8B%E3%81%8F%0D%0A%20%20%20%20%5Cdraw%5Bvery%20thick%5D(A)%20--%20(B)%20--(C)%20--cycle%3B%0D%0A%0D%0A%25%E9%A0%82%E7%82%B9%E3%81%AE%E5%90%8D%E5%89%8D%0D%0A%5Cnode%5Babove%20left%5D%20at%20(A)%20%7BA%7D%0D%0A%20%20%20%20node%5Bbelow%20left%5D%20at%20(B)%20%7BB%7D%0D%0A%20%20%20%20node%5Bbelow%20right%5D%20at%20(C)%20%7BC%7D%3B%0D%0A%0D%0A%0D%0A%25%E5%8D%8A%E5%86%86%E3%82%92%E6%8F%8F%E3%81%8F%0D%0A%25%E5%B7%A6%E5%81%B4%0D%0A%20%20%20%20%5Cdraw%5Bname%20path%20%3D%20C%2Cvery%20thick%2Csamples%3D100%2Cdomain%3D-90%3A90%5D%20plot%20(%7B%5CRadii%7B2%7D*cos(%5Cx)%2B0.5*%5CA%7B1%7D%7D%2C%7B%5CRadii%7B2%7D*sin(%5Cx)%2B0.5*%5CA%7B2%7D%7D)%3B%0D%0A%25%E5%8F%B3%E5%81%B4%0D%0A%20%20%20%20%5Cdraw%5Bname%20path%20%3D%20L%2Cvery%20thick%2Csamples%3D100%2Cdomain%3D0%3A180%5D%20plot%20(%7B%5CRadii%7B1%7D*cos(%5Cx)%2B0.5*%5CC%7B1%7D%7D%2C%7B%5CRadii%7B1%7D*sin(%5Cx)%2B0.5*%5CC%7B2%7D%7D)%3B%0D%0A%0D%0A%0D%0A%25%E4%BA%A4%E7%82%B9%E3%82%92%E4%BD%9C%E6%88%90%0D%0A%5Cpath%5Bname%20intersections%3D%7Bof%3DL%20and%20C%7D%5D%20(intersection-1)%20coordinate%20(D)%3B%0D%0A%20%20%20%20%5Cnode%5Babove%20right%5D%20at%20(D)%20%7BD%7D%3B%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%25%E6%96%9C%E7%B7%9A%0D%0A%5Cbegin%7Bscope%7D%0D%0A%5Ctikzmath%7B%0D%0A%20%20%20%20%5Chwidth%20%3D%200.2%3B%0D%0A%20%20%20%20%5ClineRange%20%3D%2020%3B%0D%0A%20%20%20%20%5CdirVecx%20%3D%202%3B%0D%0A%20%20%20%20%5CdirVecy%20%3D%201%3B%0D%0A%7D%0D%0A%5Ccoordinate%20(dirVec)%20at%20(%5CdirVecx%2C%5CdirVecy)%3B%0D%0A%0D%0A%5Cclip%0D%0A%5Bsamples%3D100%2Cdomain%3D18%3A90%5D%20plot%20(%7B%5CRadii%7B2%7D*cos(%5Cx)%2B0.5*%5CA%7B1%7D%7D%2C%7B%5CRadii%7B2%7D*sin(%5Cx)%2B0.5*%5CA%7B2%7D%7D)%20--%20(D)%0D%0A%5Bsamples%3D100%2Cdomain%3D0%3A107%5D%20plot%20(%7B%5CRadii%7B1%7D*cos(%5Cx)%2B0.5*%5CC%7B1%7D%7D%2C%7B%5CRadii%7B1%7D*sin(%5Cx)%2B0.5*%5CC%7B2%7D%7D)%20--%20(C)%0D%0A%5Bsamples%3D100%2Cdomain%3D107%3A180%5D%20plot%20(%7B%5CRadii%7B1%7D*cos(%5Cx)%2B0.5*%5CC%7B1%7D%7D%2C%7B%5CRadii%7B1%7D*sin(%5Cx)%2B0.5*%5CC%7B2%7D%7D)%0D%0A%5Bsamples%3D100%2Cdomain%3D-90%3A18%5D%20plot%20(%7B%5CRadii%7B2%7D*cos(%5Cx)%2B0.5*%5CA%7B1%7D%7D%2C%7B%5CRadii%7B2%7D*sin(%5Cx)%2B0.5*%5CA%7B2%7D%7D)%0D%0A%3B%0D%0A%5Cforeach%20%5Cx%20in%20%7B-100%2C...%2C100%7D%0D%0A%20%20%20%20%7B%0D%0A%20%20%20%20%5Cdraw%20(%24(%5Cx*%5Chwidth%2C0)%2B%5ClineRange*(dirVec)%24)%20--%20(%24(%5Cx*%5Chwidth%2C0)-%5ClineRange*(dirVec)%24)%3B%0D%0A%20%20%20%20%7D%0D%0A%5Cend%7Bscope%7D%0D%0A%0D%0A%25%E9%95%B7%E3%81%95%E3%82%92%E6%9B%B8%E3%81%8F%0D%0A%5Cdef%5Cwrleng(%231-%232)%233%7B%0D%0A%5Cpreleng%7B%231%7D%7B%232%7D%7B%233%7D%7B25pt%7D%7B-90%7D%0D%0A%7D%25%0D%0A%5Cwrleng%20(A-B)%7B6%20%5Cunicm%20%7D%3B%0D%0A%0D%0A%5Cdef%5Cwrleng(%231-%232)%233%7B%0D%0A%5Cpreleng%7B%231%7D%7B%232%7D%7B%233%7D%7B25pt%7D%7B-90%7D%0D%0A%7D%25%0D%0A%5Cwrleng%20(A-C)%7B10%20%5Cunicm%20%7D%3B%0D%0A%0D%0A%5Cdef%5Cwrleng(%231-%232)%233%7B%0D%0A%5Cpreleng%7B%231%7D%7B%232%7D%7B%233%7D%7B20pt%7D%7B-90%7D%0D%0A%7D%25%0D%0A%5Cwrleng%20(B-C)%7B8%20%5Cunicm%20%7D%3B%0D%0A%0D%0A%5Cdef%5Cwrleng(%231-%232)%233%7B%0D%0A%5Cpreleng%7B%231%7D%7B%232%7D%7B%233%7D%7B25pt%7D%7B-90%7D%0D%0A%7D%25%0D%0A%5Cwrleng%20(A-C)%7B10%20%5Cunicm%20%7D%3B%0D%0A%5Cend%7Btikzpicture%7D