3D 图形中的延伸线

3D 图形中的延伸线

我怎样才能将两条线延伸到这个 3D 图形中?有点像这张图片,其中红线是虚线,表示穿过两个点的线。我以为我可以简单地将两个值乘以标量向量,但它不起作用。 在此处输入图片描述

\documentclass{article}
\usepackage[margin=1in]{geometry} 
\usepackage{tikz, tikz-3dplot}
\usepackage{amsmath}
\begin{document}
    \tdplotsetmaincoords{75}{135}
    \begin{tikzpicture} [scale=1.1, tdplot_main_coords, axis/.style={->,black,thick}, 
    vector/.style={-stealth,black,very thick}, 
    vector guide/.style={dashed,black,thick}]

        %standard tikz coordinate definition using x, y, z coords
        \coordinate (origin) at (0,0,0);
        \coordinate (a) at (-3,0,1);
        \coordinate (b) at (0,1,2);
        \coordinate (c) at (2,-1,1);
        \coordinate (d) at (1,2,0);

        %draw axes
        \draw[axis] (0,0,0) -- (4,0,0) node[anchor=north east]{$x$};
        \draw[axis] (0,0,0) -- (0,4,0) node[anchor=north west]{$y$};
        \draw[axis] (0,0,0) -- (0,0,4) node[anchor=south]{$z$};

        % Draw two points
        \draw[fill=black] (a) circle[radius=2pt] node[anchor=north west]{$a=(-3,0,1)$};
        \draw[fill=black] (b) circle[radius=2pt] node[anchor=south west]{$b=(0,1,2)$};
        \draw[fill=black] (c) circle[radius=2pt] node[anchor=south]{$c=(2,-1,1)$};
        \draw[fill=black] (d) circle[radius=2pt] node[anchor=north]{$d=(1,2,0)$};

        %draw guide lines to components
        \draw[vector guide] (origin) -- (a);
        \draw[vector guide] (origin) -- (b);
        \draw[vector guide] (origin) -- (c);
        \draw[vector guide] (origin) -- (d);

        % Draw parametric lines
        \draw[line width=1pt] (a) -- (b) node[yshift=0.5cm, anchor=south]{$ta + b$};
        \draw[line width=1pt] (c) -- (d) node[yshift=0.5cm, anchor=south]{$tc + d$};
    \end{tikzpicture}
\end{document}

答案1

您可以使用库添加多个向量calc,该库会自动加载tikz-3dplot。例如

\draw (c) -- ($(c)+0.5*($(c)-(d)$)$);

cc加上 0.5 倍c-d。此示例及其他示例包含在

\documentclass{article}
\usepackage[margin=1in]{geometry} 
\usepackage{tikz, tikz-3dplot}
\usepackage{amsmath}
\begin{document}
\tdplotsetmaincoords{75}{135}
\begin{tikzpicture}[scale=1.1, tdplot_main_coords, axis/.style={->,black,thick}, 
vector/.style={-stealth,black,very thick}, 
vector guide/.style={dashed,black,thick},
vector extension/.style={densely dashed,red,-stealth}]

    %standard tikz coordinate definition using x, y, z coords
    \coordinate (origin) at (0,0,0);
    \coordinate (a) at (-3,0,1);
    \coordinate (b) at (0,1,2);
    \coordinate (c) at (2,-1,1);
    \coordinate (d) at (1,2,0);
    \draw[vector extension] (c) -- ($(c)+0.5*($(c)-(d)$)$);
    \draw[vector extension] (d) -- ($(d)+0.5*($(d)-(c)$)$);
    \draw[vector extension] (a) -- ($(a)+0.5*($(a)-(b)$)$);
    \draw[vector extension] (b) -- ($(b)+0.5*($(b)-(a)$)$);
    %draw axes
    \draw[axis] (0,0,0) -- (4,0,0) node[anchor=north east]{$x$};
    \draw[axis] (0,0,0) -- (0,4,0) node[anchor=north west]{$y$};
    \draw[axis] (0,0,0) -- (0,0,4) node[anchor=south]{$z$};

    % Draw two points
    \draw[fill=black] (a) circle[radius=2pt] node[anchor=north west]{$a=(-3,0,1)$};
    \draw[fill=black] (b) circle[radius=2pt] node[anchor=south west]{$b=(0,1,2)$};
    \draw[fill=black] (c) circle[radius=2pt] node[anchor=south]{$c=(2,-1,1)$};
    \draw[fill=black] (d) circle[radius=2pt] node[anchor=north]{$d=(1,2,0)$};

    %draw guide lines to components
    \draw[vector guide] (origin) -- (a);
    \draw[vector guide] (origin) -- (b);
    \draw[vector guide] (origin) -- (c);
    \draw[vector guide] (origin) -- (d);

    % Draw parametric lines
    \draw[line width=1pt] (a) -- (b) node[yshift=0.5cm, anchor=south]{$ta + b$};
    \draw[line width=1pt] (c) -- (d) node[yshift=0.5cm, anchor=south]{$tc + d$};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容