但是,我希望平行线在水平线上“截断”。如果平行线在水平线上截断,则所有平行线的长度都相等,并且是无理数,端点的坐标也是如此。因此,为了绘制它们,我既不想利用线的长度,也不想利用水平线上线端点的坐标。(所有线的斜率都是 1)
我怎样才能做到这一点?
这是我用来绘制它们的代码:
\documentclass{article}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\tikzstyle{every node}=[circle, draw, fill=black!50,
inner sep=0pt, minimum width=4pt]
\begin{tikzpicture}[thick,scale=0.8]
\draw {(0,0) -- (5,-5)node{}};
\draw \foreach \x in {0,0.5,...,5}
{
(\x,-\x) node{} -- (-5+\x,-5-\x)
};
\draw {(-5,-5) -- (5,-5)};
\end{tikzpicture}
\end{document}
干杯!
答案1
一个基本的解决方案:重新计算线的长度并使用极坐标......
\documentclass{article}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\tikzstyle{every node}=[circle, draw, fill=black!50,
inner sep=0pt, minimum width=4pt]
\begin{tikzpicture}[thick,scale=0.8]
\draw {(0,0) -- (5,-5)node{}};
\draw \foreach \x in {0,0.5,...,5}
{
(\x,-\x) node{} -- + (225:{1.414*(5-\x)}) % <---
};
\draw {(-5,-5) -- (5,-5)};
\end{tikzpicture}
\end{document}
这就是您所寻找的吗?
答案2
剪切线上方(或下方)的区域。
\documentclass{article}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\tikzstyle{every node}=[circle, draw, fill=black!50,
inner sep=0pt, minimum width=4pt]
\begin{tikzpicture}[thick,scale=0.8]
\begin{scope}
\clip (-5,-5) rectangle (5,0.2);
\draw {(0,0) -- (5,-5)node{}};
\draw \foreach \x in {0,0.5,...,5}
{
(\x,-\x) node{} -- (-5+\x,-5-\x)
};
\draw {(-5,-5) -- (5,-5)};
\end{scope}
\end{tikzpicture}
\end{document}