Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm having some problems with my figure: I want the thick arrows (labeled epsilon+ and epsilon-) to extend all the way to the intersections they are pointing towards.

If I change the line length in the "intersection of" statement like:

(intersection of 100:2--+10:100 and 30:2--+120:100)

i.e. 100 instead of 4, the arrows get longer, but still not all the way there...

What explains this behaviour? Is it caused by the relative coordinates specifying the lines?

Do lines have to actually intersect to specify a coordinate using the "intersection of" or are they extended as needed to perform the calculation? (In my case, they are, but just wondering)

This is my first figure made with TikZ, and all input is appreciated. I'm thinking of resorting to using GeoGebra and exporting as TikZ or PDF, but I haven't quite given in yet.

Kind regards,

Snorre Olsen

The produced image

\documentclass[•]{article}
\usepackage{tikz}
\usepackage{amsmath}

\begin{document}

\begin{tikzpicture}[scale=1]
\tikzstyle weak=[gray, very thin, text=black]
% Direction arrows
\draw[->] (0,0) -- (210:6) node[below] {To base station B};
\draw[->] (0,0) -- (280:4) node[below] {To base station A};
\draw (210:0.5) arc(210:280:0.5) node[midway, below] {$\gamma$};
% Shifted versions of LoP's
\draw[weak] (0,0) -- node[left] {$\Delta_\text{A+}$} (100:2) +(190:4) -- +(10:4) node[right] {LoP$_\text{A+}$};
\draw[weak] (0,0) -- node[below right] {$\Delta_\text{B+}$} (30:2) 
           +(120:4) -- +(300:4) node[below] {LoP$_\text{B+}$};
\draw[weak] (0,0) -- node[right, black] {$\Delta_\text{A-}$}(280:2) 
           +(190:4) -- +(10:4) node[right] {LoP$_\text{A-}$};
% Resulting error vectors
\draw[->,thick] (0,0) -- node[above left] {$\epsilon_+$}(intersection of 100:2--+10:4 and 30:2--+120:4);
\draw[->,thick] (0,0) -- node[below] {$\epsilon_-$}(intersection of 280:2--+10:4 and 30:2--+300:4);
\end{tikzpicture}

\end{document}
share|improve this question
    
Welcome to TeX.SX! –  Torbjørn T. May 15 at 10:43

1 Answer 1

up vote 6 down vote accepted

If you add the intersections library you can give name to paths with name path, and use name intersections={of=pathA and pathB} to create coordinates at the intersections called intersection-N.

Because all the lines start in (0,0), this will be the first intersection (intersection-1), while the second intersection (intersection-2) is the one you want.

As for why your code didn't work, I don't really know. However, the (intersections of A--B and C--D) syntax isn't mentioned at all in the manual for PGF/TikZ 3.0, leading me to think/guess that it is deprecated in favour of the intersections library. That it still works is probably a remnant of code for PGF2.1, probably kept to maintain backward compatibility, and that there is something wrong with it. I'm just speculating though.

Finally, I think it is recommended using \tikzset{stylename/.style={options}}, rather than \tikzstyle{stylename}=[options] (Should \tikzset or \tikzstyle be used to define TikZ styles?). In your case you could add the style definition to the tikzpicture options, as it only applies for that one picture anyway.

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{intersections}
\begin{document}

\begin{tikzpicture}[weak/.style={gray, very thin, text=black}]
% Direction arrows
\draw[->] (0,0) -- (210:6) node[below] {To base station B};
\draw[->] (0,0) -- (280:4) node[below] {To base station A};
\draw (210:0.5) arc(210:280:0.5) node[midway, below] {$\gamma$};
% Shifted versions of LoP's
\draw[weak,name path=A1] (0,0) -- node[left] {$\Delta_\text{A+}$} (100:2) +(190:4) -- +(10:4) node[right] {LoP$_\text{A+}$};
\draw[weak,name path=B] (0,0) -- node[below right] {$\Delta_\text{B+}$} (30:2) 
           +(120:4) -- +(300:4) node[below] {LoP$_\text{B+}$};
\draw[weak,name path=A2] (0,0) -- node[right, black] {$\Delta_\text{A-}$}(280:2) 
           +(190:4) -- +(10:4) node[right] {LoP$_\text{A-}$};
% Resulting error vectors
\draw[->,thick,name intersections={of=A1 and B}] (0,0) -- node[above left] {$\epsilon_+$}(intersection-2);
\draw[->,thick,name intersections={of=A2 and B}] (0,0) -- node[below] {$\epsilon_-$}(intersection-2);
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Thank you for the quick reply! Any thoughts as to why my initial attempt failed though? Also, not quite sure I understand the intersection-2 (where does the 2 come from?) but I will read up on this. –  Snorre O. May 15 at 11:07
    
@SnorreO. To be honest, I don't really understand why the first intersection (intersection-1) didn't work either. You can have multiple intersections between two paths, and the number indicates which one is used. I didn't think too much about your original code either, but I'll have a look, and update my answer if I figure it out. –  Torbjørn T. May 15 at 11:12
    
@SnorreO. Silly me, all the paths start in (0,0), so that is of course the first intersection. I edited my answer a bit. –  Torbjørn T. May 15 at 11:38
    
@TorbjørnT. The syntax (intersection of...) was in 2.0, but is not in the documentation of 2.1. So it's even older ;) –  Kpym yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.