Skip to content

Instantly share code, notes, and snippets.

@shihashi
Last active June 5, 2021 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shihashi/9e90224be537457b58ad0bdb0687d26c to your computer and use it in GitHub Desktop.
Save shihashi/9e90224be537457b58ad0bdb0687d26c to your computer and use it in GitHub Desktop.
Draw a incircle given the length of the three sides of the triangle.
\documentclass{article}% Typeset by pdfLaTeX
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\a{2}
\def\b{3}
\def\c{4}
\def\B{acos((\c^2+\a^2-\b^2)/(2*\a*\c))}
\def\r{\a*\c*sin(\B)/(\a+\b+\c)}
\coordinate (B) at (0,0);
\coordinate (C) at (\a,0);
\coordinate (A) at ({\B}:\c);
\coordinate (incenter) at (barycentric cs:A=\a,B=\b,C=\c);
\draw (A)--(B)--(C)--cycle;
\draw (incenter) circle[radius={\r}];
\end{tikzpicture}
\end{document}
%
% Reference
%
% PGF Manual 139-140
% https://pgf-tikz.github.io/pgf/pgfmanual.pdf
% (accessed 2021-06-05)
%
% GitHub - mebiolabo/EulerLine
% https://github.com/mebio-labo/EulerLine
% (accessed 2021-06-05)
%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment