6

I'm having issues with the intersection feature. It works, but it seems to "miss" the true intersection a bit. The code below produces the error for me. See this image (can't post it directly because <10 rep points):

http://i.imgur.com/WfRBQ.jpg

Notice how the point E2 is slightly below and to the right of the true intersection. Is this just a calculation error? Or am I doing something wrong?

Cheers,

Trevor

\usepackage{tikz}
\usetikzlibrary{arrows,shapes,trees,calc}
\usetikzlibrary{intersections}
\usepackage{relsize}

\begin{tikzpicture}[
    scale=2.2,
    dot/.style={circle, fill=black, minimum size=4pt, inner sep=0pt},]
\newcommand\Sshift{0.8cm}

\coordinate (D_1L) at (0.2,1.8); % DL begin
\coordinate (D_2L) at (2.3,0.2); % DL end
\coordinate (S_1L) at (0.2,0.2); % SL begin
\coordinate (S_2L) at (1.8,1.8); % SL end
\coordinate (S_21L) at ([xshift=\Sshift] S_1L);
\coordinate (S_22L) at ([xshift=\Sshift] S_2L);

\draw[axis,<->] (2.8,0) node(Sxaxis)[right] {$Q_{sec}$}
      -| (0,2) node(Syaxis)[above] {$P_{sec}$};

\draw[line, thick] (S_1L) -- (S_2L) node[right] {$S_1$};
\draw[line] (D_1L) -- (D_2L) node[right] {$D$};
\draw[line, thick] (S_21L) -- (S_22L) node[right] (S_22L) {$S_2$};

% intersections
\coordinate (E1L) at (intersection of S_1L--S_2L and D_1L--D_2L);
 \draw[dashed] (Syaxis |- E1L) node[left]{$P_1$}
 -| (Sxaxis -|E1L) node[below]{$Q_1$};
 \node[dot, label=above:{$E_1$}] (E1) at (E1L) {};
\coordinate (E2L) at (intersection of S_21L--S_22L and D_1L--D_2L);
 \draw[dashed] (Syaxis |- E2L) node[left]{$P_2$}
 -| (Sxaxis -|E2L) node[below]{$Q_2$};
 \node[dot, label=right:{$E_2$}] (E2) at (E2L) {};

\end{tikzpicture}
1
  • 2
    Your example is not complete : line/.style ? axis/.style ? \begin{document}? the class ? Jun 6, 2012 at 6:10

2 Answers 2

13

You made a mistake here (I removed the unknown styles)

\draw[,thick] (S_21L) -- (S_22L) node[right] (S_22L) {$S_2$};  

You need to remove the last (S_22L)

    \draw[, thick] (S_21L) -- (S_22L) node[right]  {$S_2$};

You move the the coordinates (S_22L) with node[right] and S_22L) now is not on the line.

\documentclass{scrartcl}    
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,trees,calc}
\usetikzlibrary{intersections}
\usepackage{relsize}

\begin{document}
    \begin{tikzpicture}[
        scale=2.2,
        dot/.style={circle, fill=black, minimum size=4pt, inner sep=0pt},]
    \newcommand\Sshift{0.8cm}

    \coordinate (D_1L) at (0.2,1.8); % DL begin
    \coordinate (D_2L) at (2.3,0.2); % DL end
    \coordinate (S_1L) at (0.2,0.2); % SL begin
    \coordinate (S_2L) at (1.8,1.8); % SL end
    \coordinate (S_21L) at ([xshift=\Sshift] S_1L);
    \coordinate (S_22L) at ([xshift=\Sshift] S_2L);

    \draw[<->] (2.8,0) node (Sxaxis)[right] {$Q_{sec}$}
            -| (0,2)   node (Syaxis)[above] {$P_{sec}$};

    \draw[, thick] (S_1L)  -- (S_2L)  node[right] {$S_1$};
    \draw[]        (D_1L)  -- (D_2L)  node[right] {$D$};
    \draw[, thick] (S_21L) -- (S_22L) node[right]  {$S_2$};

    % intersections
    \coordinate (E1L) at (intersection of S_1L--S_2L and D_1L--D_2L);
     \draw[dashed] (Syaxis |- E1L) node[left]{$P_1$}
     -| (Sxaxis -|E1L) node[below]{$Q_1$};
     \node[dot, label=above:{$E_1$}] (E1) at (E1L) {};
    \coordinate (E2L) at (intersection of S_21L--S_22L and D_1L--D_2L);
     \draw[dashed] (Syaxis |- E2L) node[left]{$P_2$}
     -| (Sxaxis -|E2L) node[below]{$Q_2$};

     \node[dot, label=right:{$E_2$}] (E2) at (E2L) {};

    \end{tikzpicture}   
\end{document}

enter image description here

0
0

Using the tzplot package:

enter image description here

\documentclass[tikz]{standalone}
    
\usepackage{tzplot}

\begin{document}

\begin{tikzpicture}[scale=2.2]
\tzaxes(3,2){$Q_{sec}$}{$P_{sec}$}
\tzline"DL"(0.2,1.8)(2.3,0.2){$D$}[r]
\tzline[thick]"SL1"(0.2,0.2)(1.8,1.8){$S_1$}[r]
\tzline[thick]<.8,0>"SL2"(0.2,0.2)(1.8,1.8){$S_2$}[r] % shifted
\tzXpoint*{DL}{SL1}(E1){$E_1$}
\tzXpoint*{DL}{SL2}(E2){$E_2$}[0]
\tzproj(E1){$Q_1$}{$P_1$}
\tzproj(E2){$Q_2$}{$P_2$}
\end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .