TikZ: 삼각형의 내심 좌표 얻기

TikZ: 삼각형의 내심 좌표 얻기

좌표를 얻고 싶습니다.삼각형의 내심. 매크로 갖고싶다

\incenter{name}{a}{b}{c}

정점의 좌표가 , , name인 삼각형의 중심에 좌표를 설정합니다 .abc

나는 사용하고 싶었다이 계산명령 과 함께 직교 좌표를 사용 let하지만 좌표에서는 작동하지 않습니다.

답변1

tkz-euclide이는 문서( texdoc -s euclide) 에서 거의 직접 가져온 것입니다 .

\documentclass[border=2mm]{standalone}

\usepackage{tkz-euclide}
\usetkzobj{all}

\newcommand{\incenter}[4]{%
    \begin{tikzpicture}
        \tkzInit[xmax=5,ymax=4]
        \tkzClip
        \tkzDefPoint(0,0){#2} %% Put the coordinates here
        \tkzDefPoint(5,1){#3} %% for the desired
        \tkzDefPoint(1,4){#4} %% triangle.
        \tkzDrawPolygon[color=red](#2,#3,#4)
        \tkzInCenter(#2,#3,#4)
        \tkzGetPoint{G}
        \tkzDrawPoint(G)
        \node[below] at (G) {#1};
    \end{tikzpicture}
}

\begin{document}

\incenter{name}{a}{b}{c}

\end{document}

tkz-euclide incenter의 예

하나 더. 를 사용하여 임의의 삼각형을 지정하려면 \incenter다음을 시도해 볼 수 있습니다.

\documentclass[border=2mm]{standalone}

\usepackage{tkz-euclide}
\usetkzobj{all}

\newcommand{\incenter}[2]{%
    \begin{tikzpicture}
        \foreach \x/\y [count=\i from 1] in {#2}{\tkzDefPoint(\x,\y){n-\i}}
        \tkzInit[xmax=5,ymax=4]
        \tkzClip
        \tkzDrawPolygon[color=red](n-1,n-2,n-3)
        \tkzInCenter(n-1,n-2,n-3)
        \tkzGetPoint{G}
        \tkzDrawPoint(G)
        \node[below] at (G) {#1};
    \end{tikzpicture}
}

\begin{document}

\incenter{Incenter!}{0/0.5,5/3,1/4}% {label}{x_1/y_1,x_2/y_2,x_3/y_3}

\end{document}

여기에 이미지 설명을 입력하세요

답변2

포인트 단위로 작업해도 괜찮다면:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}[x=1pt, y=1pt]
\draw [thick] (0, 0) coordinate (A) -- (20, 40) coordinate (B)
   -- (40, 10) coordinate (C) -- cycle;
\tikzmath{%
  coordinate \p, \I;
  \p1 = (A); \p2 = (B); \p3 = (C);
  \a = veclen(\px3-\px2, \py3-\py2);
  \b = veclen(\px1-\px3, \py1-\py3);
  \c = veclen(\px2-\px1, \py2-\py1);
  % Get the inradius
  \s = (\a + \b + \c) / 2;
  \K = sqrt(\s) * sqrt(\s - \a) * sqrt(\s - \b) * sqrt(\s - \c);
  \r = \K / \s;
  % Normalize the lengths a bit
  \m = max(\a, \b, \c);
  \a = \a / \m; \b = \b / \m; \c = \c / \m;
  % Get the incenter
  \ix = (\a*\px1 + \b*\px2 + \c*\px3) / (\a + \b + \c);
  \iy = (\a*\py1 + \b*\py2 + \c*\py3) / (\a + \b + \c);
  \I = (\ix, \iy);
}
\fill (\I) circle [radius=1];
\draw [red] (\I) circle [radius=\r];
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보