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/827952001a3f214b033187a00aca3bc0 to your computer and use it in GitHub Desktop.
Save shihashi/827952001a3f214b033187a00aca3bc0 to your computer and use it in GitHub Desktop.
Draw a circumcircle 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{\b/(2*sin(\B))}
\coordinate (B) at (0,0);
\coordinate (C) at (\a,0);
\coordinate (A) at ({\B}:\c);
\coordinate (circumcenter)
at (barycentric cs:%
A={\a^2*(-\a^2+\b^2+\c^2)},%
B={\b^2*(\a^2-\b^2+\c^2)},%
C={\c^2*(\a^2+\b^2-\c^2)});
\draw (A)--(B)--(C)--cycle;
\draw (circumcenter) 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