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)}
\def\VecAdd(#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)}
\def\VecAdd(#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}





(-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. – Feb 03 '19 at 15:43