3

Based on the question at here How can I draw a circle knowing center and radius lies on a plane?

I tried to draw the circle passing through A, H, K. enter image description here

I can not the result when I in put the line

\draw[blue,thick,circle in plane with normal={{\mynormal} with radius {\RAHK} around (I')}];

How can I get the result?

\documentclass[border=1mm,tikz,12pt]{standalone} 
\usepackage{fouriernc} 
\usepackage{tikz-3dplot} 
\usetikzlibrary{calc,backgrounds,angles} 
\usepackage{tkz-euclide,amsmath} 
\usetkzobj{all} 
\usepackage{pgfplots} 
\pgfplotsset{compat=1.16}
\makeatletter 
        \newcounter{smuggle} 
        \DeclareRobustCommand\smuggleone[1]{% 
            \stepcounter{smuggle}% 
            \expandafter\global\expandafter\let\csname smuggle@\arabic{smuggle}\endcsname#1% 
            \aftergroup\let\aftergroup#1\expandafter\aftergroup\csname smuggle@\arabic{smuggle}\endcsname 
        } 
        \DeclareRobustCommand\smuggle[2][1]{% 
            \smuggleone{#2}% 
            \ifnum#1>1 
            \aftergroup\smuggle\aftergroup[\expandafter\aftergroup\the\numexpr#1-1\aftergroup]\aftergroup#2% 
            \fi 
        } 
        \makeatother 
        \def\parsecoord(#1,#2,#3)>(#4,#5,#6){% 
            \def#4{#1}% 
            \def#5{#2}% 
            \def#6{#3}% 
            \smuggle{#4}% 
            \smuggle{#5}% 
            \smuggle{#6}% 
        } 
        \def\SPTD(#1,#2,#3).(#4,#5,#6){((#1)*(#4)+1*(#2)*(#5)+1*(#3)*(#6))} 
        \def\VPTD(#1,#2,#3)x(#4,#5,#6){((#2)*(#6)-1*(#3)*(#5),(#3)*(#4)-1*(#1)*(#6),(#1)*(#5)-1*(#2)*(#4))} 
        \def\VecMinus(#1,#2,#3)-(#4,#5,#6){(#1-1*(#4),#2-1*(#5),#3-1*(#6))} 
        \def\VecAdd(#1,#2,#3)+(#4,#5,#6){(#1+1*(#4),#2+1*(#5),#3+1*(#6))} 
        \newcommand{\RotationAnglesForPlaneWithNormal}[5]{%\typeout{N=(#1,#2,#3)}
            \foreach \XS in {1,-1}
            {\foreach \YS in {1,-1}
                {\pgfmathsetmacro{\mybeta}{\XS*acos(#3)} 
                    \pgfmathsetmacro{\myalpha}{\YS*acos(#1/sin(\mybeta))} 
                    \pgfmathsetmacro{\ntest}{abs(cos(\myalpha)*sin(\mybeta)-#1)%
                        +abs(sin(\myalpha)*sin(\mybeta)-#2)+abs(cos(\mybeta)-#3)}
                    \ifdim\ntest pt<0.1pt
                    \xdef#4{\myalpha}   
                    \xdef#5{\mybeta}
                    \fi
            }}
        } 
        \tikzset{circle in plane with normal/.style args={#1 with radius #2 around #3}{ 
                /utils/exec={\edef\temp{\noexpand\parsecoord#1>(\noexpand\myNx,\noexpand\myNy,\noexpand\myNz)} 
                    \temp 
                    \pgfmathsetmacro{\myNx}{\myNx} 
                    \pgfmathsetmacro{\myNy}{\myNy} 
                    \pgfmathsetmacro{\myNz}{\myNz} 
                    \pgfmathsetmacro{\myNormalization}{sqrt(pow(\myNx,2)+pow(\myNy,2)+pow(\myNz,2))} 
                    \pgfmathsetmacro{\myNx}{\myNx/\myNormalization} 
                    \pgfmathsetmacro{\myNy}{\myNy/\myNormalization} 
                    \pgfmathsetmacro{\myNz}{\myNz/\myNormalization} 
                    % compute the rotation angles that transform us in the corresponding plabe 
                    \RotationAnglesForPlaneWithNormal{\myNx}{\myNy}{\myNz}{\tmpalpha}{\tmpbeta} 
                    %\typeout{N=(\myNx,\myNy,\myNz),alpha=\tmpalpha,beta=\tmpbeta,r=#2,#3} 
                    \tdplotsetrotatedcoords{\tmpalpha}{\tmpbeta}{0}}, 
                insert path={[tdplot_rotated_coords,canvas is xy plane at z=0,transform shape] 
                    #3 circle[radius=#2]} 
        }} 

    \tikzset{reverseclip/.style={insert path={(current bounding box.south west)rectangle 
                (current bounding box.north east)} }}
\begin{document} 
    \tdplotsetmaincoords{70}{90}
    \begin{tikzpicture}[tdplot_main_coords,scale=1,line cap=butt,line join=round]
    \pgfmathsetmacro\a{5} 
    \pgfmathsetmacro\R{1/2*\a} 
    \pgfmathsetmacro\h{\a}
    \pgfmathsetmacro\angB{-30} 
    \def\r{1/2*\a}
\pgfmathsetmacro\RAHK{1/2*sqrt(\h^2*\a^2/(\a^2+\h^2))}

\pgfmathsetmacro\RBHKC{sqrt((4*sin(\angB)*\R*\a^3-4*\h^2*sin(\angB)*\R*\a+4*\R^2*\a^2+4*\R^2*\h^2+\a^4+\a^2*\h^2)/(4*\R^2+4*\a*\R*sin(\angB)+\a^2+4*\h^2))} 

\typeout{\RAHK,\RBHKC} 
    \coordinate (A) at (0,0,0) ; 
    \coordinate (C) at (0,\a,0);
    \coordinate (B) at ({ \R*cos(\angB)}, {\a/2 + \R*sin(\angB)},0); 

    \coordinate (S) at (0,0,\h); 
    \coordinate (O) at ($ (A)!0.5!(C) $);
    \coordinate (H) at ({4*\h*\h*\R*cos(\angB)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)}, {2*\h*\h*(2*\R*sin(\angB)+\a)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)}, {\h*(4*\R^2+4*\a*\R*sin(\angB)+\a*\a)/(4*\R*\R+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)});
    \coordinate (K) at (0, {\h*\h*\a/(\a*\a+\h*\h)}, {\h*\a*\a/(\a*\a+\h*\h)});

    \coordinate (I') at ($(K)!0.5!(A) $); 
    \coordinate (I) at ($(C)!0.5!(H) $);

\foreach \v/\position in { B/below,C/right,A/left,S/above,K/above,H/right,O/below} {\draw[draw =black, fill=black] (\v) circle (1.3pt) node [\position=0.2mm] {$\v$}; 
    } 

    \draw[thick] (S) -- (A) (S) -- (B) (S) -- (C)   (A) -- (B) -- (C) (A) --  (H) --  (K) ; 
    \draw[dashed]  (A)   -- (K) (A)   --(C) ; 

    \parsecoord(0,0,0)>(\myAx,\myAy,\myAz) 
    \parsecoord({4*\h*\h*\R*cos(\angB)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)}, {2*\h*\h*(2*\R*sin(\angB)+\a)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)}, {\h*(4*\R^2+4*\a*\R*sin(\angB)+\a*\a)/(4*\R*\R+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)})>(\myHx,\myHy,\myHz)
    \parsecoord(0, {\h*\h*\a/(\a*\a+\h*\h)}, {\h*\a*\a/(\a*\a+\h*\h)})>(\myKx,\myKy,\myKz)

    \def\mynormal{\VPTD({\myHx-\myAx},{\myHy-\myAy},{\myHz-\myAz})x({\myKx-\myAx},{\myKy-\myAy},{\myKz-\myAz})} 
    \edef\temp{\noexpand\parsecoord\mynormal>(\noexpand\myNx,\noexpand\myNy,\noexpand\myNz)} 
    \draw[blue,thick,circle in plane with normal={{\mynormal} with radius {\RAHK} around (I')}];    

    \end{tikzpicture} 

\end{document}
4

The problems are caused by the extra { and } you have in

\parsecoord({4*\h*\h*\R*cos(\angB)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)}, {2*\h*\h*(2*\R*sin(\angB)+\a)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)}, {\h*(4*\R^2+4*\a*\R*sin(\angB)+\a*\a)/(4*\R*\R+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)})>(\myHx,\myHy,\myHz)
\parsecoord(0, {\h*\h*\a/(\a*\a+\h*\h)}, {\h*\a*\a/(\a*\a+\h*\h)})>(\myKx,\myKy,\myKz)

If you remove them, you get

\documentclass[border=1mm,tikz,12pt]{standalone} 
\usepackage{fouriernc} 
\usepackage{tikz-3dplot} 
\usetikzlibrary{backgrounds,angles} 
\makeatletter 
        \newcounter{smuggle} 
        \DeclareRobustCommand\smuggleone[1]{% 
            \stepcounter{smuggle}% 
            \expandafter\global\expandafter\let\csname smuggle@\arabic{smuggle}\endcsname#1% 
            \aftergroup\let\aftergroup#1\expandafter\aftergroup\csname smuggle@\arabic{smuggle}\endcsname 
        } 
        \DeclareRobustCommand\smuggle[2][1]{% 
            \smuggleone{#2}% 
            \ifnum#1>1 
            \aftergroup\smuggle\aftergroup[\expandafter\aftergroup\the\numexpr#1-1\aftergroup]\aftergroup#2% 
            \fi 
        } 
        \makeatother 
        \def\parsecoord(#1,#2,#3)>(#4,#5,#6){% 
            \def#4{#1}% 
            \def#5{#2}% 
            \def#6{#3}% 
            \smuggle{#4}% 
            \smuggle{#5}% 
            \smuggle{#6}% 
        } 
        \def\SPTD(#1,#2,#3).(#4,#5,#6){((#1)*(#4)+1*(#2)*(#5)+1*(#3)*(#6))} 
        \def\VPTD(#1,#2,#3)x(#4,#5,#6){((#2)*(#6)-1*(#3)*(#5),(#3)*(#4)-1*(#1)*(#6),(#1)*(#5)-1*(#2)*(#4))} 
        \def\VecMinus(#1,#2,#3)-(#4,#5,#6){(#1-1*(#4),#2-1*(#5),#3-1*(#6))} 
        \def\VecAdd(#1,#2,#3)+(#4,#5,#6){(#1+1*(#4),#2+1*(#5),#3+1*(#6))} 
        \newcommand{\RotationAnglesForPlaneWithNormal}[5]{%\typeout{N=(#1,#2,#3)}
            \foreach \XS in {1,-1}
            {\foreach \YS in {1,-1}
                {\pgfmathsetmacro{\mybeta}{\XS*acos(#3)} 
                    \pgfmathsetmacro{\myalpha}{\YS*acos(#1/sin(\mybeta))} 
                    \pgfmathsetmacro{\ntest}{abs(cos(\myalpha)*sin(\mybeta)-#1)%
                        +abs(sin(\myalpha)*sin(\mybeta)-#2)+abs(cos(\mybeta)-#3)}
                    \ifdim\ntest pt<0.1pt
                    \xdef#4{\myalpha}   
                    \xdef#5{\mybeta}
                    \fi
            }}
        } 
        \tikzset{circle in plane with normal/.style args={#1 with radius #2 around #3}{ 
                /utils/exec={\edef\temp{\noexpand\parsecoord#1>(\noexpand\myNx,\noexpand\myNy,\noexpand\myNz)} 
                    \temp 
                    \pgfmathsetmacro{\myNx}{\myNx} 
                    \pgfmathsetmacro{\myNy}{\myNy} 
                    \pgfmathsetmacro{\myNz}{\myNz} 
                    \pgfmathsetmacro{\myNormalization}{sqrt(pow(\myNx,2)+pow(\myNy,2)+pow(\myNz,2))} 
                    \pgfmathsetmacro{\myNx}{\myNx/\myNormalization} 
                    \pgfmathsetmacro{\myNy}{\myNy/\myNormalization} 
                    \pgfmathsetmacro{\myNz}{\myNz/\myNormalization} 
                    % compute the rotation angles that transform us in the corresponding plabe 
                    \RotationAnglesForPlaneWithNormal{\myNx}{\myNy}{\myNz}{\tmpalpha}{\tmpbeta} 
                    %\typeout{N=(\myNx,\myNy,\myNz),alpha=\tmpalpha,beta=\tmpbeta,r=#2,#3} 
                    \tdplotsetrotatedcoords{\tmpalpha}{\tmpbeta}{0}}, 
                insert path={[tdplot_rotated_coords,canvas is xy plane at z=0,transform shape] 
                    #3 circle[radius=#2]} 
        }} 

    \tikzset{reverseclip/.style={insert path={(current bounding box.south west)rectangle 
                (current bounding box.north east)} }}
\begin{document} 
    \tdplotsetmaincoords{70}{90}
    \begin{tikzpicture}[tdplot_main_coords,scale=1,line cap=butt,line join=round]
    \pgfmathsetmacro\a{5} 
    \pgfmathsetmacro\R{1/2*\a} 
    \pgfmathsetmacro\h{\a}
    \pgfmathsetmacro\angB{-30} 
    \def\r{1/2*\a}
\pgfmathsetmacro\RAHK{1/2*sqrt(\h^2*\a^2/(\a^2+\h^2))}

\pgfmathsetmacro\RBHKC{sqrt((4*sin(\angB)*\R*\a^3-4*\h^2*sin(\angB)*\R*\a+4*\R^2*\a^2+4*\R^2*\h^2+\a^4+\a^2*\h^2)/(4*\R^2+4*\a*\R*sin(\angB)+\a^2+4*\h^2))} 

%\typeout{\RAHK,\RBHKC} 
    \coordinate (A) at (0,0,0) ; 
    \coordinate (C) at (0,\a,0);
    \coordinate (B) at ({ \R*cos(\angB)}, {\a/2 + \R*sin(\angB)},0); 

    \coordinate (S) at (0,0,\h); 
    \coordinate (O) at ($ (A)!0.5!(C) $);
    \coordinate (H) at ({4*\h*\h*\R*cos(\angB)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)}, {2*\h*\h*(2*\R*sin(\angB)+\a)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)}, {\h*(4*\R^2+4*\a*\R*sin(\angB)+\a*\a)/(4*\R*\R+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h)});
    \coordinate (K) at (0, {\h*\h*\a/(\a*\a+\h*\h)}, {\h*\a*\a/(\a*\a+\h*\h)});

    \coordinate (I') at ($(K)!0.5!(A) $); 
    \coordinate (I) at ($(C)!0.5!(H) $);

\foreach \v/\position in { B/below,C/right,A/left,S/above,K/above,H/right,O/below} {\draw[draw =black, fill=black] (\v) circle (1.3pt) node [\position=0.2mm] {$\v$}; 
    } 

    \draw[thick] (S) -- (A) (S) -- (B) (S) -- (C)   (A) -- (B) -- (C) (A) --  (H) --  (K) ; 
    \draw[dashed]  (A)   -- (K) (A)   --(C) ; 

    \parsecoord(0,0,0)>(\myAx,\myAy,\myAz) 
    \parsecoord(4*\h*\h*\R*cos(\angB)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h), 2*\h*\h*(2*\R*sin(\angB)+\a)/(4*\R^2+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h), \h*(4*\R^2+4*\a*\R*sin(\angB)+\a*\a)/(4*\R*\R+4*\a*\R*sin(\angB)+\a*\a+4*\h*\h))>(\myHx,\myHy,\myHz)
    \parsecoord(0, \h*\h*\a/(\a*\a+\h*\h), \h*\a*\a/(\a*\a+\h*\h))>(\myKx,\myKy,\myKz)

    \def\mynormal{\VPTD({\myHx-\myAx},{\myHy-\myAy},{\myHz-\myAz})x({\myKx-\myAx},{\myKy-\myAy},{\myKz-\myAz})} 
    \draw[blue,thick,circle in plane with normal={{\mynormal} with radius {\RAHK} around (I')}];    

    \end{tikzpicture} 

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.