绘制跨两个交叉点的线

绘制跨两个交叉点的线

我想画下面的图。我有以下代码

\documentclass[border=5pt]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \draw[very thick]
        (-6, 2.5)--
            (1, -0.5)

        (-6, 0)--
            (1, 0)
        ;

    \draw[dashed, thick]
        (-3, 3)--
            (-5, -0.5)

        (-1, 3)--
            (-3, -0.5)
        ;
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案1

intersections有了图书馆,一切就变得非常简单了。

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}

\begin{tikzpicture}
    \path[draw, name path=L1,very thick]
        (-6, 2.5)--(1, -0.5);
    \path[draw, name path=L2,very thick]
        (-6, 0)--(1, 0);

    \path [draw, name path=LD1, dashed, thick]
        (-3, 3)--(-5, -0.5);
    \path [draw, name path=LD2, dashed, thick]
        (-1, 3)--(-3, -0.5);

    \path [name intersections={of=L2 and LD1, by={A}}];    
    \path [name intersections={of=L1 and LD2, by={B}}];

\draw [red,very thick,shorten >=-0.75cm, shorten <=-0.75cm] (A) -- (B);

\filldraw [red](A) circle (2pt)node[anchor=south east]{$A$};
\filldraw [red](B) circle (2pt)node[anchor=south]{$B$};

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容