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 attempting to generate the following diagram:

enter image description here

I am finding it difficult to place all of the triangles surrounding the center circle in the manner shown. Currently I can place four of the 8 triangles by specifying left, right and so on but I don't know how to place the triangles that are slanted. How would I go about completing this diagram?

share|improve this question
8  
Could you edit your question to include the code you already have? That makes it easier for others to come up with a solution (setting up the framework is not that much fun). –  Jake Feb 17 '13 at 17:03
    
You can either rotate around the midpoint of the circle, calculate the path of the rotated triangles by hand or even use the isosceles triangle shape. –  Qrrbrbirlbel Feb 17 '13 at 17:11
add comment

2 Answers 2

up vote 29 down vote accepted

Here's something in tikz which is similar to what you want.

\documentclass{article}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[x=0.5cm,y=0.5cm]
    \draw (5,0)
        arc (0:360:5);
    \foreach \angle in { 0,45,...,360 }{
        \draw [rotate around={\angle:(0,0)}]
            (5.5,0)    
            -- +(0,-1.5)
            -- +(3,0)
            -- +(0,1.5)
            -- cycle;
       }

\end{tikzpicture}
\end{document}

enter image description here

Taking @Qrrbrbirlbel's comment into account and adding color and thickening the lines, you could write:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[x=0.5cm,y=0.5cm,line width=4pt,draw=yellow]
\draw (1,0) node[draw,circle,minimum size=5cm] (TheSun) {};
    \foreach \angle in { 0,45,...,359  }
    {
        \draw [rotate around={\angle:(TheSun.center)}]
            ($(TheSun.center) + (5.5,0)$)
                   -- +(0,-1.5)
                   -- +(3,0)
                   -- +(0,1.5)
                   -- cycle;
     }

\end{tikzpicture}
\end{document}

To give you:

enter image description here

The benefit of this last approach is you can easily change the location of the sun by rewriting

\draw (1,0)

to any value you want, say

\draw (3,-4)

and everything else will follow. Though, if the sun is the only thing you're drawing, this feature will have no apparent effect.

Styles

You can modify the style of the parts of the sun and tikz has a very nice interface to allow you to do this such as naming your style in meaningful manner. In this example, I create two styles: one for the flames and one for the body of the sun.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{shapes.geometric}
\tikzset{
    sunflames/.style={
        line width=1pt,
        draw=red,
        fill=yellow,
        regular polygon, 
        regular polygon sides=3,
        inner sep=0.35cm
    },
    sunbody/.style={
        line width=2pt,
        draw=red,
        fill=yellow,
        circle,
        minimum size=5cm
    }
 }
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[x=0.5cm,y=0.5cm]
\draw (1,0) node[sunbody] (TheSun) {};
    \foreach \angle in { 0,45,...,359  }
    {
        \draw [rotate around={\angle:(TheSun.center)}]
            ($(TheSun.center) + (7,0)$)
            node[shape border rotate=\angle-90,sunflames] {};
     }

\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
2  
The circle path is probably easier: \draw (0,0) circle[radius=5]; It may be even more maintainable if you use a circle node (\node[draw,circle,minimum size=5cm] (c) {};) and then use c.center as the point to rotate around. Also, you have two triangles at the angle of 0/360. –  Qrrbrbirlbel Feb 17 '13 at 17:43
    
@Qrrbrbirlbel. Thank you! Very good points. –  A.Ellett Feb 17 '13 at 17:46
add comment

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}
\SpecialCoor
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \pscircle(0,0){2}
    \multido{\i=0+45}{8}{\uput{5pt}[\i]{\i}(2;\i){\pspolygon(0,0.5)(0,-0.5)(1,0)}}
\end{pspicture}
\end{document}

If you don't like \uput, use \rput as follows,

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}
\SpecialCoor
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \pscircle(0,0){2}
    \multido{\i=0+45}{8}{\rput{\i}(!2 5 72.27 div 2.54 mul add \i\space PtoC){\pspolygon(0,0.5)(0,-0.5)(1,0)}}
\end{pspicture}
\end{document}

If you don't like \pspolygon, use \pstriangle as follows,

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}
\SpecialCoor
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \pscircle(0,0){2}
    \multido{\i=90+45}{8}{\rput{!\i\space 90 sub}(!2 5 72.27 div 2.54 mul add \i\space PtoC){\pstriangle[dimen=middle](0,0)(1,1)}}
\end{pspicture}
\end{document}

If you only like \pstriangle and \uput, use them as follows,

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}
\SpecialCoor
\begin{document}
\begin{pspicture}(-3,-3)(3,3)
    \pscircle(0,0){2}
    \multido{\i=90+45}{8}{\uput{5pt}[\i]{!\i\space 90 sub}(2;\i){\pstriangle[dimen=middle](0,0)(1,1)}}
\end{pspicture}
\end{document}

Note that \pstriangle sets dimen=outer (changable) by default while \pspolygon sets dimen=middle (unchangable). Unfortunately, you cannot change dimen for \pspolygon so I change \pstriangle's dimen to middle to be the same as the \pspolygon's dimen.

You can prove that all my variants above produce the same output by compiling the following and view them alternately.

\documentclass[pstricks,border=12pt,multi]{standalone}
\usepackage{multido}

\SpecialCoor
\psset{dimen=middle}

\begin{document}

\begin{pspicture}(-3,-3)(3,3)
    \pscircle(0,0){2}
    \multido{\i=0+45}{8}{\uput{5pt}[\i]{\i}(2;\i){\pspolygon(0,0.5)(0,-0.5)(1,0)}}
\end{pspicture}

\begin{pspicture}(-3,-3)(3,3)
    \pscircle(0,0){2}
    \multido{\i=90+45}{8}{\uput{5pt}[\i]{!\i\space 90 sub}(2;\i){\pstriangle(0,0)(1,1)}}
\end{pspicture}

\begin{pspicture}(-3,-3)(3,3)
    \pscircle(0,0){2}
    \multido{\i=0+45}{8}{\rput{\i}(!2 5 72.27 div 2.54 mul add \i\space PtoC){\pspolygon(0,0.5)(0,-0.5)(1,0)}}
\end{pspicture}

\begin{pspicture}(-3,-3)(3,3)
    \pscircle(0,0){2}
    \multido{\i=90+45}{8}{\rput{!\i\space 90 sub}(!2 5 72.27 div 2.54 mul add \i\space PtoC){\pstriangle(0,0)(1,1)}}
\end{pspicture}

\end{document}

Animated version:

enter image description here

\documentclass[pstricks,border=15pt,multi]{standalone}
\usepackage{multido}

\SpecialCoor
\psset{linecolor=orange}

\begin{document}

\multido{\n=0.0+0.1}{6}{%
\begin{pspicture}(-3,-3)(3,3)
    \pscircle*(0,0){1}
    \multido{\i=0+45}{8}{\uput{5pt}[\i]{\i}(!1 \n\space 1.5 mul add \i\space PtoC){\pspolygon*(!0 0.25 \n\space add)(!0 -0.25 \n\space sub)(!0.5 \n\space2 mul add 0)}}
\end{pspicture}}

\end{document}
share|improve this answer
add comment

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.