测量/尺寸线(与线平行的线)

测量/尺寸线(与线平行的线)

我在绘制与线平行的倾斜“测量线”时遇到了问题。

在此处输入图片描述

\documentclass[border=2pt,tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}

\begin{center}
\begin{tikzpicture}
\coordinate (A) at (1,1);
\coordinate (B) at (4,4);
\fill (A) circle(.5mm);
\fill (B) circle(.5mm);
\draw (A)--(B);
\coordinate (P1) at ($($(A)!1!(B)$)!.2cm!90:(B)$);
\coordinate (P2) at ($($(A)!0!(B)$)!.2cm!90:(B)$);
\draw[|<->|] (P1)--(P2);
\end{tikzpicture}
\end{center}

\end{document}

请注意,该行以“1”结尾,这是错误的,将 (A)!1!(B) 中的 1 改为“0.9999”会更好。我想有更好的方法可以做到这一点。TIA。

答案1

您只需使用(A)和即可(B)。然后该段足够长以获得良好的结果。

\documentclass[border=2pt,tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}
\coordinate (A) at (1,1);
\coordinate (B) at (4,4);
\fill (A) circle(.5mm);
\fill (B) circle(.5mm);
\draw (A)--(B);
\coordinate (P1) at ($(A)!.2cm!90:(B)$);
\coordinate (P2) at ($(B)!.2cm!-90:(A)$);
\draw[|<->|] (P1)--(P2);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

您还可以使用dimline这样的:

\documentclass[tikz, border=2pt]{standalone}
\usepackage{tikz-dimline, calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (1,1);
\coordinate (B) at (4,4);
\fill (A) circle(.5mm);
\fill (B) circle(.5mm);
\draw (A)--(B);
\dimline[extension start length=0.4 cm, extension end length=0.4 cm] {($(A)!.4cm!90:(B)$)} {($(B)!.4cm!-90:(A)$)}{10};
\end{tikzpicture}
\end{document}

带斜线的线

或者不带标签:

\dimline[extension start length=0.4 cm, extension end length=0.4 cm, label style=transparent] {($(A)!.4cm!90:(B)$)} {($(B)!.4cm!-90:(A)$)}{};

答案3

您还可以使用 - 在我看来 - 令人惊叹的套餐tkz-euclide并执行以下操作:

\documentclass[border=2mm, tikz]{standalone}

\usepackage{tkz-euclide}

\begin{document}

    \begin{tikzpicture}
        \tkzDefPoints{
        1/1/A,
        4/4/B}
        \tkzDrawSegment[dim={,4mm,transparent}](A,B)
        \tkzDrawPoints(A,B)
    \end{tikzpicture}

\end{document}

在此处输入图片描述

答案4

平行线和垂直线的不同形式:

% parallel4.tex
\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}

    \coordinate (a) at (0,1);
    \coordinate (b) at (3,2);
    \coordinate (c) at (2.5,0);

    \node[left] at (a){a};
    \node[right] at (b){b};
    \node[below] at (c){c};

    \draw[gray!40] (a) -- (b) -- (c) -- cycle;

    % Project the middle point (p): (.)(p)(.) over line (.)(.)
    \draw[red]    (a) -- ($(b)!(a)!(c)$);
    \draw[green]  (b) -- ($(a)!(b)!(c)$);
    \draw[blue]   (c) -- ($(a)!(c)!(b)$);

    \draw[->] ($(a)!(3,1)!(b)$) -- (3,1) ;


    % Perpendicular at a position in the middle of a line (.)(.)
    % and with a length d:   (.)x(.)d
    % first number is the position, second, the length but
    % taking a proportion of the first position 
    \draw[->] ($(a)!.5!(c)!.1!90:(a)$) -- ($(a)!.5!(c)!.1!-90:(a)$) ;

    % Parallel to (.)(.) at a distance d: (.)d(.)
    \draw[->] ($(a)!-.1!90:(c)$) -- ($(c)!-.1!-90:(a)$) ;

    \coordinate (A) at (0,3);
    \coordinate (B) at (2,5);
    \fill (A) circle(.5mm) node[below] {A};
    \fill (B) circle(.5mm) node[right] {B};
    \draw (A)--(B);

    % Parallel to (.)(.) to measure:
    \coordinate (P1) at ($(A)!.2cm!90:(B)$);
    \coordinate (P2) at ($(B)!.2cm!-90:(A)$);
    \draw[|<->|] (P1)--(P2);

    % directamente
    \draw[|>-<|] ($(A)!-.2cm!90:(B)$)--($(B)!-.2cm!-90:(A)$);

    % Parallel to measure but with lines limiting:
    \draw[shorten >= -0.25cm] (a) -- ($(a)!0.1!90:(b)$);
    \draw[shorten >= -0.25cm] (b) --($(b)!0.1!-90:(a)$);
    \draw[<->] ($(a)!0.1!90:(b)$)--($(b)!0.1!-90:(a)$);

\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容