我想用reverseclip
这张图片。第一种方式。
\documentclass[border=2mm,tikz]{standalone}
\usepackage{fouriernc}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc,backgrounds}
\usepackage{tkz-euclide,amsmath}
\usetkzobj{all}
\usepackage{pgfplots}
\tikzset{reverseclip/.style={insert path={(current bounding box.south west)rectangle
(current bounding box.north east)} }}
\begin{document}
%polar coordinates of visibility
\tdplotsetmaincoords{70}{330}
\begin{tikzpicture}[tdplot_main_coords,scale=1.5,line join = round, line cap = round]
\coordinate (B) at (0, 0, 0);
\coordinate (Q) at ({-3*sqrt(15)/4}, -3/4, 0);
\coordinate (A) at ($ 2*(Q) - (B) $);
\coordinate (C) at (0, 4, 3);
\coordinate (D) at (0, 0, 3);
\coordinate (P) at (0, 2, 3);
\coordinate (R) at (0, 2, 0);
\coordinate (M) at ($ 3.5*(R) - (B) $);
\coordinate (X) at (-7,-3,0);
\coordinate (Y) at (-7,3,0);
\coordinate (Z) at (2,3,0);
\coordinate (T) at (2,-3,0);
\foreach \v/\position in {A/below,B/below, D/above,P/above,C/above,R/below,Q/below} {\draw[draw =black, fill=black] (\v) circle (1.2pt) node [\position=0.2mm] {$\v$};
}
\draw[thick] (A) -- (B) -- (D) -- (C) --cycle
(A) -- (D) (Y) -- (X) -- (T) -- (Z) ;
;
\draw [dashed] (P) -- (Q) --(R) --cycle
(B) -- (C)
;
\begin{scope}
\draw [dashed](Y)-- (Z);
\clip (C) -- (A) -- (B) -- (D) -- cycle [reverseclip];
\draw [ thick](Y)-- (Z);
\end{scope}
\tkzMarkRightAngle(D,B,A);
\tkzMarkRightAngle(B,D,C);
\tkzMarkRightAngle(P,R,Q);
\end{tikzpicture}
\end{document}
第二种方式(我得到了错误的结果)
\documentclass[border=2mm,tikz]{standalone}
\usepackage{fouriernc}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc,backgrounds}
\usepackage{tkz-euclide,amsmath}
\usetkzobj{all}
\usepackage{pgfplots}
\tikzset{reverseclip/.style={insert path={(current bounding box.south west)rectangle
(current bounding box.north east)} }}
\begin{document}
%polar coordinates of visibility
\tdplotsetmaincoords{70}{330}
\begin{tikzpicture}[tdplot_main_coords,scale=1.5,line join = round, line cap = round]
\coordinate (B) at (0, 0, 0);
\coordinate (Q) at ({-3*sqrt(15)/4}, -3/4, 0);
\coordinate (A) at ($ 2*(Q) - (B) $);
\coordinate (C) at (0, 4, 3);
\coordinate (D) at (0, 0, 3);
\coordinate (P) at (0, 2, 3);
\coordinate (R) at (0, 2, 0);
\coordinate (M) at ($ 3.5*(R) - (B) $);
\foreach \v/\position in {A/below,B/below, D/above,P/above,C/above,R/below,Q/below} {\draw[draw =black, fill=black] (\v) circle (1.2pt) node [\position=0.2mm] {$\v$};
}
\draw[thick] (A) -- (B) -- (D) -- (C) --cycle
(A) -- (D)
;
\draw [dashed] (P) -- (Q) --(R) --cycle
(B) -- (C)
;
\begin{scope} [canvas is xy plane at z=0,transform shape]
\draw [dashed]
(-7,-3) rectangle (2,3);
\clip (C)-- (A) -- (B) -- (D) -- cycle [reverseclip];
\draw[thick] (-7,-3) rectangle (2,3);
\end{scope}
\tkzMarkRightAngle(D,B,A);
\tkzMarkRightAngle(B,D,C);
\tkzMarkRightAngle(P,R,Q);
\end{tikzpicture}
\end{document}
[![在此处输入图片描述][2]][2]
我怎样才能reverseclip
像第二种方式一样使用矩形?
答案1
原因是你使用的reverseclip
范围是将你变换成一个平面。因此,如果你替换
\clip (C)-- (A) -- (B) -- (D) -- cycle [reverseclip];
经过
\clip[draw] (C)-- (A) -- (B) -- (D) -- cycle [reverseclip];
你得到
这解释了结果:Ti钾Z 没有绘制边界框矩形,而是绘制了与边界框具有相同的西南角和东北角的投影矩形。解决这个问题的一种方法是使用
\tikzset{reverseclip/.style={insert path={
(current bounding box.south west) --(current bounding box.north west)
--(current bounding box.north east) -- (current bounding box.south east)
-- cycle} }}
反而。
\documentclass[border=2mm,tikz]{standalone}
\usepackage{fouriernc}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc,backgrounds}
\usepackage{tkz-euclide,amsmath}
\usetkzobj{all}
\tikzset{reverseclip/.style={insert path={
(current bounding box.south west) --(current bounding box.north west)
--(current bounding box.north east) -- (current bounding box.south east)
-- cycle} }}
\begin{document}
%polar coordinates of visibility
\tdplotsetmaincoords{70}{330}
\begin{tikzpicture}[tdplot_main_coords,scale=1.5,line join = round, line cap = round]
\coordinate (B) at (0, 0, 0);
\coordinate (Q) at ({-3*sqrt(15)/4}, -3/4, 0);
\coordinate (A) at ($ 2*(Q) - (B) $);
\coordinate (C) at (0, 4, 3);
\coordinate (D) at (0, 0, 3);
\coordinate (P) at (0, 2, 3);
\coordinate (R) at (0, 2, 0);
\coordinate (M) at ($ 3.5*(R) - (B) $);
\foreach \v/\position in {A/below,B/below, D/above,P/above,C/above,R/below,Q/below} {\draw[draw =black, fill=black] (\v) circle (1.2pt) node [\position=0.2mm] {$\v$};
}
\draw[thick] (A) -- (B) -- (D) -- (C) --cycle
(A) -- (D)
;
\draw [dashed] (P) -- (Q) --(R) --cycle
(B) -- (C)
;
\begin{scope} [canvas is xy plane at z=0,transform shape]
\draw [dashed]
(-7,-3) rectangle (2,3);
\clip (C)-- (A) -- (B) -- (D) -- cycle [reverseclip];
\draw[thick] (-7,-3) rectangle (2,3);
\end{scope}
\tkzMarkRightAngle(D,B,A);
\tkzMarkRightAngle(B,D,C);
\tkzMarkRightAngle(P,R,Q);
\end{tikzpicture}
\end{document}