TikZ忘れやすいもの anglesライブラリ intersectonsライブラリ

#anglesライブラリ

図形に角度を記入したいときの便利なライブラリです。

`\usetikzlibrary{angles}`

```tex
\draw pic[fill=gray,draw=black, <->, "#文字列",angle eccentricity=1.2, angle radius=0.5cm] {angle=A--B--C}
;
```

`{angle=A--B--C}`の`A`，`B`，`C`は座標を表しています。$\angle \rm{ABC}$に角度の記号をつけます。Bを中心とした弧を書きます。
`{angle=A--B--C}`はAからCへ回反時計回りに角度をつけます。`{angle=C--B--A}`はその反対側に角度に記号がつきます。

```tex
\usetikzlibrary{angles}
\begin{document}
\begin{tikzpicture}
\draw (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);

\draw pic[draw=black, "$\theta$",angle eccentricity=1.3, angle radius=0.5cm] 
{angle=A--B--C};

\end{tikzpicture}
\end{document}
```

オプション

`fill`：弧の内部を指定した色で塗りつぶします

`angle radius=0.5cm` ：弧の半径を決める

`angle eccentricity=1.2`： 文字列を配置する場所（中心からの離れ具合）を決めます

`<->`は`draw`のオプションと同じ





## fill

```tex
\usetikzlibrary{angles}
\begin{tikzpicture}
\draw (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);

\draw pic[draw=black, fill=gray,"$\theta$",angle eccentricity=1.3, angle radius=0.5cm] 
{angle=A--B--C};

\end{tikzpicture}
```

<img src="https://texclip.marutank.net/render.php/texclip20230705033323.svg?s=%5Cusetikzlibrary%7Bangles%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%20(3%2C-1)%20coordinate%20(A)%20--%20(0%2C0)%20coordinate%20(B)%20--%20(2%2C2)%20coordinate%20(C)%3B%0A%0A%5Cdraw%20pic%5Bdraw%3Dblack%2Cfill%3Dgray%2Cangle%20eccentricity%3D1.3%2C%20angle%20radius%3D0.5cm%5D%20%0A%7Bangle%3DA--B--C%7D%3B%0A%0A%5Cend%7Btikzpicture%7D&f=c&r=600&m=s&b=f&k=f">

## angle radius

```tex
\usetikzlibrary{angles}
\begin{tikzpicture}
\draw (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);
\draw pic[draw=black, angle eccentricity=1.3, angle radius=0.5cm] 
{angle=A--B--C};
\node[below] at(B) {0.5cm};


\draw[xshift=4cm] (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);
\draw pic[draw=black, angle eccentricity=1.3, angle radius=0.8cm] 
{angle=A--B--C};
\node[below] at(B) {0.8cm};

\draw[xshift=8cm] (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);
\draw pic[draw=black, angle eccentricity=1.3, angle radius=1cm] 
{angle=A--B--C};
\node[below] at(B) {1cm};
\end{tikzpicture}
```

<img src="https://texclip.marutank.net/render.php/texclip20230705034034.svg?s=%5Cusetikzlibrary%7Bangles%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%20(3%2C-1)%20coordinate%20(A)%20--%20(0%2C0)%20coordinate%20(B)%20--%20(2%2C2)%20coordinate%20(C)%3B%0A%5Cdraw%20pic%5Bdraw%3Dblack%2C%20angle%20eccentricity%3D1.3%2C%20angle%20radius%3D0.5cm%5D%20%0A%7Bangle%3DA--B--C%7D%3B%0A%5Cnode%5Bbelow%5D%20at(B)%20%7B0.5cm%7D%3B%0A%0A%0A%5Cdraw%5Bxshift%3D4cm%5D%20(3%2C-1)%20coordinate%20(A)%20--%20(0%2C0)%20coordinate%20(B)%20--%20(2%2C2)%20coordinate%20(C)%3B%0A%5Cdraw%20pic%5Bdraw%3Dblack%2C%20angle%20eccentricity%3D1.3%2C%20angle%20radius%3D0.8cm%5D%20%0A%7Bangle%3DA--B--C%7D%3B%0A%5Cnode%5Bbelow%5D%20at(B)%20%7B0.8cm%7D%3B%0A%0A%5Cdraw%5Bxshift%3D8cm%5D%20(3%2C-1)%20coordinate%20(A)%20--%20(0%2C0)%20coordinate%20(B)%20--%20(2%2C2)%20coordinate%20(C)%3B%0A%5Cdraw%20pic%5Bdraw%3Dblack%2C%20angle%20eccentricity%3D1.3%2C%20angle%20radius%3D1cm%5D%20%0A%7Bangle%3DA--B--C%7D%3B%0A%5Cnode%5Bbelow%5D%20at(B)%20%7B1cm%7D%3B%0A%5Cend%7Btikzpicture%7D&f=c&r=600&m=s&b=f&k=f">



## `angle eccentricity`

```tex
\usetikzlibrary{angles}
\begin{tikzpicture}
\draw (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);
\draw pic[draw=black, "A",angle eccentricity=0.5, angle radius=0.5cm] 
{angle=A--B--C};
\node[below=10pt](ang) at (B) {\verb|angle eccentricity|};
\node[below] at (ang) {\verb|0.5|};


\draw[xshift=4cm] (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);
\draw pic[draw=black, "A",angle eccentricity=0.8, angle radius=0.5cm] 
{angle=A--B--C};
\node[below=10pt](ang) at (B) {\verb|angle eccentricity|};
\node[below] at (ang) {\verb|0.8|};


\draw[xshift=8cm] (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);
\draw pic[draw=black, "A",angle eccentricity=1, angle radius=0.5cm] 
{angle=A--B--C};
\node[below=10pt](ang) at (B) {\verb|angle eccentricity|};
\node[below] at (ang) {\verb|1|};
\end{tikzpicture}
```

<img src="https://www.evernote.com/shard/s225/sh/421b032f-9885-35e3-70c8-7d5450586e42/IyCkWNReChbUL3BYEczvfG6BWhFS6ySpBslbl8xXbCnZWO1sPvPbYdwmjA/res/6935050d-af72-352e-5cb9-4e7610d3ca24">


```tex
\usetikzlibrary{angles}
\begin{tikzpicture}
\draw (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);
\draw pic[draw=black, "A",angle eccentricity=2, angle radius=0.5cm] 
{angle=A--B--C};
\node[below=10pt](ang) at (B) {\verb|angle radius|};
\node[below] at (ang) {\verb|0.5|};

\draw[xshift=6cm] (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);
\draw pic[draw=black, "A",angle eccentricity=2, angle radius=1cm] (ang)
{angle=A--B--C};
\node[below=10pt](ang) at (B) {\verb|angle radius|};
\node[below] at (ang) {\verb|1|};

\draw[xshift=12cm] (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);
\draw pic[draw=black, "A",angle eccentricity=2, angle radius=1.5cm] (ang)
{angle=A--B--C};
\node[below=10pt](ang) at (B) {\verb|angle radius|};
\node[below] at (ang) {\verb|1.5|};
\end{tikzpicture}
```
<img src="https://www.evernote.com/shard/s225/sh/421b032f-9885-35e3-70c8-7d5450586e42/IyCkWNReChbUL3BYEczvfG6BWhFS6ySpBslbl8xXbCnZWO1sPvPbYdwmjA/res/0f0f1dc0-5ded-5161-f944-b4669707737e">

## 矢印

```tex
\usetikzlibrary{angles}
\begin{tikzpicture}
\draw (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);

\node[right] at (A) {A};
\node[below] at (B) {B};
\node[right] at (C) {C};

\draw pic[draw=black, -latex, angle radius=0.5cm] (ang)
{angle=A--B--C};

\node[right=0.6cm] at (ang) {\verb|angle=A--B--C|};

\end{tikzpicture}
```

<img src="https://texclip.marutank.net/render.php/texclip20230705041801.svg?s=%5Cusetikzlibrary%7Bangles%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%20(3%2C-1)%20coordinate%20(A)%20--%20(0%2C0)%20coordinate%20(B)%20--%20(2%2C2)%20coordinate%20(C)%3B%0A%0A%5Cnode%5Bright%5D%20at%20(A)%20%7BA%7D%3B%0A%5Cnode%5Bbelow%5D%20at%20(B)%20%7BB%7D%3B%0A%5Cnode%5Bright%5D%20at%20(C)%20%7BC%7D%3B%0A%0A%5Cdraw%20pic%5Bdraw%3Dblack%2C%20-latex%2C%20angle%20radius%3D0.5cm%5D%20(ang)%0A%7Bangle%3DA--B--C%7D%3B%0A%0A%5Cnode%5Bright%3D0.6cm%5D%20at%20(ang)%20%7B%5Cverb%7Cangle%3DA--B--C%7C%7D%3B%0A%0A%5Cend%7Btikzpicture%7D&f=c&r=600&m=s&b=f&k=f">



矢印を始点に場合

```tex
\usetikzlibrary{angles}
\begin{tikzpicture}
\draw (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);

\node[right] at (A) {A};
\node[below] at (B) {B};
\node[right] at (C) {C};

\draw pic[draw=black, latex-, angle radius=0.5cm] (ang)
{angle=A--B--C};

\node[right=0.6cm] at (ang) {\verb|angle=A--B--C|};

\end{tikzpicture}
```
<img src="https://texclip.marutank.net/render.php/texclip20230705041933.svg?s=%5Cusetikzlibrary%7Bangles%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%20(3%2C-1)%20coordinate%20(A)%20--%20(0%2C0)%20coordinate%20(B)%20--%20(2%2C2)%20coordinate%20(C)%3B%0A%0A%5Cnode%5Bright%5D%20at%20(A)%20%7BA%7D%3B%0A%5Cnode%5Bbelow%5D%20at%20(B)%20%7BB%7D%3B%0A%5Cnode%5Bright%5D%20at%20(C)%20%7BC%7D%3B%0A%0A%5Cdraw%20pic%5Bdraw%3Dblack%2C%20latex-%2C%20angle%20radius%3D0.5cm%5D%20(ang)%0A%7Bangle%3DA--B--C%7D%3B%0A%0A%5Cnode%5Bright%3D0.6cm%5D%20at%20(ang)%20%7B%5Cverb%7Cangle%3DA--B--C%7C%7D%3B%0A%0A%5Cend%7Btikzpicture%7D&f=c&r=600&m=s&b=f&k=f">




始点と終点を入れ替えた場合
```tex
\usetikzlibrary{angles}
\begin{tikzpicture}
\draw (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);

\node[right] at (A) {A};
\node[below] at (B) {B};
\node[right] at (C) {C};

\draw pic[draw=black, -latex, angle radius=0.5cm] (ang)
{angle=C--B--A};

\node[right=0.6cm] at (ang) {\verb|angle=C--B--A|};

\end{tikzpicture}
```

<img src="https://texclip.marutank.net/render.php/texclip20230705043203.svg?s=%5Cusetikzlibrary%7Bangles%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%20(3%2C-1)%20coordinate%20(A)%20--%20(0%2C0)%20coordinate%20(B)%20--%20(2%2C2)%20coordinate%20(C)%3B%0A%0A%5Cnode%5Bright%5D%20at%20(A)%20%7BA%7D%3B%0A%5Cnode%5Bbelow%5D%20at%20(B)%20%7BB%7D%3B%0A%5Cnode%5Bright%5D%20at%20(C)%20%7BC%7D%3B%0A%0A%5Cdraw%20pic%5Bdraw%3Dblack%2C%20-latex%2C%20angle%20radius%3D0.5cm%5D%20(ang)%0A%7Bangle%3DC--B--A%7D%3B%0A%0A%5Cnode%5Bright%3D0.6cm%5D%20at%20(ang)%20%7B%5Cverb%7Cangle%3DC--B--A%7C%7D%3B%0A%0A%5Cend%7Btikzpicture%7D&f=c&r=600&m=s&b=f&k=f">




### 直角マーク

直角マークを入れたいときは，次のように`right`を付け加えます。

```tex
\usetikzlibrary{angles}
\begin{tikzpicture}
\draw (3,-1) coordinate (A) -- (0,0) coordinate (B) -- (2,2) coordinate (C);

\node[right] at (A) {A};
\node[below] at (B) {B};
\node[right] at (C) {C};

\draw pic[draw=black, angle radius=0.4cm]
{right angle=C--B--A};

\node[right=0.6cm] at (B) {\verb|right angle=C--B--A|};

\end{tikzpicture}
```

<img src="https://texclip.marutank.net/render.php/texclip20230712234817.svg?s=%5Cusetikzlibrary%7Bangles%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%20(3%2C-1)%20coordinate%20(A)%20--%20(0%2C0)%20coordinate%20(B)%20--%20(2%2C2)%20coordinate%20(C)%3B%0A%0A%5Cnode%5Bright%5D%20at%20(A)%20%7BA%7D%3B%0A%5Cnode%5Bbelow%5D%20at%20(B)%20%7BB%7D%3B%0A%5Cnode%5Bright%5D%20at%20(C)%20%7BC%7D%3B%0A%0A%5Cdraw%20pic%5Bdraw%3Dblack%2C%20angle%20radius%3D0.4cm%5D%0A%7Bright%20angle%3DC--B--A%7D%3B%0A%0A%5Cnode%5Bright%3D0.6cm%5D%20at%20(B)%20%7B%5Cverb%7Cright%20angle%3DC--B--A%7C%7D%3B%0A%0A%5Cend%7Btikzpicture%7D&f=c&r=300&m=s&b=f&k=f">

時計回り，反時計回り関係なく，小さく方の角に直角マークを付けます。





### `node`との相性の悪さ

nodeを使って点の名前を決めてしまうと，次のようになってしまいます。

```tex
\begin{document}
\usetikzlibrary{angles}
\begin{tikzpicture}
\draw (3,-1) node[right] (A) {A} -- (0,0) node[below] (B) {B} -- (2,2) node[right] (C) {C};

\draw pic[draw=black, -latex, angle radius=0.5cm] 
{angle=A--B--C};

\end{tikzpicture}
\end{document}
```

<img src="https://texclip.marutank.net/render.php/texclip20230705041058.svg?s=%5Cusetikzlibrary%7Bangles%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%20(3%2C-1)%20node%5Bright%5D%20(A)%20%7BA%7D%20--%20(0%2C0)%20node%5Bbelow%5D%20(B)%20%7BB%7D%20--%20(2%2C2)%20node%5Bright%5D%20(C)%20%7BC%7D%3B%0A%0A%5Cdraw%20pic%5Bdraw%3Dblack%2C%20-latex%2C%20angle%20radius%3D0.5cm%5D%20%0A%7Bangle%3DA--B--C%7D%3B%0A%0A%5Cend%7Btikzpicture%7D&f=c&r=600&m=s&b=f&k=f">







# 交点の求め方
2つの曲線に名前をつける。

```tex
\draw[name path = BD] (B) -- (D);
\draw[name path = AC] (A) -- (C);
```

オプション`name path = #文字列`で名前を付けることができる。パスが存在すればよいので，`\draw`ではなく`\path`でもよい。

```tex

\node[name intersections = {of = BD and AC, by ={E}}] at (E) {E(交点)}; 

```

オプションに交点を計算させるコマンドを入れる。`{of = BD and AC}`はパスBDとパスACの名前を書いてパスを指定している。`by = {E}`は交点に（座標として）名前を付けている。このオプションは省略できる。その場合，交点の名前は`intersection-1`となる。

交点が複数ある場合は`intersection-1`，`intersection-2`，`intersection-3`...となる。どのような順番で決定されているかは謎。