使用 TikZ 进行动态裁剪平面

使用 TikZ 进行动态裁剪平面

我对 TikZ 有疑问。我想绘制一个动态剪切平面。红色区域的顶部是动态的,蓝色区域应该具有相同的高度/级别,但尺寸要大得多……以将光学区域与红色区域分开。有什么想法吗?

更新我添加了另一张图片来阐明我的观点。蓝色方块应该完美地贴合在红色截头体的顶部。它应该是动态的,所以如果我改变截头体的高度,蓝色方块也会移动。我的问题是红色截头体的高度是从视点到底部的射线的一部分。如果可以给出一个适合透视和射线的高度参数,我认为这也可以解决问题。

\begin{tikzpicture}[scale=1]
\usetikzlibrary{calc}
        %%% Parameter %%%
        \pgfmathsetmacro{\frameHeight}{8}
        \pgfmathsetmacro{\frameWidth}{0.92}
        \pgfmathsetmacro{\frameDepth}{0.87}
        \pgfmathsetmacro{\viewpointDepth}{0.5}
        \pgfmathsetmacro{\viewpointCentering}{0.5}
        \pgfmathsetmacro{\projectionHeight}{0.36}
        \pgfmathsetmacro{\projectionWidth}{0.96}
        \pgfmathsetmacro{\projectionDepth}{0.07}
            % Fluchtpunkte
        \coordinate (F1) at (30:50cm);
        \coordinate (F2) at (150:50cm);
            % Eckpunkte
        \coordinate (P1) at (0cm,0cm);                  % v U
        \coordinate (P2) at (0cm,\frameHeight);     % v O
        \coordinate (P3) at ($(F1)!\frameDepth!(P1)$);  % h U
        \coordinate (P4) at ($(F1)!\frameDepth!(P2)$);  % h O
        \coordinate (P5) at ($(F2)!\frameWidth!(P1)$);  
        \coordinate (P6) at ($(F2)!\frameWidth!(P2)$);
        \coordinate (P7) at (intersection cs: first line={(P5) -- (F1)}, second line={(P3) -- (F2)});
        \coordinate (P8) at (intersection cs: first line={(P6) -- (F1)}, second line={(P4) -- (F2)});
        \coordinate (P9) at ($(P2)!\viewpointDepth!(P4)$);
        \coordinate (P10) at (intersection cs: first line={(P9) -- (F2)}, second line={(P6) -- (P8)});
            % Sichtfeld
        \coordinate (A) at ($(P5)!\projectionWidth!(P1)$);
        \coordinate (B) at ($(P1)!\projectionWidth!(P5)$);
        \coordinate (C) at ($(A)!\projectionDepth!(F1)$);   
        \coordinate (D) at (intersection cs: first line={(C) -- (F2)}, second line={(B) -- (F1)});  
        \coordinate (V) at ($(P9)!\viewpointCentering!(P10)$);
            % Nutzfläche Schnitt
        \coordinate (E) at ($(A)!\projectionHeight!(V)$);
        \coordinate (F) at (intersection cs: first line={(E) -- (F2)}, second line={(V) -- (B)});
        \coordinate (G) at (intersection cs: first line={(E) -- (F1)}, second line={(V) -- (C)});
        \coordinate (H) at (intersection cs: first line={(F) -- (F1)}, second line={(V) -- (D)});
            % nutz Sichtfeld Ebene
        \coordinate (P11) at ($(E)$); %({(E)--(F2)}:2);
        \coordinate (P12) at ($(F)$);
        \coordinate (P13) at ($(G)$);
        \coordinate (P14) at ($(H)$);
            % real Sichtfeld Ebene
        \coordinate (P15) at (0, -1);
        \coordinate (P16) at ($(P15)!0.115!(F2)$);
        \coordinate (P17) at ($(F1)!0.835!(P15)$);
        \coordinate (P18) at (intersection cs: first line={(P16) -- (F1)}, second line={(P17) -- (F2)});
        %Linien
        \draw[rounded corners, draw=black!80, fill=yellow!80, opacity=0.5] (P15) -- (P16) -- (P18) -- (P17)  -- cycle;
            % Tiefe / Verlauf
        \begin{scope}[opacity=0.2]
        \shade[top color=gray!70,bottom color=gray!5] (P1) -- (P3) -- (P7) -- (P5);
        \shade[right color=gray!70,left color=gray!5] (P5) -- (P6) -- (P8) -- (P7);
        \shade[left color=gray!70,right color=gray!5] (P7) -- (P3) -- (P4) -- (P8);
        \end{scope}
            % Sichtfeld der Kamera
        \fill [red!80, opacity=0.4] (A) -- (B) -- (D) -- (C);
        \begin{scope}[thin, dashed, red]%thick, dashed, fill=red!80, opacity=1]
            \draw (A) -- (V);
            \draw (B) -- (V);
            \draw (C) -- (V);
            \draw (D) -- (V);
        \end{scope}
        \begin{scope}[red]
            \draw (A) -- (E);
            \draw (B) -- (F);
            \draw (D) -- (H);
            \draw (C) -- (G);
        \end{scope}
        \draw [thin, red] (A) -- (B) -- (D) -- (C) -- (A);
        \draw [thin, red] (E) -- (F) -- (H) -- (G) -- (E);
        %\draw [thick, red!80] (
        \begin{scope}[red!80, opacity=0.1]
            \fill (A) -- (B) -- (F) -- (E);
            \fill (C) -- (A) -- (E) -- (G);
            \fill (D) -- (C) -- (G) -- (H);
            \fill (B) -- (D) -- (H) -- (F);
        \end{scope}
        \draw[rounded corners, draw=black!80, fill=blue!80, opacity=0.5] (P11) -- (P12) -- (P14) -- (P13) -- cycle;
            % Frame
        \begin{scope}[thin, opacity=0.6]
            \draw (P1) -- (P3) -- (P4) -- (P2) -- (P1) ;
            \draw (P1) -- (P5) -- (P6) -- (P2) -- (P1) ;
            \draw (P2) -- (P6) -- (P8) -- (P4) -- (P2) ;
            \draw (P3) -- (P7) -- (P8) -- (P4) -- (P3) ;
            \draw (P1) -- (P5) -- (P7) -- (P3) -- (P1) ;
        \end{scope}
        \draw[thin,dashed] (P9) -- (P10);
        % Verbindungspunkte
        \foreach \i in {1,2,...,10}
            {
             \shade[shading=ball, ball color=black!80] (P\i) circle (0.05em) node[above right] {}; %\tiny \i};
            }
        \foreach \i in {A, B,...,H}
            {
            \shade[shading=ball, ball color=red] (\i) circle (0.05em) node[above right] {}; %\tiny \i};
            }
        %Beschriftung
        %\draw[fill=red] (V) circle (0.25em) node[above right] {\tiny Viewpoint};
        \shade[shading=ball, ball color=red] (V) circle (0.25em) node[above right] {\tiny Betrachtungspunkt};
        \draw[] (4.75,0.8) to[out=90,in=-90] (0.75,2);
        \draw (4.75,0.5) node[] {\footnotesize nutzbares Sichtfeld};
        \draw[] (-5.5,4.3) to[out=90,in=-90] (-0.5,4.5);
        \draw (-5.5,4) node[] {\footnotesize unterer Schwellwert};
        \draw[] (-5.5,0.8) to[out=90,in=-90] (-3,1.4);
        \draw (-5.5,0.5) node[] {\footnotesize oberer Schwellwert};
\end{tikzpicture}

在此处输入图片描述 在此处输入图片描述

答案1

这是你想要的吗(改变值\projectionHeight会使视锥体和平面一起移动)?

\documentclass{report}
\usepackage[T1]{fontenc}


\usepackage{pgfplots}
\usetikzlibrary{intersections}


\begin{document}

\begin{tikzpicture}[scale=1]
\usetikzlibrary{calc}
        %%% Parameter %%%
        \pgfmathsetmacro{\frameHeight}{8}
        \pgfmathsetmacro{\frameWidth}{0.92}
        \pgfmathsetmacro{\frameDepth}{0.87}
        \pgfmathsetmacro{\viewpointDepth}{0.5}
        \pgfmathsetmacro{\viewpointCentering}{0.5}
        \pgfmathsetmacro{\projectionHeight}{0.5}
        \pgfmathsetmacro{\projectionWidth}{0.96}
        \pgfmathsetmacro{\projectionDepth}{0.07}
            % Fluchtpunkte
        \coordinate (F1) at (30:50cm);
        \coordinate (F2) at (150:50cm);
            % Eckpunkte
        \coordinate (P1) at (0cm,0cm);                  % v U
        \coordinate (P2) at (0cm,\frameHeight);     % v O
        \coordinate (P3) at ($(F1)!\frameDepth!(P1)$);  % h U
        \coordinate (P4) at ($(F1)!\frameDepth!(P2)$);  % h O
        \coordinate (P5) at ($(F2)!\frameWidth!(P1)$);  
        \coordinate (P6) at ($(F2)!\frameWidth!(P2)$);
        \coordinate (P7) at (intersection cs: first line={(P5) -- (F1)}, second line={(P3) -- (F2)});
        \coordinate (P8) at (intersection cs: first line={(P6) -- (F1)}, second line={(P4) -- (F2)});
        \coordinate (P9) at ($(P2)!\viewpointDepth!(P4)$);
        \coordinate (P10) at (intersection cs: first line={(P9) -- (F2)}, second line={(P6) -- (P8)});
            % Sichtfeld
        \coordinate (A) at ($(P5)!\projectionWidth!(P1)$);
        \coordinate (B) at ($(P1)!\projectionWidth!(P5)$);
        \coordinate (C) at ($(A)!\projectionDepth!(F1)$);   
        \coordinate (D) at (intersection cs: first line={(C) -- (F2)}, second line={(B) -- (F1)});  
        \coordinate (V) at ($(P9)!\viewpointCentering!(P10)$);
            % Nutzfläche Schnitt
        \coordinate (E) at ($(A)!\projectionHeight!(V)$);
        \coordinate (F) at (intersection cs: first line={(E) -- (F2)}, second line={(V) -- (B)});
        \coordinate (G) at (intersection cs: first line={(E) -- (F1)}, second line={(V) -- (C)});
        \coordinate (H) at (intersection cs: first line={(F) -- (F1)}, second line={(V) -- (D)});
            % nutz Sichtfeld Ebene
        \coordinate (P11) at ($(E)$); %({(E)--(F2)}:2);
        \coordinate (P12) at ($(F)$);
        \coordinate (P13) at ($(G)$);
        \coordinate (P14) at ($(H)$);
            % real Sichtfeld Ebene
        \coordinate (P15) at (0, -1);
        \coordinate (P16) at ($(P15)!0.115!(F2)$);
        \coordinate (P17) at ($(F1)!0.835!(P15)$);
        \coordinate (P18) at (intersection cs: first line={(P16) -- (F1)}, second line={(P17) -- (F2)});
        \coordinate (P15') at (0, \projectionHeight*\frameHeight);
        \coordinate (P16') at ($(P15')!0.115!(F2)$);
        \coordinate (P17') at ($(F1)!0.835!(P15')$);
        \coordinate (P18') at (intersection cs: first line={(P16') -- (F1)}, second line={(P17') -- (F2)});
        %Linien
        \draw[rounded corners, draw=black!80, fill=yellow!80, opacity=0.5] (P15) -- (P16) -- (P18) -- (P17)  -- cycle;
        \draw[rounded corners, draw=black!80, fill=cyan!80, opacity=0.5] (P15') -- (P16') -- (P18') -- (P17')  -- cycle;
            % Tiefe / Verlauf
        \begin{scope}[opacity=0.2]
        \shade[top color=gray!70,bottom color=gray!5] (P1) -- (P3) -- (P7) -- (P5);
        \shade[right color=gray!70,left color=gray!5] (P5) -- (P6) -- (P8) -- (P7);
        \shade[left color=gray!70,right color=gray!5] (P7) -- (P3) -- (P4) -- (P8);
        \end{scope}
            % Sichtfeld der Kamera
        \fill [red!80, opacity=0.4] (A) -- (B) -- (D) -- (C);
        \begin{scope}[thin, dashed, red]%thick, dashed, fill=red!80, opacity=1]
            \draw (A) -- (V);
            \draw (B) -- (V);
            \draw (C) -- (V);
            \draw (D) -- (V);
        \end{scope}
        \begin{scope}[red]
            \draw (A) -- (E);
            \draw (B) -- (F);
            \draw (D) -- (H);
            \draw (C) -- (G);
        \end{scope}
        \draw [thin, red] (A) -- (B) -- (D) -- (C) -- (A);
        \draw [thin, red] (E) -- (F) -- (H) -- (G) -- (E);
        %\draw [thick, red!80] (
        \begin{scope}[red!80, opacity=0.1]
            \fill (A) -- (B) -- (F) -- (E);
            \fill (C) -- (A) -- (E) -- (G);
            \fill (D) -- (C) -- (G) -- (H);
            \fill (B) -- (D) -- (H) -- (F);
        \end{scope}
            % Frame
        \begin{scope}[thin, opacity=0.6]
            \draw (P1) -- (P3) -- (P4) -- (P2) -- (P1) ;
            \draw (P1) -- (P5) -- (P6) -- (P2) -- (P1) ;
            \draw (P2) -- (P6) -- (P8) -- (P4) -- (P2) ;
            \draw (P3) -- (P7) -- (P8) -- (P4) -- (P3) ;
            \draw (P1) -- (P5) -- (P7) -- (P3) -- (P1) ;
        \end{scope}
        \draw[thin,dashed] (P9) -- (P10);
        % Verbindungspunkte
        \foreach \i in {1,2,...,10}
            {
             \shade[shading=ball, ball color=black!80] (P\i) circle (0.05em) node[above right] {}; %\tiny \i};
            }
        \foreach \i in {A, B,...,H}
            {
            \shade[shading=ball, ball color=red] (\i) circle (0.05em) node[above right] {}; %\tiny \i};
            }
        %Beschriftung
        %\draw[fill=red] (V) circle (0.25em) node[above right] {\tiny Viewpoint};
        \shade[shading=ball, ball color=red] (V) circle (0.25em) node[above right] {\tiny Betrachtungspunkt};
        \draw[] (4.75,0.8) to[out=90,in=-90] (0.75,2);
        \draw (4.75,0.5) node[] {\footnotesize nutzbares Sichtfeld};
        \draw[] (-5.5,4.3) to[out=90,in=-90] (-0.5,4.5);
        \draw (-5.5,4) node[] {\footnotesize unterer Schwellwert};
        \draw[] (-5.5,0.8) to[out=90,in=-90] (-3,1.4);
        \draw (-5.5,0.5) node[] {\footnotesize oberer Schwellwert};
\end{tikzpicture}


\end{document}

答案2

最终解决方案。谢谢@all

\begin{tikzpicture}[scale=0.9]
\usetikzlibrary{calc}
        %%% Parameter %%%
        \pgfmathsetmacro{\frameHeight}{8}
        \pgfmathsetmacro{\frameWidth}{0.92}
        \pgfmathsetmacro{\frameDepth}{0.87}
        \pgfmathsetmacro{\viewpointDepth}{0.5}
        \pgfmathsetmacro{\viewpointCentering}{0.6}
        \pgfmathsetmacro{\projectionHeight}{0.36}
        \pgfmathsetmacro{\projectionWidth}{0.96}
        \pgfmathsetmacro{\projectionDepth}{0.07}
        \pgfmathsetmacro{\clippingPlaneHeight}{0.1}
        \pgfmathsetmacro{\clippingPlaneWidth}{0.91}
        %%%%%%%%%%%%
        %%%%%%%%%%%%
            % Fluchtpunkte
        \coordinate (F1) at (30:50cm);
        \coordinate (F2) at (150:50cm);
            % Eckpunkte
        \coordinate (P1) at (0cm,0cm);                  % v U
        \coordinate (P2) at (0cm,\frameHeight);     % v O
        \coordinate (P3) at ($(F1)!\frameDepth!(P1)$);  % h U
        \coordinate (P4) at ($(F1)!\frameDepth!(P2)$);  % h O
        \coordinate (P5) at ($(F2)!\frameWidth!(P1)$);  
        \coordinate (P6) at ($(F2)!\frameWidth!(P2)$);
        \coordinate (P7) at (intersection cs: first line={(P5) -- (F1)}, second line={(P3) -- (F2)});
        \coordinate (P8) at (intersection cs: first line={(P6) -- (F1)}, second line={(P4) -- (F2)});
        \coordinate (P9) at ($(P2)!\viewpointDepth!(P4)$);
        \coordinate (P10) at (intersection cs: first line={(P9) -- (F2)}, second line={(P6) -- (P8)});
            % Sichtfeld
        \coordinate (A) at ($(P5)!\projectionWidth!(P1)$);
        \coordinate (B) at ($(P1)!\projectionWidth!(P5)$);
        \coordinate (C) at ($(A)!\projectionDepth!(F1)$);   
        \coordinate (D) at (intersection cs: first line={(C) -- (F2)}, second line={(B) -- (F1)});  
        \coordinate (V) at ($(P9)!\viewpointCentering!(P10)$);
            % Nutzfläche Schnitt
        \coordinate (E) at ($(A)!\projectionHeight!(V)$);
        \coordinate (F) at (intersection cs: first line={(E) -- (F2)}, second line={(V) -- (B)});
        \coordinate (G) at (intersection cs: first line={(E) -- (F1)}, second line={(V) -- (C)});
        \coordinate (H) at (intersection cs: first line={(F) -- (F1)}, second line={(V) -- (D)});
            % nutz Sichtfeld Ebene
        \coordinate (P11) at (0, \projectionHeight*\frameHeight-0.5);
        \coordinate (P12) at ($(P11)!\clippingPlaneHeight!(F2)$);
        \coordinate (P13) at ($(F1)!\clippingPlaneWidth!(P11)$);
        \coordinate (P14) at at (intersection cs: first line={(P12) -- (F1)}, second line={(P13) -- (F2)});
            % real Sichtfeld Ebene
        \coordinate (P15) at (0, -0.5);
        \coordinate (P16) at ($(P15)!\clippingPlaneHeight!(F2)$);
        \coordinate (P17) at ($(F1)!\clippingPlaneWidth!(P15)$);
        \coordinate (P18) at (intersection cs: first line={(P16) -- (F1)}, second line={(P17) -- (F2)});
            % Hilfspunkte Höhe Ebene
        \coordinate (P19) at (0, \projectionHeight*\frameHeight);
        \coordinate (P20) at ($(F2)!\frameWidth!(P19)$);
        %Linien
        \draw[rounded corners, draw=black, fill=yellow!30, opacity=0.7] (P15) -- (P16) -- (P18) -- (P17)  -- cycle;
            % Tiefe / Verlauf
        \begin{scope}[opacity=0.1]
        \shade[top color=gray!70,bottom color=gray!5] (P1) -- (P3) -- (P7) -- (P5);
        \shade[right color=gray!70,left color=gray!5] (P5) -- (P6) -- (P8) -- (P7);
        \shade[left color=gray!70,right color=gray!5] (P7) -- (P3) -- (P4) -- (P8);
        \end{scope}
            %Frustum
        \begin{scope}[red!80]
            \draw (A) -- (E);
            \draw (B) -- (F);
            \draw (D) -- (H);
            \draw (C) -- (G);
        \end{scope}
            %Frame Unterteil + Hinterteil
        \draw[thick, color=black!25]  (P3) -- (P7) -- (P8)  (P5) -- (P7);
        \draw[thick, color=black!40]  (P20) -- (P5) -- (P1) -- (P19);
            % Sichtfeld der Kamera
        \fill [red!80, opacity=0.3] (A) -- (B) -- (D) -- (C);
        \fill [red!80, opacity=0.4] (E) -- (F) -- (H) -- (G);
        \draw [thin, red!80] (A) -- (B) -- (D) -- (C) -- (A);
        \draw [thin, red] (E) -- (F) -- (H) -- (G) -- (E);
        %\draw [thick, red!80] (
        \begin{scope}[red!80, opacity=0.1]
            \fill (A) -- (B) -- (F) -- (E);
            \fill (C) -- (A) -- (E) -- (G);
            \fill (D) -- (C) -- (G) -- (H);
            \fill (B) -- (D) -- (H) -- (F);
        \end{scope}
        \draw[rounded corners, draw=black, fill=blue!25, opacity=0.7] (P11) -- (P12) -- (P14) -- (P13) -- cycle;
        \begin{scope}[thin, dashed, red!80]%thick, dashed, fill=red!80, opacity=1]
            \draw (E) -- (V);
            \draw (F) -- (V);
            \draw (G) -- (V);
            \draw (H) -- (V);
            %\draw (F1) -- (F3);
            %\draw (F2) -- (F4);
        \end{scope}
            % Frame Oberteil
        \draw[thick,color=black!40] (P19) -- (P2) (P3) -- (P4) (P20) -- (P6)
                                        (P1) -- (P3) (P2) -- (P4) (P2)--(P6) (P6) -- (P8) -- (P4);
        \draw[thin,dashed, color=black !70] (P9) -- (P10);
        % Verbindungspunkte
        \foreach \i in {1,2,..., 10} %20}
            {
             %\shade[shading=ball, ball color=black!80] (P\i) circle (0.05em) node[above right] {}; %\tiny \i};
            }
        \foreach \i in {A, B,...,H}
            {
            %\shade[shading=ball, ball color=red!] (\i) circle (0.05em) node[above right] {}; %\tiny \i};
            }
        %Beschriftung
        %\draw[fill=red] (V) circle (0.25em) node[above right] {\tiny Viewpoint};
        \shade[shading=ball, ball color=red!80] (V) circle (0.25em) node[above right] {\footnotesize Kamera};
        %\draw (-1.1,9.3) node[] {\footnotesize Kamera};
        \draw[thin, -to] (4.75,0.8) to[out=135,in=-45] (0.75,2);
        \draw (4.75,0.5) node[] {\footnotesize nutzbares Sichtfeld};
        \draw[thin, -to] (-5.5,3.6) to[out=45,in=-135] (-3,4.2);
        \draw (-5.5,3.2) node[] {\footnotesize unterer Schwellwert};
        \draw[thin, -to] (-5.5,0.9) to[out=45,in=-135] (-3,1.5);
        \draw (-5.5,0.5) node[] {\footnotesize oberer Schwellwert};
\end{tikzpicture}

在此处输入图片描述

答案3

这是一种使用 3D 坐标的方法,这样您就可以直接计算蓝色矩形的角,而不需要裁剪。您可以更改顶点的高度(\vertexheight)、蓝色矩形的高度百分比(\posalongpath)以及坐标轴的方向和长度(\Cangle\Clength

代码

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}

\begin{document}

\newcommand{\xangle}{7}
\newcommand{\yangle}{138}
\newcommand{\zangle}{90}

\newcommand{\xlength}{1}
\newcommand{\ylength}{1}
\newcommand{\zlength}{1}

\pgfmathsetmacro{\xx}{\xlength*cos(\xangle)}
\pgfmathsetmacro{\xy}{\xlength*sin(\xangle)}
\pgfmathsetmacro{\yx}{\ylength*cos(\yangle)}
\pgfmathsetmacro{\yy}{\ylength*sin(\yangle)}
\pgfmathsetmacro{\zx}{\zlength*cos(\zangle)}
\pgfmathsetmacro{\zy}{\zlength*sin(\zangle)}

\pgfmathsetmacro{\posalongpath}{0.37}
\pgfmathsetmacro{\vertexheight}{5}

\begin{tikzpicture}[x={(\xx cm,\xy cm)}, y={(\yx cm,\yy cm)}, z={(\zx cm,\zy cm)}]
    \coordinate (A) at (0,0,0);
    \coordinate (B) at (3,0,0);
    \coordinate (C) at (3,3,0);
    \coordinate (D) at (0,3,0);
    \coordinate (V) at (2,2,\vertexheight);

    \path (A) -- (V) coordinate[pos=\posalongpath] (A-V);
    \path (B) -- (V) coordinate[pos=\posalongpath] (B-V);
    \path (C) -- (V) coordinate[pos=\posalongpath] (C-V);
    \path (D) -- (V) coordinate[pos=\posalongpath] (D-V);

    \pgfmathsetmacro{\blueheight}{\posalongpath*\vertexheight}

    \coordinate (A1) at ($(A-V) + (0,0,-\blueheight)$);
    \coordinate (B1) at ($(B-V) + (0,0,-\blueheight)$);
    \coordinate (C1) at ($(C-V) + (0,0,-\blueheight)$);
    \coordinate (D1) at ($(D-V) + (0,0,-\blueheight)$);

    \fill[red,opacity=0.5,draw=red!80!black,thick] (A) -- (B) -- (C) -- (D) -- cycle;

    \fill[yellow,opacity=0.5,draw=red!80!black,thick] (A1) -- (B1) -- (C1) -- (D1) -- cycle;

    \draw[red!50!black] (A) -- (A-V) (B) -- (B-V) (C) -- (C-V) (D) -- (D-V);
    \draw[blue!50!yellow,densely dashed] (A1) -- (A-V) (B1) -- (B-V) (C1) -- (C-V) (D1) -- (D-V);

    \fill[blue,opacity=0.5,draw=blue!80!black,thick] (A-V) -- (B-V) -- (C-V) -- (D-V) -- cycle; 

    \draw[red!50!black,densely dashed] (V) -- (A-V) (V) -- (B-V) (V) -- (C-V) (V) -- (D-V);

    \fill[red,opacity=0.2] (A) -- (B) -- (B-V) -- (A-V) -- (D-V) -- (D) -- cycle;

\end{tikzpicture}

\end{document}

输出

在此处输入图片描述

交替输出

\newcommand{\xangle}{45}
\newcommand{\yangle}{150}
\newcommand{\zangle}{90}
\pgfmathsetmacro{\posalongpath}{0.12}
\pgfmathsetmacro{\vertexheight}{7}

在此处输入图片描述

相关内容