我可以计算平方或平方根以作为 tikz 图片中的坐标吗?

我可以计算平方或平方根以作为 tikz 图片中的坐标吗?

我正在尝试画纸飞机的折叠线。这是让我的孩子学习如何折叠纸飞机的模板。我做到了:

% based on http://michaelgoerz.net/blog/2009/07/printable-paper-with-latex-and-tikz/
\documentclass[a4paper, 10pt]{article} % for A4 size paper
\usepackage{tikz}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[remember picture, overlay]   
\tikzset{normal lines/.style={gray, very thin}} 
\tikzset{margin lines/.style={gray, thick}} 
\tikzset{mm lines/.style={gray, ultra thin}} 
\tikzset{strong lines/.style={black, very thin}} 
\tikzset{master lines/.style={black, very thick}} 
\tikzset{dashed master lines/.style={loosely dashed, black, very thick}}  
\node at (current page.south west){
  \begin{tikzpicture}[remember picture, overlay]   
    \draw[style=dashed master lines] (0.5*\paperwidth,\paperheight)--(0.5*\paperwidth,0); %middenlijn
    \draw[style=dashed master lines] (0.5*\paperwidth,\paperheight)--(\paperwidth,\paperheight-0.5*\paperwidth); %korte vleugel1
    \draw[style=dashed master lines] (0.5*\paperwidth,\paperheight)--(0,\paperheight-0.5*\paperwidth); %korte vleugel2
  \end{tikzpicture}
};
\end{tikzpicture} \end{document}

结果: 在此处输入图片描述

对于下一条折叠线,我需要知道第一条折叠线的长度。要计算这个,我只需要执行一个简单的勾股定理,即对 0.5*\paperwidth 的平方的两倍之和求平方根。我认为下面的方法可以解决问题。

\pgfmathparse{sqrt({(0.5*{\paperwidth})^2}+{pow((0.5*{\paperwidth})^2)})};
\draw[style=dashed master lines] (0.5*\paperwidth,\paperheight)--(0.5*\paperwidth,\paperheight-0.5*\pgfmathresult) ; 

不幸的是,我没有得到预期的结果。我做错了什么,或者我应该如何计算 \paperwidth 的平方根或平方?

答案1

我不太清楚你在这里想做什么。这是我的猜测

\documentclass[a4paper, 10pt]{article} % for A4 size paper
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\pagestyle{empty}

\begin{tikzpicture}[remember picture, 
                    overlay,
                    normal lines/.style={gray, very thin},
                    margin lines/.style={gray, thick},
                    mm lines/.style={gray, ultra thin}, 
                    strong lines/.style={black, very thin}, 
                    master lines/.style={black, very thick}, 
                    dashed master lines/.style={loosely dashed, black, very thick}
                   ]

  \coordinate (origin) at (current page.north west);
  \path 
        [draw,dashed] (current page.north) -- (current page.south)
        [draw,dashed] (current page.north) -- ($(current page.north west)+(0,-0.5\paperwidth)$)
        [draw,dashed] (current page.north) -- ($(current page.north east)+(0,-0.5\paperwidth)$)
        [draw,dashed] (current page.south) -- ($(current page.south west)+(0,0.5\paperwidth)$)
        [draw,dashed] (current page.south) -- ($(current page.south east)+(0,0.5\paperwidth)$)
        ;

\end{tikzpicture} 

\end{document}1

产生

在此处输入图片描述

这是一种说明@Qrrbrbirlbel 所建议的方法(尽管我确信这不是您想要的图像)

\documentclass[a4paper, 10pt]{article} % for A4 size paper
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\pagestyle{empty}

\begin{tikzpicture}[remember picture, 
                    overlay,
                    normal lines/.style={gray, very thin},
                    margin lines/.style={gray, thick},
                    mm lines/.style={gray, ultra thin}, 
                    strong lines/.style={black, very thin}, 
                    master lines/.style={black, very thick}, 
                    dashed master lines/.style={loosely dashed, black, very thick}
                   ]

  \coordinate (origin) at (current page.north west);
  \path 
        coordinate (my top center) at (current page.north) 
        coordinate (my bot center) at (current page.south)
        coordinate (my top left)   at ($(current page.north west)+(0,-0.5\paperwidth)$)
        coordinate (my top right)  at ($(current page.north east)+(0,-0.5\paperwidth)$)
        coordinate (my bot left)   at ($(current page.south west)+(0,0.5\paperwidth)$)
        coordinate (my bot right)  at ($(current page.south east)+(0,0.5\paperwidth)$)
        ;
  \draw[dashed] (my top center) -- (my top left);
  \path let
          \p1=($(my top left)-(my top center)$),
          \p2=($(my top right)-(my top center)$),
          \n1={veclen(\x1,\y1)},
          \n2={atan2(\y1,\x1)},
          \n3={atan2(\y2,\x2)}
        in
        [draw,dashed] (my top left) arc (\n2:180:\n1);

\end{tikzpicture} 

\end{document}1

在此处输入图片描述

如果我更好地了解您所追求的目标,我相信我可以给出更好的答案。

相关内容