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.

Based on the first answer given here, I was trying to mark different angles. However, I need that the last angle (C_1 D C_6) is to be measured from the other direction (reflex angle) which I could not achieve:

Here is my code:

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

\usepackage{color, amsmath}
\newcommand\ptext[1]{\textcolor{purple}{$#1$}}

\begin{document}

\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
  \def\tikz@AngleOfLine(#1)(#2)#3{
  \pgfmathanglebetweenpoints{
    \pgfpointanchor{#1}{center}}{
    \pgfpointanchor{#2}{center}}
  \pgfmathsetmacro{#3}{\pgfmathresult}
  }

\begin{tikzpicture}[dot/.style 2 args={circle, color={#2},outer sep=0pt, inner sep=1.5pt, fill ,name=#1},
dot/.default={}{blue},
  ex line/.default = {1cm},
  ex line/.style={shorten >=-#1, ->, color=blue},
  line/.default=1cm,
  line/.style={}]

\node [dot={C_1}{green}, label={[xshift=-0.15cm, yshift=0.05cm]\ptext{C_1}}] at (0, 0) {};
\node [dot={C_2}{green}, label={[xshift=0.1cm, yshift=0.1cm]\ptext{C_2}}] at (-2.3,1) {};
\node [dot={C_3}{green}, label={[xshift=0cm, yshift=0cm]\ptext{C_3}}] at (-4,4.3) {};
\node [dot={C_4}{green}, label={[xshift=-.05cm, yshift=0.05cm]\ptext{C_4}}] at (2.5,5) {};
\node [dot={C_5}{green}, label={[xshift=0cm, yshift=0cm]\ptext{C_5}}] at (4.9,3) {};
\node [dot={C_6}{green}, label={[xshift=-0.1cm, yshift=0cm]\ptext{C_6}}] at (4,1) {};

\draw [line] (C_1) -- (C_2);
\draw [line] (C_2) -- (C_3);
\draw [line] (C_3) -- (C_4);
\draw [line] (C_4) -- (C_5);
\draw [line] (C_5) -- (C_6);
\draw [line] (C_6) -- (C_1);

\node [dot={D}{blue},label={[xshift=0.15cm, yshift=-0.7cm]\ptext{D}}] at (.85,2.17) {};
\draw [ex line, very thick] (D) -- (C_1);

\tikzAngleOfLine(D)(C_1){\AngleStart}

\foreach \num in {2, 3, 4, 5, 6}{    
\draw [ex line] (D) -- (C_\num);
\tikzAngleOfLine(D)(C_\num){\AngleEnd}

\draw[red,->] (D)+(\AngleStart:0.75+\num*0.15cm) arc (\AngleStart:\AngleEnd:0.75+\num*0.15cm);   
}

\end{tikzpicture}
\end{document}

How to do that?

share|improve this question

2 Answers 2

You can use an if condition or do it separately or make the condition choose only the arrow head size etc. Here is a generic solution

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\usepackage{amsmath}
\newcommand\ptext[1]{\textcolor{purple}{$#1$}}

\begin{document}

\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
  \def\tikz@AngleOfLine(#1)(#2)#3{
  \pgfmathanglebetweenpoints{
    \pgfpointanchor{#1}{center}}{
    \pgfpointanchor{#2}{center}}
  \pgfmathsetmacro{#3}{\pgfmathresult}
  }

\begin{tikzpicture}[dot/.style 2 args={circle, color={#2},outer sep=0pt, inner sep=1.5pt, fill ,name=#1},
dot/.default={}{blue},
  ex line/.default = {1cm},
  ex line/.style={shorten >=-#1, ->, color=blue},
  line/.default=1cm,
  line/.style={}]

\node [dot={C_1}{green}, label={[xshift=-0.15cm, yshift=0.05cm]\ptext{C_1}}] at (0, 0) {};
\node [dot={C_2}{green}, label={[xshift=0.1cm, yshift=0.1cm]\ptext{C_2}}] at (-2.3,1) {};
\node [dot={C_3}{green}, label={[xshift=0cm, yshift=0cm]\ptext{C_3}}] at (-4,4.3) {};
\node [dot={C_4}{green}, label={[xshift=-.05cm, yshift=0.05cm]\ptext{C_4}}] at (2.5,5) {};
\node [dot={C_5}{green}, label={[xshift=0cm, yshift=0cm]\ptext{C_5}}] at (4.9,3) {};
\node [dot={C_6}{green}, label={[xshift=-0.1cm, yshift=0cm]\ptext{C_6}}] at (4,1) {};

\draw [line] (C_1) -- (C_2);
\draw [line] (C_2) -- (C_3);
\draw [line] (C_3) -- (C_4);
\draw [line] (C_4) -- (C_5);
\draw [line] (C_5) -- (C_6);
\draw [line] (C_6) -- (C_1);

\node [dot={D}{blue},label={[xshift=0.15cm, yshift=-0.7cm]\ptext{D}}] at (.85,2.17) {};
\draw [ex line, very thick] (D) -- (C_1);

\tikzAngleOfLine(D)(C_1){\AngleStart}

\foreach \num in {2, 3, 4, 5, 6}{    
\draw [ex line] (D) -- (C_\num);
\tikzAngleOfLine(D)(C_\num){\AngleEnd}
\ifnum\num=6\relax
\draw[red,->] (D)+(\AngleEnd:0.75+\num*0.15cm) arc (\AngleEnd:\AngleStart:0.75+\num*0.15cm);   
\else
\draw[red,->] (D)+(\AngleStart:0.75+\num*0.15cm) arc (\AngleStart:\AngleEnd:0.75+\num*0.15cm);   
\fi
}

\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Thank you @percusse for your response, but I wanted a different thing. With a small change in your given code I finally got what I wanted. :-) –  pushpen.paul Apr 6 at 13:42

As I mentioned, I found my solution just by replacing this line from percusse's solution

\draw[red,->] (D)+(\AngleEnd:0.75+\num*0.15cm) arc (\AngleEnd:\AngleStart:0.75+\num*0.15cm);   

with

\draw[red,<-] (D)+(\AngleEnd:0.75+\num*0.15cm) arc (\AngleEnd:360+\AngleStart:0.75+\num*0.15cm);   

, which gives: .

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.