이 원의 반경을 어떻게 정확하게 표시할 수 있나요?

이 원의 반경을 어떻게 정확하게 표시할 수 있나요?

이 원의 반경을 표시하고 싶습니다. 반경의 올바른 결과는 입니다 7/sqrt(3). 내 코드.

\documentclass[border = 1mm]{standalone} 
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{intersections,calc,backgrounds,fpu} 
\newcommand{\PgfmathsetmacroFPU}[2]{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathsetmacro{#1}{#2}%
\pgfmathsmuggle#1\endgroup}
\begin{document}
\tdplotsetmaincoords{70}{80}
\begin{tikzpicture}[tdplot_main_coords,line join = round, line cap = round]
    \pgfmathsetmacro{\a}{5} 
    \pgfmathsetmacro{\b}{7} 
    \pgfmathsetmacro{\c}{8} 
    \PgfmathsetmacroFPU{\myr}{{sqrt(-
     pow(\a,2) *pow(\b,2)* pow(\c,2)/ (pow(\a,4)  + pow(\b,4)  + pow(\c,4)- 2
     *pow(\a,2) *pow(\b,2)  - 2*pow(\c,2) *pow(\b,2)-2*pow(\c,2) *pow(\a,2) ))}}

    \coordinate (A) at (0,0,0);
    \coordinate (B) at (\c,0,0);
    \coordinate (C) at  ({(pow(\b,2) + pow(\c,2) - pow(\a,2))/(2*\c)},{sqrt((\a+\b-\c) *(\a-\b+\c) *(-\a+\b+\c)* (\a+\b+\c))/(2*\c)},0);
    \coordinate (T) at  (\c/2, {\c* (\a*\a + \b*\b - \c*\c)/(2*sqrt((\a+\b-\c) *(\a-\b+\c)* (-\a+\b+\c)* (\a+\b+\c)))},0);
    \foreach \point/\position in {A/left,B/below,C/right,T/below}
    {
        \fill (\point) circle (1.8pt);
        \node[\position=3pt] at (\point) {$\point$};
    }
    \begin{scope}[canvas is xy plane at z=0]
    \draw[thick] (T) circle (\myr); 
    \end{scope}
 \pgfmathparse{\myr}
 \pgfmathresult
\end{tikzpicture}
   \end{document}

나는 노력했다

\pgfmathparse{\myr}
 \pgfmathresult

결과를 얻을 수 없습니다. 수동이 아닌 자동으로 결과를 얻으려면 어떻게 해야 합니까?

답변1

pgf에는 분수 감지 등에 대한 지원이 매우 제한되어 있으며 제곱근이 포함되자마자 몇 가지 작업을 직접 수행해야 한다고 생각합니다. (공평하게 말하면, 컴퓨터 대수학 시스템도 그러한 표현식을 감지하는 데는 적합하지 않지만 이를 사용하여 표현식을 구문 분석하면 정확한 결과를 얻을 수 있습니다. 그러나 LaTeX는 그러한 컴퓨터 대수학 시스템이 아닙니다.) 키를 사용할 수 있습니다.

\pgfkeys{/pgf/number format/.cd,frac, frac denom=3,frac whole=false}

획득하다

\documentclass[border = 1mm]{standalone} 
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{intersections,calc,backgrounds,fpu} 
\newcommand{\PgfmathsetmacroFPU}[2]{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathsetmacro{#1}{#2}%
\pgfmathsmuggle#1\endgroup}
\begin{document}
\tdplotsetmaincoords{70}{80}
\begin{tikzpicture}[tdplot_main_coords,line join = round, line cap = round]
    \pgfmathsetmacro{\a}{5} 
    \pgfmathsetmacro{\b}{7} 
    \pgfmathsetmacro{\c}{8} 
    \PgfmathsetmacroFPU{\myr}{{sqrt(-
     pow(\a,2) *pow(\b,2)* pow(\c,2)/ (pow(\a,4)  + pow(\b,4)  + pow(\c,4)- 2
     *pow(\a,2) *pow(\b,2)  - 2*pow(\c,2) *pow(\b,2)-2*pow(\c,2) *pow(\a,2) ))}}

    \coordinate (A) at (0,0,0);
    \coordinate (B) at (\c,0,0);
    \coordinate (C) at  ({(pow(\b,2) + pow(\c,2) - pow(\a,2))/(2*\c)},{sqrt((\a+\b-\c) *(\a-\b+\c) *(-\a+\b+\c)* (\a+\b+\c))/(2*\c)},0);
    \coordinate (T) at  (\c/2, {\c* (\a*\a + \b*\b - \c*\c)/(2*sqrt((\a+\b-\c) *(\a-\b+\c)* (-\a+\b+\c)* (\a+\b+\c)))},0);
    \foreach \point/\position in {A/left,B/below,C/right,T/below}
    {
        \fill (\point) circle (1.8pt);
        \node[\position=3pt] at (\point) {$\point$};
    }
    \begin{scope}[canvas is xy plane at z=0]
    \draw[thick] (T) circle (\myr); 
    \end{scope}
 \draw (T)  -- (C) node[midway,sloped,fill=white] {%
 \pgfmathparse{\myr/sqrt(3)}%
 \pgfkeys{/pgf/number format/.cd,frac, frac denom=3,frac whole=false}%  
 $\pgfmathprintnumber{\pgfmathresult}\cdot\sqrt{3}\,$cm};
\end{tikzpicture}
\end{document}

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

물론 그보다 더 잘할 수도 있지만 내가 아는 한 필요한 정수 연산을 수행하기 위한 루틴은 아직 구현되지 않았습니다 pgf(그리고 이에 대한 실제 패키지가 없을 가능성도 약간 있습니다). 가장 큰 장애물은 gcd분수의 공통 인수를 취소하는 데 매우 유용한 가 아직 작동하지 않는다는 것입니다 fpu. 반면에 fpu숫자가 너무 크기 때문에 여기에 필요합니다. 그래서 나는 정수로 요소의 거듭제곱을 결정할 수 있는 것과 같은 다양한 루틴 gcd(이라고 함 gcdFPU)과 기타 여러 루틴을 추가했습니다. integerpower예를 들어, 이후부터 integerpower(12,2)산출됩니다 . 이것은 제곱근에서 제곱을 끌어내는 데 사용될 수 있습니다. 212=2^2 times something that is not divisible by 2

\documentclass[tikz,border=1mm]{standalone} 
\usepackage{tikz-3dplot}
\usetikzlibrary{fpu} 
\newcounter{ifactor}
\newcommand{\PgfmathsetmacroFPU}[2]{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathsetmacro{#1}{#2}%
\pgfmathsmuggle#1\endgroup}
\newcommand{\PgfmathtruncatemacroFPU}[2]{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathtruncatemacro{#1}{round(#2)}%
\pgfmathsmuggle#1\endgroup}
% the following functions are based on 
% * https://tex.stackexchange.com/a/177109 (digitcount,digitsum,lastdigit)
% * https://tex.stackexchange.com/a/501895 (memberQ)
% or new in the sense that they were developed on the basis of the existing
% pgf functions
\makeatletter
\newcount\c@Digits
\newcount\c@Powers
\pgfmathdeclarefunction{digitcount}{1}{%
  \begingroup%
  \global\c@Digits=0
  \expandafter\DigitCount@i#1\@nil%
  \pgfmathparse{int(\the\c@Digits)}%
  \pgfmathsmuggle\pgfmathresult\endgroup}
% \def\GroupDigits#1{%
%   \global\c@Digits=0
%   \expandafter\DigitCount@i#1\@nil%
%   \pgfmathparse{int(\the\c@Digits)}}
\def\DigitCount@i#1#2\@nil{%
  \advance\c@Digits by \@ne
  \ifx\relax#2\relax\else\DigitCount@i#2\@nil\fi
}
\pgfmathdeclarefunction{digitsum}{1}{%
  \begingroup%
  \global\c@Digits=0
  \expandafter\DigitSum@i#1\@nil%
  \pgfmathparse{int(\the\c@Digits)}%
    \pgfmathsmuggle\pgfmathresult\endgroup}
% \def\DigitSum#1{%
%   \global\c@Digits=0
%   \expandafter\DigitSum@i#1\@nil%
%   \pgfmathparse{int(\the\c@Digits)}}
\def\DigitSum@i#1#2\@nil{%
  \advance\c@Digits by #1
  \ifx\relax#2\relax\else\DigitSum@i#2\@nil\fi
}
\pgfmathdeclarefunction{lastdigit}{1}{%
  \begingroup%
    \global\c@Digits=0
    \expandafter\LastDigit@i#1\@nil%
    \pgfmathparse{int(\the\c@Digits)}%
    \pgfmathsmuggle\pgfmathresult\endgroup}
% \def\LastDigit#1{%
%   \global\c@Digits=0
%   \expandafter\LastDigit@i#1\@nil%
%   \pgfmathparse{int(\the\c@Digits)}}
\def\LastDigit@i#1#2\@nil{%
  \c@Digits=#1
  \ifx\relax#2\relax\else\LastDigit@i#2\@nil\fi
}
\pgfmathdeclarefunction{integerpower}{2}{%
  \begingroup%
    \global\c@Powers=0%
    \pgfmathtruncatemacro{\pgfutil@tmpa}{#1}%
    \loop\pgfmathtruncatemacro{\itest}{gcd(\pgfutil@tmpa,#2)}%0
    \ifnum\itest>1\relax%
    \advance\c@Powers by \@ne%
    \pgfmathtruncatemacro{\pgfutil@tmpa}{\pgfutil@tmpa/#2}%
    \repeat%
    \pgfmathparse{int(\the\c@Powers)}%
    \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{integerpower2}{1}{% works with large numbers
  \begingroup%
    \pgfkeys{/pgf/fpu=false}%
    \global\c@Powers=0%
    \PgfmathtruncatemacroFPU{\pgfutil@tmpa}{#1}%
    \loop%
    \pgfmathtruncatemacro{\pgfutil@tmpb}{lastdigit(\pgfutil@tmpa)}%
    \pgfmathtruncatemacro{\itest}{iseven(\pgfutil@tmpb)}%
    \ifnum\itest=1%
    \advance\c@Powers by \@ne%
    \PgfmathtruncatemacroFPU{\pgfutil@tmpa}{\pgfutil@tmpa/2}%
    \repeat%
    \pgfmathparse{int(\the\c@Powers)}%
    \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{integerpower3}{1}{% works with large numbers
  \begingroup%
    \pgfkeys{/pgf/fpu=false}%
    \global\c@Powers=0%
    \PgfmathtruncatemacroFPU{\pgfutil@tmpa}{#1}%
    \loop%
    \pgfmathtruncatemacro{\itest}{divby3(\pgfutil@tmpa)}%
    \ifnum\itest=1%
    \advance\c@Powers by \@ne%
    \PgfmathtruncatemacroFPU{\pgfutil@tmpa}{\pgfutil@tmpa/3}%
    \repeat%
    \pgfmathparse{int(\the\c@Powers)}%
    \pgfmathsmuggle\pgfmathresult\endgroup} 
\pgfmathdeclarefunction{memberQ}{2}{%
  \begingroup%
    \edef\pgfutil@tmpb{0}%
    \edef\pgfutil@tmpa{#2}%
    \expandafter\pgfmath@member@i\pgfutil@firstofone#1\pgfmath@token@stop
    \edef\pgfmathresult{\pgfutil@tmpb}%
    \pgfmath@smuggleone\pgfmathresult%
  \endgroup}
\def\pgfmath@member@i#1{%
    \ifx\pgfmath@token@stop#1%
    \else
      \ifnum#1=\pgfutil@tmpa\relax%
      \gdef\pgfutil@tmpb{1}%
      \fi%
      \expandafter\pgfmath@member@i
    \fi} 
\pgfmathdeclarefunction{isevenFPU}{1}{%
  \begingroup%
  \pgfmathparse{iseven(lastdigit(#1))}%
    \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{isoddFPU}{1}{%
  \begingroup%
  \pgfmathparse{isodd(lastdigit(#1))}%
    \pgfmathsmuggle\pgfmathresult\endgroup}        
\pgfmathdeclarefunction{divby3}{1}{%
  \begingroup%
  \pgfmathparse{memberQ({3,6,9},digitsum(digitsum(#1)))}%
  \pgfmathsmuggle\pgfmathresult\endgroup}   
\pgfmathdeclarefunction{gcdFPU}{2}{%
  \begingroup
    \pgfkeys{/pgf/fpu=false}%
    \pgfmathcontinuelooptrue
    \PgfmathtruncatemacroFPU{\pgfutil@tmpa}{#1}%
    \PgfmathtruncatemacroFPU{\pgfutil@tmpb}{#2}%
    \PgfmathtruncatemacroFPU{\itest}{ifthenelse(\pgfutil@tmpa==0,1,0)}%
    \ifnum\itest=1\relax
      \pgfmathcontinueloopfalse
      \PgfmathtruncatemacroFPU{\pgfutil@tmpa}{\pgfutil@tmpb}%
    \fi%
    \PgfmathtruncatemacroFPU{\itest}{ifthenelse(\pgfutil@tmpb==0,1,0)}%
    \ifnum\itest=1\relax
      \pgfmathcontinueloopfalse
      \PgfmathtruncatemacroFPU{\pgfutil@tmpb}{\pgfutil@tmpa}%
    \fi%
    \PgfmathtruncatemacroFPU{\pgfutil@tmpa}{abs(\pgfutil@tmpa)}%
    \PgfmathtruncatemacroFPU{\pgfutil@tmpb}{abs(\pgfutil@tmpb)}%
    \loop
      \ifpgfmathcontinueloop%
      \PgfmathtruncatemacroFPU{\itest}{ifthenelse(\pgfutil@tmpa==\pgfutil@tmpb,1,0)}%
      \ifnum\itest=1\relax
        \pgfmathcontinueloopfalse
      \else
        \PgfmathtruncatemacroFPU{\itest}{ifthenelse(\pgfutil@tmpa>\pgfutil@tmpb,1,0)}%
        \ifnum\itest=1\relax
          \PgfmathtruncatemacroFPU{\pgfutil@tmpa}{\pgfutil@tmpa-\pgfutil@tmpb}%
        \else
          \PgfmathtruncatemacroFPU{\pgfutil@tmpb}{\pgfutil@tmpb-\pgfutil@tmpa}%
        \fi
      \fi
    \repeat
    \PgfmathtruncatemacroFPU\pgfmathresult{\pgfutil@tmpa}%
    \pgfmathsmuggle\pgfmathresult\endgroup}
\pgfmathdeclarefunction{factorinteger}{1}{%
\begingroup% not yet done
\endgroup
}  
\makeatother

\newcommand{\Pgfmathfraction}[3]{\begingroup%
\pgfmathtruncatemacro{\mynumerator}{#2/gcd(#2,#3)}%
\pgfmathtruncatemacro{\mydenominator}{#3/gcd(#2,#3)}%
\pgfmathsmuggle#1\endgroup}
\begin{document}
\tdplotsetmaincoords{70}{80}
\foreach \a/\b/\c in {3/4/5,6/7/8,5/7/8}
{\begin{tikzpicture}[tdplot_main_coords,line join = round, line cap = round,
declare function={numerator(\a,\b,\c)=pow(\a,2) *pow(\b,2)* pow(\c,2);
denominator(\a,\b,\c)=-pow(\a,4)  - pow(\b,4)  - pow(\c,4)+% 
2*pow(\a,2) *pow(\b,2)+2*pow(\c,2) *pow(\b,2)+2*pow(\c,2)*pow(\a,2);}]
 \begin{scope}[local bounding box=elli]
    \PgfmathtruncatemacroFPU{\mynumerator}{numerator(\a,\b,\c)}
    \PgfmathtruncatemacroFPU{\mydenominator}{denominator(\a,\b,\c)}
    \PgfmathtruncatemacroFPU{\mygcd}{gcdFPU(\mynumerator,\mydenominator)}
    \message{numerator=\mynumerator,denominator=\mydenominator,gcd=\mygcd^^J}
    \PgfmathtruncatemacroFPU{\newnumerator}{\mynumerator/\mygcd}
    \PgfmathtruncatemacroFPU{\newdenominator}{\mydenominator/\mygcd}
    \message{new numerator=\newnumerator,new denominator=\newdenominator^^J}
    \pgfmathtruncatemacro{\myprenum}{1}
    \pgfmathtruncatemacro{\mypreden}{1}
    \foreach \Prime in {2,3,5,7,11,13,17}
    {\pgfmathtruncatemacro{\myint}{integerpower(\newnumerator,\Prime)}
     \ifnum\myint>1
      \pgfmathtruncatemacro{\myint}{2*int(\myint/2)}
      \PgfmathtruncatemacroFPU{\newnumerator}{\newnumerator/pow(\Prime,\myint)}
      \xdef\newnumerator{\newnumerator}
      \pgfmathtruncatemacro{\myprenum}{\myprenum*pow(\Prime,\myint/2)}
      \xdef\myprenum{\myprenum}
     \fi
    \pgfmathtruncatemacro{\myint}{integerpower(\newdenominator,\Prime)}
     \ifnum\myint>0
      \pgfmathtruncatemacro{\myint}{2*int(\myint/2)}
      \PgfmathtruncatemacroFPU{\newdenominator}{\newdenominator/pow(\Prime,\myint)}
      \xdef\newdenominator{\newdenominator}
      \pgfmathtruncatemacro{\mypreden}{\mypreden*pow(\Prime,\myint/2)}
      \xdef\mypreden{\mypreden}
     \fi
    }
    \message{new numerator=\newnumerator, pre num=\myprenum,new
    denominator=\newdenominator, pre den=\mypreden^^J}
    \pgfmathsetmacro{\myr}{(\myprenum/\mypreden)*sqrt(\newnumerator/\newdenominator)}
    \coordinate (A) at (0,0,0);
    \coordinate (B) at (\c,0,0);
    \coordinate (C) at  ({(pow(\b,2) + pow(\c,2) - pow(\a,2))/(2*\c)},{sqrt((\a+\b-\c) *(\a-\b+\c) *(-\a+\b+\c)* (\a+\b+\c))/(2*\c)},0);
    \coordinate (T) at  (\c/2, {\c* (\a*\a + \b*\b - \c*\c)/(2*sqrt((\a+\b-\c) *(\a-\b+\c)* (-\a+\b+\c)* (\a+\b+\c)))},0);
    \foreach \point/\position in {A/left,B/below,C/right,T/below}
    {
        \fill (\point) circle (1.8pt);
        \node[\position=3pt] at (\point) {$\point$};
    }
    \begin{scope}[canvas is xy plane at z=0]
    \draw[thick] (T) circle (\myr); 
    \end{scope}
 \draw (T)  -- (C) node[midway,sloped,fill=white] {%
 $\displaystyle\ifnum\mypreden=1
  \myprenum
 \else
  \frac{\myprenum}{\mypreden}
 \fi
 \ifnum\newdenominator=1
  \ifnum\newnumerator=1
  \else
   \cdot\sqrt{\newnumerator}
  \fi
 \else 
  \ifnum\newnumerator=1
   \cdot\frac{1}{\sqrt{\newdenominator}}
  \else
   \cdot\sqrt{\frac{\newnumerator}{\newdenominator}}
  \fi
 \fi\,$cm};
 \end{scope}
 \node[above] at (elli.north){$a=\a,b=\b,c=\c$};
\end{tikzpicture}}
\end{document}

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

관련 정보