我希望A
、B
、C
和D
的节点与 的边的rectangle ABCD
距离相同。显然它们不是。我将节点放在圆圈中,并用小绿色圆盘标记这些圆圈上最靠近四边形边的点。这些绿色圆盘与四边形边的距离不同。我还使用了类似命令0.15cm
quadrilateral PQRS
\draw[dashed] ($(A)!0.15!-90:(S)$) -- ($(S)!0.15!90:(A)$);
标记应该来自0.15cm
四边形边的线段。显然它们不是。为什么在TikZ
呈现这些命令时会出现不一致的情况?
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,intersections,quotes}
\begin{document}
\begin{tikzpicture}
%Vertex A is located. It is a vertex on the bottom edge of the rectangle.
\coordinate (A) at (0,0);
\path[name path=a_path_to_define_the_bottom_side_of_rectangle] (0,0) -- (4,0);
%Vertex A is the midpoint of side PS of the circumscribing quadrilateral.
\coordinate (P) at (-2.25,0.75);
\coordinate (S) at (2.25,-0.75);
\path (P) -- (S);
%Vertex B of the rectangle is located. It is the intersection of a horizontal line
%through A and the line of slope 4/5 through S. Vertex R of the circumscribing
%quadrilateral is located so that B is the midpoint of side RS.
\path[name path=a_path_to_define_RS_of_quadrilateral] (S) -- ($(S) +({atan(4/5)}:2.5)$);
\coordinate[name intersections={of=a_path_to_define_the_bottom_side_of_rectangle and a_path_to_define_RS_of_quadrilateral, by=B}];
\draw let \p1=($(S)-(B)$), \n1={atan(\y1/\x1)} in coordinate (R) at ($(B) +(\n1:{veclen(\x1,\y1)})$);
\draw[green] (R) -- (S);
%Vertex Q of the circumscribing quadrilateral is located. Since vertex D
%of the inscribed rectangle is to be the midpoint of side PQ of the circumscribing
%quadrilateral, side AD is to be parallel to QS. So, Q is a point on the vertical
%line through S. Q is also twice the distance from P as D is from P.
\path[name path=a_path_to_locate_Q] (S) -- ($(S) +(0,3.5)$);
\path[name path=another_path_to_locate_Q] let \p1=($(P)-(0,0)$) in ($(P) +(0:{2*veclen(\x1,\y1)})$) arc (0:20:{2*veclen(\x1,\y1)});
\coordinate[name intersections={of=a_path_to_locate_Q and another_path_to_locate_Q, by=Q}];
%C is the midpoint of side QR of the circumscribing quadrilateral.
\draw[name path=side_QR] (Q) -- (R);
\path[name path=a_path_to_locate_C] (B) -- ($(B) +(0,2)$);
\coordinate[name intersections={of=side_QR and a_path_to_locate_C, by=C}];
%Vertex D of the rectangle is located.
\draw let \p1=($(A)-(B)$) in coordinate (D) at ($(C) +({-1*veclen(\x1,\y1)},0)$);
%Rectangle ABCD is drawn.
\draw (A) -- (B) -- (C) -- (D) -- cycle;
%The labels for the vertices of the rectangle are typeset.
\draw let \p1=($(P)-(S)$), \n1={atan(\y1/\x1)} in node[anchor={\n1+90}, inner sep=0,draw,circle] at ($(A)!0.15!-90:(S)$){$A$};
\draw let \p1=($(R)-(S)$), \n1={atan(\y1/\x1)} in node[anchor={\n1+90}, inner sep=0,draw,circle] at ($(B)!0.15!-90:(R)$){$B$};
\draw let \p1=($(Q)-(R)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-90}, inner sep=0,draw,circle] at ($(C)!0.15!90:(R)$){$C$};
\draw let \p1=($(P)-(Q)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-90}, inner sep=0,draw,circle] at ($(D)!0.15!90:(Q)$){$D$};
\draw[fill=green] ($(A)!0.15!-90:(S)$) circle (1pt);
\draw[dashed] ($(A)!0.15!-90:(S)$) -- ($(S)!0.15!90:(A)$);
\draw[fill=green] ($(B)!0.15!-90:(R)$) circle (1pt);
\draw[dashed] ($(B)!0.15!-90:(R)$) -- ($(R)!0.15!90:(B)$);
\draw[fill=green] ($(C)!0.15!90:(R)$) circle (1pt);
\draw[dashed] ($(C)!0.15!90:(R)$) -- ($(R)!0.15!-90:(C)$);
\draw[fill=green] ($(D)!0.15!90:(Q)$) circle (1pt);
\draw[dashed] ($(D)!0.15!90:(Q)$) -- ($(Q)!0.15!-90:(D)$);
%Quadrilateral PQRS is drawn.
\draw (P) -- (Q) -- (R) -- (S) -- cycle;
\node[anchor=east, inner sep=0] at ($(P) +(-0.15,0)$){$P$};
\node[anchor=south, inner sep=0] at ($(Q) +(0,0.15)$){$Q$};
\node[anchor=west, inner sep=0] at ($(R) +(0.15,0)$){$R$};
\node[anchor=north, inner sep=0] at ($(S) +(0,-0.15)$){$S$};
\end{tikzpicture}
\end{document}
答案1
如果您不指定单位,那么您要求的点是第一个点到第二个点之间的距离的 15%。如果您指的是 1.5 毫米,那么您必须明确说明0.15cm
(或1.5mm
):
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc,intersections}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\path[name path=a_path_to_define_the_bottom_side_of_rectangle] (0,0) -- (4,0);
\coordinate (P) at (-2.25,0.75);
\coordinate (S) at (2.25,-0.75);
\path (P) -- (S);
\path[name path=a_path_to_define_RS_of_quadrilateral] (S) -- ($(S) +({atan(4/5)}:2.5)$);
\coordinate[name intersections={of=a_path_to_define_the_bottom_side_of_rectangle and a_path_to_define_RS_of_quadrilateral, by=B}];
\draw let \p1=($(S)-(B)$), \n1={atan(\y1/\x1)} in coordinate (R) at ($(B) +(\n1:{veclen(\x1,\y1)})$);
\draw[green] (R) -- (S);
\path[name path=a_path_to_locate_Q] (S) -- ($(S) +(0,3.5)$);
\path[name path=another_path_to_locate_Q] let \p1=($(P)-(0,0)$) in ($(P) +(0:{2*veclen(\x1,\y1)})$) arc (0:20:{2*veclen(\x1,\y1)});
\coordinate[name intersections={of=a_path_to_locate_Q and another_path_to_locate_Q, by=Q}];
\draw[name path=side_QR] (Q) -- (R);
\path[name path=a_path_to_locate_C] (B) -- ($(B) +(0,2)$);
\coordinate[name intersections={of=side_QR and a_path_to_locate_C, by=C}];
\draw let \p1=($(A)-(B)$) in coordinate (D) at ($(C) +({-1*veclen(\x1,\y1)},0)$);
\draw (A) -- (B) -- (C) -- (D) -- cycle;
\draw let \p1=($(P)-(S)$), \n1={atan(\y1/\x1)} in node[anchor={\n1+90}, inner sep=0,draw,circle] at ($(A)!0.15!-90:(S)$){$A$};
\draw let \p1=($(R)-(S)$), \n1={atan(\y1/\x1)} in node[anchor={\n1+90}, inner sep=0,draw,circle] at ($(B)!0.15!-90:(R)$){$B$};
\draw let \p1=($(Q)-(R)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-90}, inner sep=0,draw,circle] at ($(C)!0.15!90:(R)$){$C$};
\draw let \p1=($(P)-(Q)$), \n1={atan(\y1/\x1)} in node[anchor={\n1-90}, inner sep=0,draw,circle] at ($(D)!0.15!90:(Q)$){$D$};
\draw[fill=green] ($(A)!0.15cm!-90:(S)$) circle (1pt);
\draw[dashed] ($(A)!0.15cm!-90:(S)$) -- ($(S)!0.15cm!90:(A)$);
\draw[fill=green] ($(B)!0.15cm!-90:(R)$) circle (1pt);
\draw[dashed] ($(B)!0.15cm!-90:(R)$) -- ($(R)!0.15cm!90:(B)$);
\draw[fill=green] ($(C)!0.15cm!90:(R)$) circle (1pt);
\draw[dashed] ($(C)!0.15cm!90:(R)$) -- ($(R)!0.15cm!-90:(C)$);
\draw[fill=green] ($(D)!0.15cm!90:(Q)$) circle (1pt);
\draw[dashed] ($(D)!0.15cm!90:(Q)$) -- ($(Q)!0.15cm!-90:(D)$);
\draw (P) -- (Q) -- (R) -- (S) -- cycle;
\node[anchor=east, inner sep=0] at ($(P) +(-0.15cm,0)$){$P$};
\node[anchor=south, inner sep=0] at ($(Q) +(0,0.15cm)$){$Q$};
\node[anchor=west, inner sep=0] at ($(R) +(0.15cm,0)$){$R$};
\node[anchor=north, inner sep=0] at ($(S) +(0,-0.15cm)$){$S$};
\end{tikzpicture}
\end{document}