I am looking to create the 15-sided irregular polygon figure below, without having to declare coordinates for each point.

15-sided Irregular Polygon with angles

Is there an easier way to do this? Tikz? PGF?

  • 1
    Are those angles random or fixed? – percusse May 23 '13 at 20:24
  • Perhaps this answer will get you started: Circular sequence diagram (tikz?). Just connect the endpoints, and don't draw the circle. – Peter Grill May 23 '13 at 20:26
  • Are the lengths of all segments identical? – Jake May 23 '13 at 20:32
  • Starting point can be something like \draw (90:3) \foreach \x in {0, 80, 185, 200, 270} { -- (90+\x:3) node [anchor=\x] {\x} } -- cycle; – Jori Mäntysalo May 23 '13 at 20:43
  • How is this figure built? What do the angles mean? How long are the segments? I suggest TikZ’ turtle library (maybe with some adjustments). – Qrrbrbirlbel May 23 '13 at 21:01

Here's a way to draw this polygon from a list of interior angles. The key points are the \pgfextra{...} command, which allows you to execute code without interrupting the path construction, and the \path commands with the name path keywords within the pgfinterruptboundingbox environment, which are used to find the final corner.

\usetikzlibrary{shapes.geometric, intersections}

\draw (0,0) -- (0:1cm) \foreach \angle in {152,165,167,160,160,150,150,150,170,145,170,155,170,155}{ 
    \pgfextra{  % Calculate the current direction
 -- ++(\totalangle:1cm) node [pos=0, circle, anchor=(\totalangle+\angle/2+180), inner sep=0pt] {$\angle^\circ$}
} coordinate (final);


% The final point is on the intersection between the extensions of the first and last segments.
% Interrupt the bounding box, so we can use long paths for finding the intersection.
    \path [name path global=horizontal] (-20cm,0pt) -- (20cm,0pt);
    \path [name path global=lastsegment] (final) -- +(\totalangle:30cm);

\draw [name intersections={of=horizontal and lastsegment}]
    (final) -- (intersection-1)
    node [anchor=south west] {$x$}
    -- (0,0);
  • If I don't desire to actually calculate the unknown angle (x), how much of the code is necessary? I don't have much experience with pgf. – Calhistorian May 23 '13 at 22:09
  • 1
    The calculation of the angle is only one line \pgfmathsetmacro\unknownangle{\totalangle-180}. The entire second half of the code (from \begin{pgfinterruptboundingbox}) is only necessary because we don't know the length of the individual segments, so if you would precalculate that, the code could be shortened. – Jake May 23 '13 at 22:13
  • Ok. One last thing to confirm answer. Is it possible to add the degree symbol also to all the angles? I imagine this isn't that simple to do. – Calhistorian May 23 '13 at 22:25
  • 1
    @Calhistorian: Sure, just replace node ... {\angle} node ... {$\angle^\circ$}. I've edited my answer. – Jake May 23 '13 at 22:30
  • 1
    @Calhistorian: In that case, you need to decrease the inner sep of the label nodes (or set it to 0pt). I've edited my answer. – Jake May 24 '13 at 2:06

Here is an adaptation of Circular sequence diagram (tikz?) which will adapt to any number of segments based on the number of labels provided.

enter image description here



% https://tex.stackexchange.com/questions/21559/macro-to-access-a-specific-member-of-a-list/21560#21560

    % #1 = outer circle radius
    % #2 = inner circle radius
    % #3 = seqeunce
    \foreach [count = \Count] \Angle in {0,\AngleSep,..., 360} {%
            \draw [blue, ultra thick] (\LastAngle:#1) -- (\Angle:#1);
        \xdef\LastAngle{\Angle}% Save it so we can access it next iteration
        \node at (\MidPoint:\MidRadius) {\GetListMember{#3}{\Count}};
  • 2
    I thought the OP wanted the irregular polygon with the corner angles given by the labels. – Jake May 23 '13 at 20:38
  • @Jake: Good point, it is not really clear as the OP desires to not specify the points of each of the coordinates. Also, note that the labels are not in order, so even more confusing. – Peter Grill May 23 '13 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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