7

I am new to latex and pgf/tikz. My supervisor asked me to create such a figure below in pgf. I don't know where to begin. Could anybody help/lead me on this please?

enter image description here

11
  • You could draw it in Inkscape and then export it to PGF/TikZ. Dec 25, 2012 at 12:47
  • @UweZiegenhagen I can do inkscape part. It seems a simple one. I had not known about exporting to PGF. After exporting, will the quality of the image be enhanced by the PGF? Dec 25, 2012 at 12:59
  • @RızaBayoğlu: No enhancement if both are in vector format. Dec 25, 2012 at 13:06
  • Then, exporting to PGF does not make sense to me. The reason why I will create such a figure in pgf is to have a high quality image (better than inkscape). Do am I right at that point? I mean if image quality will be the same using either PGF or inkscape, I don't bother with using PGF/Tikz. Dec 25, 2012 at 13:14
  • You don't need to export to PGF/TikZ until Inkscape cannot add fancier drawings that PGF/TikZ can or your supervisor asks you to do so with a certain reason. Dec 25, 2012 at 13:20

3 Answers 3

11

Current issues:

  • Labels: not all labels I can read and so reproduce right.
  • Labels of bisectors: need a bit more customization.
  • (0, 0, 0): do it really need to be there?
  • A coordinate system on the left-down. Not hard to add so.

A couple of advantages:

  • Using em: can easily be scaled (based on font size).
  • Semi-automatic computation of right angles (kidding, just the bottom one).

Code:

\documentclass{standalone}
\usepackage[english]{babel}
\usepackage{tikz}
    \usetikzlibrary{calc}

\begin{document}
    \begin{tikzpicture}
        \coordinate (origin) at (0, 0);
        \filldraw (origin) circle (0.05em);

        \draw (origin) circle (6em);

        % Two dotted lines
        \draw[dotted] (0,8em) coordinate (p_1) -- (0,-8em) coordinate (p_2) node[below] {Bisector};
        \draw[dotted] (-9em,-3em) coordinate (q_1) -- (9em,3em) coordinate (q_2) node[above] {Bisector};

        % Vertices of the triangle
        \coordinate (a) at (5.2em, -3em);
        \filldraw (a) circle (0.05em);
        \coordinate (b) at (2.35em, 5.5em);
        \filldraw (b) circle (0.05em);
        \coordinate (c) at (-5.2em, -3em);
        \filldraw (c) circle (0.05em);

        % Triangle edge with names
        \draw[->] (a) node[below] {$3$} to node[right,midway] {$\vec{v}_1$} (b) node[above] {$1$};
        \draw[dashed] (b) to node[above] {$\vec{v}_3$} (c) node[left] {$2$};
        \draw[->] (a) to node[below,midway] {$\vec{v}_2$} (c);

        % $p_c$ vector
        \draw[->,thick] (0, 0.5em) to node[right,midway] {$p_c$} (intersection of b--c and p_1--p_2);

        % $\vec{v}_4$ vector
        \draw[->,thick] ($(q_1)!0.25!(q_2)$) to node[below,midway] {$\vec{v}_4$} ($(q_1)!0.4!(q_2)$);

        % Right angle for two intersecting lines
        \coordinate (i) at ($(intersection of a--c and p_1--p_2) + (0, 0.25em)$);
        \draw (i) to ($(i)!0.25em!90:(p_1)$) coordinate (t) to ($(t)!0.25em!90:(c)$);

        \coordinate (j) at ($(intersection of a--b and q_1--q_2) + (-0.25em, -0.083em)$);
        \draw (j) to ($(j)!0.25em!90:(q_1)$) coordinate (t) to ($(t)!0.25em!90:(a)$);
    \end{tikzpicture}
\end{document}

Example:

enter image description here

1
  • Thank you m0nhawk. That is a great job. lt had been harder than l thought to make this. l will try to modify your code a bit to add more features. lt helped me alot for the beginning. Dec 25, 2012 at 18:23
10

I'm also learning TikZ, so I thought I'd take a crack at it. I do some things differently than m0nhawk, for example I avoid figuring out the vertices of the triangle. But I'm new at this, so there are probably better ways of doing some things (like, for example, the bisectors and the vectors on them).

enter image description here

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary {calc}

\begin{document}

\begin{tikzpicture}
  [
    scale=3,
    >=stealth,
    point/.style= {draw, circle, inner sep=1pt, fill=black},
    dot/.style= {draw, circle, inner sep=.2pt, fill=black},
  ]

  % the circle
  \def\rad{1}
  \node (origin) at (0,0) [point, label={below right:$P_c$}]{};
  \draw (origin) circle (\rad);

  % triangle nodes: just points on the circle
  \node (n1) at +(60:\rad) [point, label=above:$1$] {};
  \node (n2) at +(-145:\rad) [point, label=below:$2$] {};
  \node (n3) at +(-45:\rad) [point, label={below right:$3$ $(0, 0, 0)$}] {};

  % triangle edges: connect the vertices, and leave a node at the midpoint
  \draw[->] (n3) -- node (a) [label={above right:$\vec{v}_1$}] {} (n1);
  \draw[->] (n3) -- node (b) [label={below right:$\vec{v}_2$}] {} (n2);
  \draw[dashed] (n2) -- (n1);

  % Bisectors
  % start at the point lying on the line from (origin) to (a), at
  % twice that distance, and then draw a path going to the point on
  % the line lying on the line from (a) to the (origin), at 3 times
  % that distance.
  \draw[dotted]
    ($ (origin) ! 2 ! (a) $)
    node [right] {Bisector 1}
    -- ($(a) ! 3 ! (origin)$ );

  % similarly for origin and b
  \draw[dotted]
    ($ (origin) ! 2 ! (b) $)
    -- ($(b) ! 3 ! (origin)$ )
    node [right] {Bisector 2};

  % short vectors
  \draw[->]
    ($ (origin) ! -.7 ! (a) $)
    -- node [below] {$\vec{u}_4$}
    ($ (origin) ! -.1 ! (a) $);
  \draw[->]
    ($ (origin) ! -.1 ! (b) $)
    -- node [right] {$\vec{u}_3$}
    ($ (origin) ! -.7 ! (b) $);

  % Right angle symbols
  \def\ralen{.5ex}  % length of the short segment
  \foreach \inter/\first/\last in {a/n3/origin, b/n2/origin}
    {
      \draw let \p1 = ($(\inter)!\ralen!(\first)$), % point along first path
                \p2 = ($(\inter)!\ralen!(\last)$),  % point along second path
                \p3 = ($(\p1)+(\p2)-(\inter)$)      % corner point
            in
              (\p1) -- (\p3) -- (\p2)               % path
              ($(\inter)!.5!(\p3)$) node [dot] {};  % center dot
    }

    % Remote origin
    \coordinate (remote) at +(-130:2*\rad);
    \draw (remote) -- +(0, .3);
    \draw (remote) -- +(.3, 0);
    \draw (remote) -- +(-130:.2);
    \draw[dashed] (remote) -- (n3);
\end{tikzpicture}
\end{document}
2
7

Honestly I would start with the tutorials in the documentation (texdoc tikz). I've tried before to create a particular document from scratch as a way to "learn" tikz, but it was just too confusing. The tutorials take you step by step, and explain the difference between, say, path and draw, or node and \node. Start with tutorial 1, and work through it all the way. There are two constructions in tutorial 3 (taken from Euclid's "Elements") that are very similar to what you are looking for.

As mentioned in the comments, you can do this in Inkscape and export as a PDF with the PGF/TikZ option. This allows LaTeX to handle the text processing for you. This works, but I've found it is difficult to get precise placement of the text when creating the document---I have to edit in Inkscape, export, typeset, tweak in Inkscape, export typeset... and so on.

1
  • That is the answer l had expected from this post. Thank you. İ think it is the best to start with the tutorials you mentioned. İ will put here as soon as i prepared something. Dec 25, 2012 at 15:47

You must log in to answer this question.

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