5

Consider the following.

Code

% lualatex filename.tex

\DocumentMetadata{}

\documentclass{article}

\usepackage{pst-eucl}

\def\maksimumB{\fpeval{2*(1+3^(1/2))*\radius} }
\def\maksimumH{\fpeval{(3+3^(1/2))*\radius} }
\def\Angle[#1]#2#3#4{\pstMarkAngle{#2}{#3}{#4}{#1$60^{\circ}$}}

\begin{document}

\def\radius{21.5 }
\psset{unit=0.07cm}
\begin{pspicture}(\maksimumB,\maksimumH)
 \pnodes{P}(0,0)%
           (\maksimumB,0)%
           (!\maksimumB 2 div \maksimumH)
 \pspolygon(P0)(P1)(P2)
 \pnodes{C}(!3 sqrt \radius mul \radius)%
           (!2 3 sqrt add \radius mul \radius)%
           (!\maksimumB 2 div 1 3 sqrt add \radius mul)
 \pscircle(C0){\radius}
 \pscircle(C1){\radius}
 \pscircle(C2){\radius}
 \multido{\iA=0+1,\iB=1+1,\r=210+120}{3}{%
   \psdot(C\iA)
   \uput[\r](C\iA){$C_{\iB}$}
 }
\psset{%
  linestyle=dotted,%
  dotsep=1.5pt,%
  LabelSep=9,%
  MarkAngleRadius=5%
}
 \Angle[\footnotesize]{P2}{P1}{P0}
 \Angle[\footnotesize]{P1}{P0}{P2}
 \Angle[\footnotesize]{P0}{P2}{P1}
\psset{%
  LabelSep=7,%
  MarkAngleRadius=3%
}
 \pspolygon(C0)(C1)(C2)
 \Angle[\scriptsize]{C1}{C0}{C2}
 \Angle[\scriptsize]{C0}{C2}{C1}
 \Angle[\scriptsize]{C2}{C1}{C0}
\end{pspicture}

\end{document}

Output

output

Question

I have the desired output but the code is somewhat messy, I think; can anyone help me simplify if?

18
  • 2
    My opinion: I'm not entirely sure how helpful this question would be to a wider audience (including many of the others posed this way). Voting to close as TL.
    – Werner
    May 7, 2013 at 6:27
  • 4
    You've asked at least a dozen of these, all with the same boilerplate commentary. At some point, people will start to doubt the sincerity of the questions (i.e do you want to learn how to improve the code yourself, or do you just want someone else to do it for you). It looks like you're getting close to that point. I'm not expressing an opinion one way or the other, just rationalizing the close votes if you're confused by them.
    – Scott H.
    May 7, 2013 at 7:47
  • 2
    No need for name calling, you mentioned that you didn't understand the close votes (none of which were me) so I gave my take on it. I'm not sure what you find ignorant about that.
    – Scott H.
    May 7, 2013 at 8:17
  • 1
    Maybe I phrased my comment poorly, I'm sorry if it offended you.
    – Scott H.
    May 7, 2013 at 8:41
  • 1
    @SvendTveskæg: To add to this discussion I've posted a question on Meta: Tagging “Please improve my code” posts. Also, a question that was just posted here has a similar flavour to yours. However, in my opinion it has a reach to a wider audience, since it references styles for chapter pages: Code improvement and suggestions in template. Users can take the code and update it to their liking. Your post is particular to a triangle with 3 balls in it and doesn't scale to something larger/more abstract.
    – Werner
    May 8, 2013 at 1:32

4 Answers 4

6

marking the angles is the same. Putting the origin in the middle of the base also simplifies the code:

\documentclass{article}
\usepackage{auto-pst-pdf,pst-eucl}

\begin{document}

\psset{unit=0.5mm}
\def\radius{21.5 }
\newlength\Radius \Radius=\radius\psunit
\begin{pspicture}(-3\Radius,0)(3\Radius,5\Radius)
\pstVerb{
  /maxB 2 dup 3 sqrt mul add \radius mul 2 div def
  /maxH 3 dup sqrt add \radius mul def }
\pnodes{P}(!maxB neg 0)(!maxB 0)(!0 maxH)
\pspolygon(P0)(P1)(P2)
\pnodes{C}(!\radius neg \radius)(\radius,\radius)(!0 1 3 sqrt add \radius mul)
\pscircle(C0){\Radius}\pscircle(C1){\Radius}\pscircle(C2){\Radius}
\pspolygon[showpoints,linestyle=dotted](C0)(C1)(C2)
\uput[225](C0){C1}\uput[-45](C1){C2}\uput[90](C2){C3}
\end{pspicture}

\end{document}

enter image description here

with the current pstricks.tex you can also calculate coordinates as P(+{algebraic},{algebraic}). The + is the identifier for the special handling:

\psset{unit=0.5mm}
\def\radius{21.5 }
\newlength\Radius \Radius=\radius\psunit
\begin{pspicture}(-3\Radius,0)(3\Radius,5\Radius)
\pnodes{P}(+{-(1+sqrt(3))*\radius},0)(+{(1+sqrt(3))*\radius},0)%
  (+{0},{(3+sqrt(3))*\radius})
\pspolygon(P0)(P1)(P2)
\pnodes{C}(!\radius neg \radius)(\radius,\radius)(!0 1 3 sqrt add \radius mul)
\pscircle(C0){\Radius}\pscircle(C1){\Radius}\pscircle(C2){\Radius}
\pspolygon[showpoints,linestyle=dotted](C0)(C1)(C2)
\uput[225](C0){C1}\uput[-45](C1){C2}\uput[90](C2){C3}
\end{pspicture}
2
  • code does not work with pdflatex. Normally auto-pst-pdf by [pdf] option works right ? I know it works with xelatex and latex->dvips->ps2pdf May 7, 2013 at 7:11
  • put the \pstVerb into the pspicture environment. I'll change my code, see above.
    – user2478
    May 7, 2013 at 7:12
7

Without TikZ.

enter image description here

\documentclass[pstricks,border=6pt]{standalone}
\SpecialCoor
\usepackage{fp}
\FPset\RR{2}% circle radius

\FPeval\XX{RR*root(2,3)}
\FPeval\RX{XX+RR}
\FPeval\Width{2*RX}
\FPeval\Height{RX*root(2,3)}

\def\Atom#1{%
    \pscircle(\XX,\RR){\RR}
    \psline(\RX;60)(0,0)(\RX,0)
    \bgroup
    \psset{linestyle=dashed}
    \psarc(0,0){15pt}{0}{60}
    \rput{*0}(25pt;30){$60^\circ$}
    \rput(\XX,\RR){%    
        \psline(\RR;60)(0,0)(\RR,0)
        \psarc(0,0){15pt}{0}{60}
        \qdisk(0,0){3pt}
        \rput{*0}(12pt;-150){$C_#1$}
        \rput{*0}(25pt;30){$60^\circ$}}
    \egroup
    \ignorespaces
}

\begin{document}
\begin{pspicture}(\Width,\Height)
    \Atom{1}
    \rput{120}(\Width,0){\Atom{2}}
    \rput{-120}(\RX,\Height){\Atom{3}}
\end{pspicture}
\end{document}

How it works:

enter image description here

\documentclass{beamer}

\usepackage{pstricks}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{pspicture}
\PreviewBorder=12pt\relax

\SpecialCoor
\usepackage{fp}
\FPset\RR{2}% circle radius

\FPeval\XX{RR*root(2,3)}
\FPeval\RX{XX+RR}
\FPeval\Width{2*RX}
\FPeval\Height{RX*root(2,3)}

\def\Atom#1{%
    \pscircle(\XX,\RR){\RR}\pause
    \psline(\RX;60)(0,0)(\RX,0)\pause
    \bgroup
    \psset{linestyle=dashed}
    \psarc(0,0){15pt}{0}{60}
    \rput{*0}(25pt;30){$60^\circ$}\pause
    \rput(\XX,\RR){%    
        \psline(\RR;60)(0,0)(\RR,0)\pause
        \psarc(0,0){15pt}{0}{60}\pause
        \qdisk(0,0){3pt}
        \rput{*0}(12pt;-150){$C_#1$}
        \rput{*0}(25pt;30){$60^\circ$}\pause}
    \egroup
    \ignorespaces
}

\begin{document}
\begin{frame}
\begin{pspicture}(\Width,\Height)
    \Atom{1}
    \rput{120}(\Width,0){\Atom{2}}
    \rput{-120}(\RX,\Height){\Atom{3}}
\end{pspicture}
\end{frame}
\end{document}
4
  • The 19th frame is identical to the 18th one. But I am too lazy to remove the 19th one. :-) May 7, 2013 at 8:44
  • 1
    This is a really elegant solution! I'll use this one instead of Herbert's, I think. May 7, 2013 at 9:26
  • Hmm. It is as if the circles are not touching each other; there seems to be a tiny gab, but I'm not sure. May 7, 2013 at 11:01
  • @SvendTveskæg: You can change the dimen from outer (default) to middle for \pscircle. May 7, 2013 at 11:02
2

Just for fun with TikZ and the angles library from the CVS version.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{angles}
\begin{document}
\begin{tikzpicture}[x=7cm, y=7cm, thick, line join=round,
  dots/.style={dash pattern=on 1\pgflinewidth off 2\pgflinewidth},
  dot/.style={circle,fill,draw,inner sep=+0pt, minimum size=+2pt}]
\pgfmathsetmacro\r{.5/(1+1/tan 30)}
\pgfmathsetmacro\vB{2*\r}
\draw (0,0) coordinate (n-0) -- ++ (0:1) coordinate (n-1)
                             -- ++ (120:1) coordinate (n-2) -- cycle;
\foreach \a/\b/\c[count=\cnt from 0] in {1/\vB/\vB, \vB/1/\vB, \vB/\vB/1}
  \draw (barycentric cs:n-0=\a,n-1=\b,n-2=\c) node[dot] (C-\cnt) {}
        node[anchor=30+120*\cnt] {$C_{\pgfmathprint{int(\cnt+1)}}$} circle [radius=\r];
\draw[dots] (C-0) -- (C-1) -- (C-2) -- (C-0);
\foreach \cnt[evaluate={\pCnt=int(Mod(\cnt-1,3)); \nCnt=int(Mod(\cnt+1,3));}] in {0,...,2}
  \path[nodes={draw, dots, angle radius=+10pt, angle eccentricity=1.8,
               pic text=$\scriptstyle60^\circ$, pic text options={draw=none}}]
   pic {angle=C-\nCnt--C-\cnt--C-\pCnt} pic {angle=n-\nCnt--n-\cnt--n-\pCnt};
\end{tikzpicture}
\end{document}

Output

enter image description here

2

With tkz-euclide and no calculation (compass and ruler)

 \documentclass[a4paper]{scrartcl}
 \usepackage[usenames,dvipsnames,svgnames]{xcolor}
 \usepackage{tkz-euclide}
 \usetkzobj{all}     
 \definecolor{fondpaille}{cmyk}{0,0,0.1,0}   
 \tkzSetUpColors[background=fondpaille,text=Maroon]  

 \begin{document}
 \begin{tikzpicture}
  \tkzDefPoint(0,0){A}
  \tkzDefPoint(8,0){B}
  \tkzDefEquilateral(A,B)\tkzGetPoint{C}
   %first circle
  \tkzDefPointBy[projection= onto A--B](C)  \tkzGetPoint{Hc}
  \tkzDefLine[bisector](B,A,C) \tkzGetPoint{a}
  \tkzDefLine[bisector](A,Hc,C) \tkzGetPoint{hc}
  \tkzInterLL(A,a)(Hc,hc) \tkzGetPoint{Oa}
  \tkzDefPointBy[projection= onto A--B](Oa)  \tkzGetPoint{I}
   %second circle
  \tkzDefLine[bisector](C,B,A) \tkzGetPoint{b}
  \tkzDefLine[bisector](B,Hc,C) \tkzGetPoint{ha}
  \tkzInterLL(B,b)(Hc,ha) \tkzGetPoint{Ob}
  \tkzDefPointBy[projection= onto A--B](Ob)  \tkzGetPoint{J} 
   %third circle
  \tkzDefPointBy[projection= onto A--C](B)  \tkzGetPoint{Hb}
  \tkzDefLine[bisector](C,Hb,B) \tkzGetPoint{hb}
  \tkzInterLL(C,Hc)(Hb,hb) \tkzGetPoint{Oc}
  \tkzDefPointBy[projection= onto C--B](Oc)  \tkzGetPoint{K}
   %drawing
  \tkzDefMidPoint(C,B) \tkzGetPoint{E}  
  \tkzDrawPolygon[color=Maroon](A,B,C)
  \tkzDrawPolygon[color=Maroon,dashed](Oa,Ob,Oc)
  \tkzDrawCircle(Oa,I)    
  \tkzDrawCircle(Ob,J)   
  \tkzDrawCircle(Oc,K)
  \tkzDrawPoints(Oa,Ob,Oc,A,B,C)
   %labels
  \tkzLabelPoints[left](Oa,A)
  \tkzLabelPoints[right](Ob,B)
  \tkzLabelPoints[above](Oc,C)  \end{tikzpicture}                                                                   
 \end{document}

enter image description here

You must log in to answer this question.

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