3

How can I extend the two lines I have through this 3d graph? Kind of like this picture, where the red lines would be dotted lines showing the line going through the two points. I thought I could simply multiply both values by a scalar vector, but it didn't work. enter image description here

\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}
Evan Kim
  • 430
  • The continuation of a line in 3D is still a line, so you can make the lines longer with’shorten=’. –  Sep 01 '19 at 21:28

1 Answers1

6

You can add a some multiple of vectors using the calc library, which gets auto-loaded with tikz-3dplot. E.g.

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

draws from c to c plus 0.5 times c-d. This and further examples are contained in

\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}

enter image description here