设SABCD
为一个金字塔,SA
垂直于平面ABC
,金字塔的底面为矩形,SA=h
,AB=a
,AD=b
。一个P
过A
并垂直于 的平面分别在,,处与、、SC
交线。我用三种方法试了一下。SB
SD
SC
E
F
K
第一种方式
\documentclass[border=3.14mm,12pt,tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{intersections,calc,backgrounds}
\begin{document}
\tdplotsetmaincoords{60}{120}
\begin{tikzpicture}[tdplot_main_coords,scale=1.5]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{4}
\pgfmathsetmacro\h{5}
% definitions
\path
coordinate(A) at (0,0,0)
coordinate (B) at (\a,0,0)
coordinate (C) at (\a,\b,0)
coordinate (D) at (0,\b,0)
coordinate (S) at (0,0,\h)
coordinate (E) at ({\a*\h^2/(\a^2+\h^2)}, 0, {\a^2*\h/(\a^2+\h^2)})
coordinate (F) at (0, {\b*\h^2/(\b^2+\h^2)}, {\b^2*\h/(\b^2+\h^2)})
coordinate (K) at ({\a*\h^2/(\a^2+\b^2+\h^2)}, {\b*\h^2/(\a^2+\b^2+\h^2)}, {(\a^2+\b^2)*\h/(\a^2+\b^2+\h^2)});
\begin{scope}
\draw [dashed, thick, name path=B--D] (B) -- (D);
\draw [dashed, thick, name path=C--A] (C) -- (A);
\path [name intersections={of=B--D and C--A,by=O}];
\end{scope}
\begin{scope}
\draw [dashed, thick, name path=S--O] (S) -- (O);
\draw [dashed, thick, name path=E--F] (E) -- (F);
\path [name intersections={of=S--O and E--F,by=I}];
\end{scope}
\begin{scope}
\draw[dashed, thick]
(A) -- (B) (D)--(A) (S)--(A);
\draw[dashed, thick]
(E) --(A) -- (F);
\draw[ultra thick]
(S) -- (B) -- (C) -- (D)--cycle (S)--(C) (E) -- (K) --(F);
\draw [thick, dashed] (A) -- (K) (E) -- (F) ;
\tkzMarkRightAngle(S,A,D)
\tkzMarkRightAngle(S,A,B)
\tkzMarkRightAngle(A,B,C)
\tkzMarkRightAngle(B,A,D)
\tkzMarkRightAngle(A,F,D)
\tkzMarkRightAngle(A,E,B)
\tkzMarkRightAngle(A,K,C)
\end{scope}
\foreach \point/\position in {A/left,B/below,C/below,S/above,D/right,E/left,D/right,F/right,K/above right,O/below,I/below}
{
\fill (\point) circle (1.5pt);
\node[\position=3pt] at (\point) {$\point$};
}
\end{tikzpicture}
\end{document}
第二种方式
\documentclass[border=3mm,12pt]{standalone}
\usepackage{fouriernc}
\usepackage{tikz,tikz-3dplot}
\usepackage{tkz-euclide}
\usetkzobj{all}
\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
}
\usetikzlibrary{intersections,calc,backgrounds}
\tikzset{projection of point/.style args={(#1,#2,#3) on line through (#4,#5,#6)
and (#7,#8,#9)}{%
/utils/exec=\pgfmathsetmacro{\myprefactor}{((#1-#4)*(#7-#4)+(#2-#5)*(#8-#5)+(#3-#6)*(#9-#6))/((#7-#4)*(#7-#4)+(#8-#5)*(#8-#5)+(#9-#6)*(#9-#6))},
insert path={%
({#4+\myprefactor*(#7-#4)},{#5+\myprefactor*(#8-#5)},{#6+\myprefactor*(#9-#6)})}
}}
\begin{document}
\tdplotsetmaincoords{60}{120}
\begin{tikzpicture}[tdplot_main_coords,scale=1.5]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{4}
\pgfmathsetmacro\h{5}
% definitions
\path
coordinate(A) at (0,0,0)
coordinate (B) at (\a,0,0)
coordinate (C) at (\a,\b,0)
coordinate (D) at (0,\b,0)
coordinate (S) at (0,0,\h);
\path[projection of point={(0,0,0) on line through (\a,0,0) and (0,0,\h)}]
coordinate (E)
[projection of point={(0,0,0) on line through (0,0,\h) and (0,\b,0) }]
coordinate (F)
[projection of point={(0,0,0) on line through (0,0,\h) and (\a,\b,0) }]
coordinate (K);
\begin{scope}
\draw [dashed, thick, name path=B--D] (B) -- (D);
\draw [dashed, thick, name path=C--A] (C) -- (A);
\path [name intersections={of=B--D and C--A,by=O}];
\end{scope}
\begin{scope}
\draw [dashed, thick, name path=S--O] (S) -- (O);
\draw [dashed, thick, name path=E--F] (E) -- (F);
\path [name intersections={of=S--O and E--F,by=I}];
\end{scope}
\begin{scope}
\draw[dashed, thick]
(A) -- (B) (D)--(A) (S)--(A);
\draw[dashed, thick]
(E) --(A) -- (F);
\draw[ultra thick]
(S) -- (B) -- (C) -- (D)--cycle (S)--(C) (E) -- (K) --(F);
\draw [thick, dashed] (A) -- (K) (E) -- (F) ;
\tkzMarkRightAngle(S,A,D)
\tkzMarkRightAngle(S,A,B)
\tkzMarkRightAngle(A,B,C)
\tkzMarkRightAngle(B,A,D)
\tkzMarkRightAngle(A,F,D)
\tkzMarkRightAngle(A,E,B)
\tkzMarkRightAngle(A,K,C)
\end{scope}
\foreach \point/\position in {A/left,B/below,C/below,S/above,D/right,E/left,D/right,F/right,K/above right,O/below,I/below}
{
\fill (\point) circle (1.5pt);
\node[\position=3pt] at (\point) {$\point$};
}
\end{tikzpicture}
\end{document}
第三条道路 根据答案是否有命令可以找到平面上某个点的投影坐标?
我定义了命令\def\VecMinus(#1,#2,#3)-(#4,#5,#6){(#1-#4,#2-#5,#3-#6)}
并尝试
\documentclass[border=3.14mm,12pt,tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
%% 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{75}{110}
\begin{tikzpicture}[tdplot_main_coords,scale=1.5]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{4}
\pgfmathsetmacro\h{5}
% definitions
\path
coordinate(A) at (0,0,0)
coordinate (B) at (\a,0,0)
coordinate (C) at (\a,\b,0)
coordinate (D) at (0,\b,0)
coordinate (S) at (0,0,\h);
\def\mynormal{\VecMinus(\a,\b,0)-(0,0,\h)}
\typeout{\mynormal:(\a,\b,-\h)}
\path[intersection of line trough={(0,0,\h) and (\a,0,0) with plane containing (0,0,0) and normal (\a,\b,-\h)}] coordinate (E)
[intersection of line trough={(0,0,\h) and (0,\b,0) with plane containing (0,0,0) and normal (\a,\b,-\h)}] coordinate (F)
[intersection of line trough={(0,0,\h) and (\a,\b,0) with plane containing (0,0,0) and normal (\a,\b,-\h)}] coordinate (K);
\draw[dashed, thick]
(A) -- (B) (D)--(A) (S)--(A);
\draw[dashed, thick]
(E) --(A) -- (F);
\draw[ultra thick]
(S) -- (B) -- (C) -- (D)--cycle (S)--(C);
\draw [thick, dashed] (A) -- (K) (A) -- (C) (B) -- (D) (E) -- (F) ;
\draw [thick] (E) -- (K) -- (F) ;
\foreach \point/\position in {A/left,B/below,C/below,S/above,D/right,E/left,D/right,F/right,K/above right}
{
\fill (\point) circle (1.5pt);
\node[\position=3pt] at (\point) {$\point$};
}
\end{tikzpicture}
\end{document}
答案1
抱歉,我原来的代码有缺陷。我只是忘了在标量积(如\SPTD#3.#4
等)周围加上括号。在对上一个答案的更新中测试这一点时,这并不重要。一旦添加了这些括号,就会得到
\documentclass[border=3.14mm,12pt,tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
%% 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))}
\def\VecAdd(#1,#2,#3)+(#4,#5,#6){(#1+1*(#4),#2+1*(#5),#3+1*(#6))}
% the line is given by \vec x = \vec \ell_0 + t \vec \ell
% the points in the plane fulfill (\vec P_0 - \vec x)\cdot\vec n =0
% inserting the line equation in the plane equation gives
% (\vec Q - \vec \ell_0 - d \vec \ell)\cdot \vec n = 0
% solving for d yields
% d = (\vec Q \cdot \vec n - \vec \ell_0\cdot\vec n)/(\vec\ell\cdot \vec n)
%
% in the macro \vec \ell_0 = #1 , \vec \ell = #2 - #1
% #3 : \vec Q and #4 : \vec n
% so d=(#3.#4-#1.#4)/(#2.#4-#1.#4)
% and \vec P = \vec \ell_0 + d * \vec \ell = #1 + d * (#2-#1)
\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{75}{110}
\begin{tikzpicture}[tdplot_main_coords,scale=1.5]
\pgfmathsetmacro\a{3}
\pgfmathsetmacro\b{4}
\pgfmathsetmacro\h{5}
% definitions
\path
coordinate(A) at (0,0,0)
coordinate (B) at (\a,0,0)
coordinate (C) at (\a,\b,0)
coordinate (D) at (0,\b,0)
coordinate (S) at (0,0,\h);
\def\mynormal{\VecMinus(\a,\b,0)-(0,0,\h)}
\typeout{\mynormal:(\a,\b,-\h)}
\path[intersection of line trough={(0,0,\h) and (\a,0,0) with plane containing (0,0,0) and normal (\a,\b,-\h)}] coordinate (E)
[intersection of line trough={(0,0,\h) and (0,\b,0) with plane containing (0,0,0) and normal (\a,\b,-\h)}] coordinate (F)
[intersection of line trough={(0,0,\h) and (\a,\b,0) with plane containing (0,0,0) and normal (\a,\b,-\h)}] coordinate (K);
\draw[dashed, thick]
(A) -- (B) (D)--(A) (S)--(A);
\draw[dashed, thick]
(E) --(A) -- (F);
\draw[ultra thick]
(S) -- (B) -- (C) -- (D)--cycle (S)--(C);
\draw [thick, dashed] (A) -- (K) (A) -- (C) (B) -- (D) (E) -- (F) ;
\draw [thick] (E) -- (K) -- (F) ;
\foreach \point/\position in {A/left,B/below,C/below,S/above,D/right,E/left,D/right,F/right,K/above right}
{
\fill (\point) circle (1.5pt);
\node[\position=3pt] at (\point) {$\point$};
}
\end{tikzpicture}
\end{document}
这与您使用其他非常好的方法得到的结果一致。抱歉造成混淆!