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 am trying to connect two points that are defined relatively to another point by polar coordinates.

Consider the figure below. The goal is to connect B and C by the black line. However, my code does not achieve the correct result.

\begin{tikzpicture}[>=latex]
    \coordinate (fov) at (0, 2);
    \fill[red] (fov) circle (2pt) node[anchor=east] {A};
    \draw[red] (fov) -- ++(295:2cm);
    \draw[red] (fov) -- ++(335:2cm);
    \fill[red] (fov)++(295:2cm) circle (2pt) node[anchor=east] {B};
    \fill[red] (fov)++(335:2cm) circle (2pt) node[anchor=south] {C};
    \draw (fov)++(295:2cm) -- (fov)++(335:2cm); 
\end{tikzpicture} 

enter image description here

What am I doing wrong?

NB: the final goal is to fill the triangle ABC.

share|improve this question
1  
You can use ([shift={(coord or point)}]<coord or point>) or via calc library ($(fov)+(335:2cm)$). –  percusse Apr 22 at 12:44
    
Think of the last draw as a path through 4 points, with a line being drawn between the middle two points. –  John Kormylo Apr 22 at 12:50

3 Answers 3

up vote 7 down vote accepted

The following example merges the single path operations to a more compact form. The needed coordinates are defined at their first use. And the lines are behind the circles (the black line on top of the red circles looked too odd to me).

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[>=latex]
    \draw[red]
      (0, 2)              coordinate (fov)
            -- +(295:2cm) coordinate (B)  
      (fov) -- +(335:2cm) coordinate (C);
    \draw (B) -- (C);
    \fill[red, radius=2pt]
      (fov) circle node[anchor=east] {A}
      (B)   circle node[anchor=east] {B}
      (C)   circle node[anchor=south] {C};
\end{tikzpicture} 
\end{document}   

Result

share|improve this answer

You can place coordinates at the end of the paths and then connect them:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[>=latex]
    \coordinate (fov) at (0, 2);
    \fill[red] (fov) circle (2pt) node[anchor=east] {A};
    \draw[red] (fov) -- ++(295:2cm);
    \draw[red] (fov) -- ++(335:2cm);
    \fill[red] (fov)++(295:2cm) coordinate (b) circle (2pt) node[anchor=east]  {B};
    \fill[red] (fov)++(335:2cm) coordinate (c) circle (2pt) node[anchor=south] {C};
    \draw (b) -- (c); 
\end{tikzpicture}

\end{document}

enter image description here

Perhaps rewriting your code with the help of the calc library gives you a better result (the black segment doesn't overwrite the red filled dots):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[>=latex]
    \coordinate (fov) at (0, 2);
    \fill[red] (fov) circle (2pt) node[anchor=east] {A};
    \draw[red] (fov) -- ++(295:2cm);
    \draw[red] (fov) -- ++(335:2cm);
    \coordinate (b) at ( $ (fov) + (295:2cm) $ );
    \coordinate (c) at ( $ (fov) +(335:2cm) $ );
    \draw (b) -- (c); 
    \fill[red] (b) circle (2pt) node[anchor=east]  {B};
    \fill[red] (c) circle (2pt) node[anchor=south] {C};
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer

enter image description here

\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}[>=latex]
    \begin{scope}{shift={(0,2)}}
    \coordinate (fov) at (0,0) ;
    \coordinate (B) at (295:2cm) ;
    \coordinate (C) at (335:2cm) ;    
    \end{scope}

    \fill[blue!20] (fov)--(B)--(C)--cycle ;
    \fill[red] (fov) circle (2pt) node[anchor=east] {A};
    \fill[red] (B) circle (2pt) node[anchor=north] {B};
    \fill[red] (C) circle (2pt) node[anchor=west] {C};


\end{tikzpicture} 
\end{document}
share|improve this answer

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.