Intersection of a line with a plane, where is wrong in my code?

Let SABCD be a pyramid, A(0,0,0), B(-2,5,0), C(4,4,0), D(6,2,0), S(a,b,h), O is intersection of two line AC and BD. A plane passing through O and parallel to the lines AB and SC cut the lines AB, BC, SB, SA respectively at E, F, G, H. We can prove that EF, GH are parallel to AB and OH is parallel to SC. In my code, I see that, OH is not parallel to SC. By calculting, I have coordinates of the point H (in picture is H') is

({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))})

and then, OH' is parallel to SC.

This is my code base on the answer at Intersection of a line with a plane, where is wrong in third way?

 \documentclass[border=3.14mm,12pt,tikz]{standalone}
\usepackage{tikz,tikz-3dplot}

\usetikzlibrary{intersections,calc,backgrounds}
%% smuggling from https://tex.stackexchange.com/a/470979/121799
\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
}

\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+#2*#5+#3*#6}
\def\VPTD(#1,#2,#3)x(#4,#5,#6){(#2*#6-#3*#5,#3*#4-#1*#6,#1*#5-#2*#4)}
\def\VecMinus(#1,#2,#3)-(#4,#5,#6){(#1-#4,#2-#5,#3-#6)}
\tikzset{intersection of line trough/.style args={#1 and #2 with plane
containing #3 and normal #4}{%
/utils/exec={\pgfmathsetmacro{\ltest}{abs(\SPTD#2.#4-(\SPTD#1.#4))}
\parsecoord#1>(\myAx,\myAy,\myAz)
\parsecoord#2>(\myBx,\myBy,\myBz)
\ifdim\ltest pt<0.01pt
\typeout{Plane\space and\space line\space are\space parallel!\ltest}
\pgfmathsetmacro{\myd}{0}
\else
\pgfmathsetmacro{\myd}{((\SPTD#3.#4)-(\SPTD#1.#4))/((\SPTD#2.#4)-(\SPTD#1.#4))}
\fi
%\typeout{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})}
\def\myP{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})}
\smuggle\myP},
insert path={%
\myP}
}}

\begin{document}
\tdplotsetmaincoords{70}{90}
\begin{tikzpicture}[tdplot_main_coords,scale=1,line join = round, line cap = round]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{3}
\pgfmathsetmacro\h{4}

% definitions
\path
coordinate(A) at (0,0,0)
coordinate (D) at (6,2,0)
coordinate (C) at (4,4,0)
coordinate (B) at (-2,5,0)
coordinate (S) at (\a,\b,\h)
coordinate (H') at ({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))})
;

\begin{scope}
\draw [dashed,  name path=B--D] (B) -- (D);
\draw [dashed,  name path=A--C] (A) -- (C);
\path [name intersections={of=B--D and A--C,by=O}];
\end{scope}

\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
\typeout{\mynormal:(-5 \h, -2 \h, -28 + 5 \a + 2 \b)}
\path[intersection of line trough={(0,0,0) and (6,2,0) with plane containing (34/11, 34/11, 0) and normal (-5 \h, -2 \h, -28 + 5 \a + 2 \b)}]  coordinate (E);

\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
\typeout{\mynormal:(-5 \h, -2 \h, -28 + 5 \a + 2 \b)}
\path[intersection of line trough={ (-2,5,0) and (4,4,0) with plane containing (34/11, 34/11, 0) and normal (-5 \h, -2 \h, -28 + 5 \a + 2 \b)}]  coordinate (F);

\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
\typeout{\mynormal:(-5 \h, -2 \h, -28 + 5 \a + 2 \b)}
\path[intersection of line trough={(0,0,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5 \h, -2 \h, -28 + 5 \a + 2 \b)}]  coordinate (H);

\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
\typeout{\mynormal:(-5 \h, -2 \h, -28 + 5 \a + 2 \b)}
\path[intersection of line trough={(-2,5,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5 \h, -2 \h, -28 + 5 \a + 2 \b)}]  coordinate (G);

\begin{scope}
\draw[very thick]
(S)--(A) -- (D) --(C) -- (B) --cycle
(S)-- (B) (S)--(C) (S)--(D) (H)--(E) (F)--(G);
\draw[dashed]
(S) -- (O)   (A) --(B) (H)--(G) (E)-- (F) (O) --(H);
\end{scope}

\draw[dashed,red] (O) -- (H');

\foreach \point/\position in {A/left,D/below,C/below,S/above,B/right,O/below,E/left,F/right,G/right,H/left,H'/above}
{
\fill (\point) circle (1.5pt);
\node[\position=1.5pt] at (\point) {$\point$};
}

\end{tikzpicture}
\end{document}


Where is wrong in my code?

I did as marmot's comment, and got

\documentclass[border=3.14mm,12pt,tikz]{standalone}
\usepackage{tikz,tikz-3dplot}

\usetikzlibrary{intersections,calc,backgrounds}
%% smuggling from https://tex.stackexchange.com/a/470979/121799
\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
}

\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+#2*#5+#3*#6}
\def\VPTD(#1,#2,#3)x(#4,#5,#6){(#2*#6-#3*#5,#3*#4-#1*#6,#1*#5-#2*#4)}
\def\VecMinus(#1,#2,#3)-(#4,#5,#6){(#1-#4,#2-#5,#3-#6)}
\tikzset{intersection of line trough/.style args={#1 and #2 with plane
containing #3 and normal #4}{%
/utils/exec={\pgfmathsetmacro{\ltest}{abs(\SPTD#2.#4-(\SPTD#1.#4))}
\parsecoord#1>(\myAx,\myAy,\myAz)
\parsecoord#2>(\myBx,\myBy,\myBz)
\ifdim\ltest pt<0.01pt
\typeout{Plane\space and\space line\space are\space parallel!\ltest}
\pgfmathsetmacro{\myd}{0}
\else
\pgfmathsetmacro{\myd}{((\SPTD#3.#4)-(\SPTD#1.#4))/((\SPTD#2.#4)-(\SPTD#1.#4))}
\fi
%\typeout{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})}
\def\myP{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})}
\smuggle\myP},
insert path={%
\myP}
}}

\begin{document}
\tdplotsetmaincoords{70}{90}
\begin{tikzpicture}[tdplot_main_coords,scale=1,line join = round, line cap = round]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{3}
\pgfmathsetmacro\h{4}

% definitions
\path
coordinate(A) at (0,0,0)
coordinate (D) at (6,2,0)
coordinate (C) at (4,4,0)
coordinate (B) at (-2,5,0)
coordinate (S) at (\a,\b,\h)
coordinate (H') at ({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))})
;

\begin{scope}
\draw [dashed,  name path=B--D] (B) -- (D);
\draw [dashed,  name path=A--C] (A) -- (C);
\path [name intersections={of=B--D and A--C,by=O}];
\end{scope}

\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
\typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)}
\path[intersection of line trough={(0,0,0) and (6,2,0) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}]  coordinate (E);

\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
\typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)}
\path[intersection of line trough={ (-2,5,0) and (4,4,0) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}]  coordinate (F);

\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
\typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)}
\path[intersection of line trough={(0,0,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}]  coordinate (H);

\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
\typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)}
\path[intersection of line trough={(-2,5,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}]  coordinate (G);

\begin{scope}
\draw[very thick]
(S)--(A) -- (D) --(C) -- (B) --cycle
(S)-- (B) (S)--(C) (S)--(D) (H)--(E) (F)--(G);
\draw[dashed]
(S) -- (O)   (A) --(B) (H)--(G) (E)-- (F) (O) --(H);
\end{scope}

\draw[dashed,red] (O) -- (H');

\foreach \point/\position in {A/left,D/below,C/below,S/above,B/right,O/below,E/left,F/right,G/right,H/left,H'/above}
{
\fill (\point) circle (1.5pt);
\node[\position=1.5pt] at (\point) {$\point$};
}

\end{tikzpicture}
\end{document}


Code is written by Maple

\documentclass[border=3.14mm,12pt,tikz]{standalone}
\usepackage{tikz,tikz-3dplot}

\begin{document}

\tdplotsetmaincoords{70}{90}
\begin{tikzpicture}[tdplot_main_coords,scale=1,line join = round, line cap = round]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{3}
\pgfmathsetmacro\h{4}

% definitions
\path
coordinate(A) at (0,0,0)
coordinate (D) at (6,2,0)
coordinate (C) at (4,4,0)
coordinate (B) at (-2,5,0)
coordinate (S) at (\a,\b,\h)
coordinate (O) at (34/11, 34/11, 0)
coordinate (E) at (42/11, 14/11, 0)
coordinate (F) at (29/11, 93/22, 0)
coordinate (H) at ({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))})
coordinate (G) at ({-2-238*\h*(2+\a)/(11*(-5*\h*(2+\a)-2*\h*(-5+\b)+(-28+2*\b+5*\a)*\h))}, {5-238*\h*(-5+\b)/(11*(-5*\h*(2+\a)-2*\h*(-5+\b)+(-28+2*\b+5*\a)*\h))},{ -238*\h^2/(11*(-5*\h*(2+\a)-2*\h*(-5+\b)+(-28+2*\b+5*\a)*\h))});

\begin{scope}
\draw[very thick]
(S)--(A) -- (D) --(C) -- (B) --cycle
(S)-- (B) (S)--(C) (S)--(D) (H)--(E) (F)--(G);
\draw[dashed]
(S) -- (O)   (A) --(B) (H)--(G) (E)-- (F) (O) --(H);
\end{scope}

\draw[dashed,red] (O) -- (H);

\foreach \point/\position in {A/left,D/below,C/below,S/above,B/right,O/below,E/left,F/right,G/right,H/left}
{
\fill (\point) circle (1.5pt);
\node[\position=1.5pt] at (\point) {$\point$};
}

\end{tikzpicture}
\end{document}


• In your code, you have the normals (-5 \h, -2 \h, -28 + 5 \a + 2 \b). I guess these should be (-5*\h, -2*\h, -28 + 5*\a + 2*\b) since the LaTeX (TikZ) parser does not automatically insert multiplication signs. – user121799 Feb 3 '19 at 15:43
• I did as you said, but I didn't get the correct result. – minhthien_2016 Feb 4 '19 at 0:57

I am sorry, you are right. There were still parsing errors. Essentially, some minus signs do not get correctly multiplied. To correct this, I rewrote the vector operations as

\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))}


After this is done (and adds the multiplication signs in the normal, which are however not essential), one confirms what you are saying.

\documentclass[border=3.14mm,12pt,tikz]{standalone}
\usepackage{tikz,tikz-3dplot}

\usetikzlibrary{intersections,calc,backgrounds}
%% smuggling from https://tex.stackexchange.com/a/470979/121799
\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
}

\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))}
\tikzset{intersection of line trough/.style args={#1 and #2 with plane
containing #3 and normal #4}{%
/utils/exec={\pgfmathsetmacro{\ltest}{abs(\SPTD#2.#4-(\SPTD#1.#4))}
\parsecoord#1>(\myAx,\myAy,\myAz)
\parsecoord#2>(\myBx,\myBy,\myBz)
\ifdim\ltest pt<0.01pt
\typeout{Plane\space and\space line\space are\space parallel!\ltest}
\pgfmathsetmacro{\myd}{0}
\else
\pgfmathsetmacro{\myd}{((\SPTD#3.#4)-(\SPTD#1.#4))/((\SPTD#2.#4)-(\SPTD#1.#4))}
\fi
%\typeout{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})}
\def\myP{({\myAx+\myd*(\myBx-\myAx)},{\myAy+\myd*(\myBy-\myAy)},{\myAz+\myd*(\myBz-\myAz)})}
\smuggle\myP},
insert path={%
\myP}
}}

\begin{document}
\tdplotsetmaincoords{70}{90}
\begin{tikzpicture}[tdplot_main_coords,scale=1,line join = round, line cap = round]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{3}
\pgfmathsetmacro\h{4}

% definitions
\path
coordinate(A) at (0,0,0)
coordinate (D) at (6,2,0)
coordinate (C) at (4,4,0)
coordinate (B) at (-2,5,0)
coordinate (S) at (\a,\b,\h)
coordinate (H') at ({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))})
;

\begin{scope}
\draw [dashed,  name path=B--D] (B) -- (D);
\draw [dashed,  name path=A--C] (A) -- (C);
\path [name intersections={of=B--D and A--C,by=O}];
\end{scope}

\def\mynormal{\VPTD(-2,5,0)x({4 - 1*\a},{ 4 - 1*\b},{ -(\h)})}
%\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
%\pgfmathprintnumberto{\mynormal}{\myX}
\edef\temp{\noexpand\parsecoord\mynormal>(\noexpand\myNx,\noexpand\myNy,\noexpand\myNz)}
\temp
\pgfmathsetmacro{\myNx}{\myNx}
\pgfmathsetmacro{\myNy}{\myNy}
\pgfmathsetmacro{\myNz}{\myNz}
\edef\temp{\noexpand\parsecoord(-5*\h, -2*\h, -28 + 5*\a + 2*\b)>(\noexpand\myNPx,\noexpand\myNPy,\noexpand\myNPz)}
\temp
\pgfmathsetmacro{\myNPx}{\myNPx}
\pgfmathsetmacro{\myNPy}{\myNPy}
\pgfmathsetmacro{\myNPz}{\myNPz}
\typeout{before\space computing:\space\mynormal\space vs.\space(-5*\h, -2*\h, -28 + 5*\a + 2*\b)}
\typeout{after\space computing:\space(\myNx,\myNy,\myNz)\space vs.\space(\myNPx,\myNPy,\myNPz)}
\path[intersection of line trough={(0,0,0) and (6,2,0) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}]  coordinate (E);

%\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
%\typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)}
\path[intersection of line trough={ (-2,5,0) and (4,4,0) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}]  coordinate (F);

%\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
%\typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)}
\path[intersection of line trough={(0,0,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}]  coordinate (H);

%\def\mynormal{\VPTD(-2,5,0)x(4 - \a, 4 - \b, -\h)}
%\typeout{\mynormal:(-5*\h, -2*\h, -28 + 5*\a + 2*\b)}
\path[intersection of line trough={(-2,5,0) and (\a,\b,\h) with plane containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}]  coordinate (G);

\begin{scope}
\draw[very thick]
(S)--(A) -- (D) --(C) -- (B) --cycle
(S)-- (B) (S)--(C) (S)--(D) (H)--(E) (F)--(G);
\draw[dashed]
(S) -- (O)   (A) --(B) (H)--(G) (E)-- (F) (O) --(H);
\end{scope}

\draw[dashed,red] (O) -- (H');

\foreach \point/\position in {A/left,D/below,C/below,S/above,B/right,O/below,E/left,F/right,G/right,H/left,H'/above}
{
\fill (\point) circle (1.5pt);
\node[\position=1.5pt] at (\point) {$\point$};
}

\end{tikzpicture}
\end{document}


• It is interesting. – minhthien_2016 Feb 4 '19 at 1:35
• @minhthien_2016 I am really very sorry. I should have thought about this but I didn't. – user121799 Feb 4 '19 at 1:38
• Please write a simplest code. I use Maple to check. – minhthien_2016 Feb 4 '19 at 1:38
• @minhthien_2016 I believe this answer reproduces your result obtained with Maple. Is that true? – user121799 Feb 4 '19 at 2:01
• @minhthien_2016 No. It will take a long while. – user121799 Feb 18 '19 at 2:17

Here is an alternative, which requires the 3dtools library from here. This computes the coordinates with a style that has the same usage as this answer, but does not require the user to paste all the macros in the preamble because now the parsing is done with the parser by the library. Note that the input coordinates can be both explicit or symbolic, but, as explained in the manual the symbolic ones need to be put in with the syntax

\path (6,2,0) coordinate (D);


while

\coordinate (D) at (6,2,0);

We keep out claws crossed that in future versions of pgf both work.

\documentclass[tikz,border=1 mm,12pt]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools}
\tikzset{intersection of line trough/.code args={#1 and #2 with plane
containing #3 and normal #4}{%
\pgfmathsetmacro{\ltest}{abs(TD("#2o#4")-TD("#1o#4"))}%
\ifdim\ltest pt<0.01pt
\message{Plane and line are parallel!^^J}
\pgfmathsetmacro{\myd}{0}
\else
\pgfmathsetmacro{\myd}{(TD("#3o#4")-TD("#1o#4"))/(TD("#2o#4")-TD("#1o#4"))}%
\fi
\pgfmathsetmacro{\myP}{TD("#1+\myd*#2-\myd*#1")}%
\pgfkeysalso{insert path={%
(\myP)
}}
}}

\begin{document}

\tdplotsetmaincoords{70}{90}
\begin{tikzpicture}[tdplot_main_coords,scale=1,line join = round, line cap = round]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{3}
\pgfmathsetmacro\h{4}

% definitions
\path
(0,0,0) coordinate (A)
(6,2,0) coordinate(D)
(4,4,0)coordinate(C)
(-2,5,0) coordinate(B)
(\a,\b,\h) coordinate(S)
(34/11, 34/11, 0) coordinate(O)
(42/11, 14/11, 0) coordinate(E)
(29/11, 93/22, 0)coordinate(F)
({-238*\h*\a/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h*\b/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}, {-238*\h^2/(11*(-5*\h*\a-2*\h*\b+(-28+2*\b+5*\a)*\h))}) coordinate(H)
({-2-238*\h*(2+\a)/(11*(-5*\h*(2+\a)-2*\h*(-5+\b)+(-28+2*\b+5*\a)*\h))}, {5-238*\h*(-5+\b)/(11*(-5*\h*(2+\a)-2*\h*(-5+\b)+(-28+2*\b+5*\a)*\h))},{ -238*\h^2/(11*(-5*\h*(2+\a)-2*\h*(-5+\b)+(-28+2*\b+5*\a)*\h))}) coordinate(G);
\path[intersection of line trough={(0,0,0) and (6,2,0) with plane containing
(34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a + 2*\b)}]
coordinate (E');
\path[intersection of line trough={ (B) and (C) with plane
containing (34/11, 34/11, 0) and normal (-5*\h, -2*\h, -28 + 5*\a +
2*\b)}]  coordinate (F');
\path[intersection of line trough={(A) and (\a,\b,\h) with plane
containing (O) and normal (-5*\h, -2*\h, -28 + 5*\a +
2*\b)}]  coordinate (H');
\path[intersection of line trough={(B) and (S) with plane
containing (O) and normal (-5*\h, -2*\h, -28 + 5*\a +
2*\b)}]  coordinate (G');

\begin{scope}
\draw[very thick]
(S)--(A) -- (D) --(C) -- (B) --cycle
(S)-- (B) (S)--(C) (S)--(D) (H)--(E) (F)--(G);
\draw[dashed]
(S) -- (O)   (A) --(B) (H)--(G) (E)-- (F) (O) --(H);
\end{scope}
\path[red] foreach \X in {E,F,G,H}
{(\X) node[above] {$\X$} (\X') node[below] {$\X'$}};
\draw[dashed,red] (O) -- (H);

\foreach \point/\position in {A/left,D/below,C/below,S/above,B/right,O/below,E/left,F/right,G/right,H/left}
{
\fill (\point) circle (1.5pt);
\node[\position=1.5pt] at (\point) {$\point$};
}

\end{tikzpicture}
\end{document}


The red stuff is just to show that it works.

EDIT: Changed to code/.style args, as suggested by Henri Menke in the comments.

• Please use .code args instead of .style args with /utils/exec. I think I mentioned this to you before that /utils/exec does not stack, i.e. if you have two invocations of /utils/exec on the same path, only the latter will be executed and /utils/exec is used internally by PGF, so you can't know. – Henri Menke Dec 14 '19 at 6:14
• @HenriMenke Thanks! But this is also a style because it uses insert path. One could of course define a code that does the /utils/exec/ part or use code with \pgfkeysalso, but only changing .style args to .code args  won't work. – Schrödinger's cat Dec 14 '19 at 6:18