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.
\documentclass[pstricks,border=12pt]{standalone}

\psset{unit=.25}
\def\Atom#1{%
\begin{pspicture}[dimen=m](-12,-12)(12,12)
    \pstVerb{/AA 1 5 atan def /RR 26 sqrt def}
    \pscustom[fillstyle=eofill,fillcolor=red,linearc=#1]
    {
            \pscircle{3}
            \moveto(5,-1)
            \psLoop{6}
            {
                    \translate(5,0)
                    \psline(0,-1)(4,-1)(4,1)(0,1)
                    \translate(-5,0)
                    \psarc(0,0){!RR}{!AA}{!60 AA sub}
                    \rotate{60}
            }
            \closepath
    }
\end{pspicture}}

\begin{document}
\Atom{.5}
\Atom{0}
\end{document}

What causes the strange output for nonzero linearc below?

Output for linearc=.5

enter image description here

Output for linearc=0

enter image description here

Edit

According to Werner's comment, it is related to precision issue. Is there a smart solution to solve it?

share|improve this question
    
My guess is this has to do with the precision of 1 5 atan... –  Werner Mar 6 at 6:00
    
@Werner Yes, you are right. Using /AA 1 1e-6 add 5 atan def eliminates this last, big arc, but others become more visible. –  Christoph Mar 6 at 22:26
2  
Can a bounty of 1 million make this problem solved? –  Oh my ghost Apr 22 at 21:02
    
Maybe. Wouldn't it be my part then? :) –  Christoph Apr 23 at 9:35
    
I do not dare to take this kind of commitment. :-) –  Oh my ghost Apr 23 at 13:40

2 Answers 2

up vote 9 down vote accepted
+100

If the current path have a point (\moveto, previous \psarc), then \psline also draw a line from the current point to its first coordinate. In theory both points are identical. However these points are calculated completely different, the end point of \psarc and the first point of \psline rotated by \rotate{60}. Therefore rounding errors cannot be avoided in practice. The result is a very tiny line, much smaller than the arc that linearc wants to draw.

Solution: Just drop the redundant point, the first point of \psline:

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

\psset{unit=.25}
\def\Atom#1{%
\begin{pspicture}[dimen=m](-12,-12)(12,12)
    \pstVerb{/AA 1 5 atan def /RR 26 sqrt def}
    \pscustom[fillstyle=eofill,fillcolor=red,linearc=#1]
    {
            \pscircle{3}
            \moveto(5,-1)
            \psLoop{6}
            {
                    \translate(5,0)
                    \psline(4,-1)(4,1)(0,1)
                    \translate(-5,0)
                    \psarc(0,0){!RR}{!AA}{!60 AA sub}
                    \rotate{60}
            }
            \closepath
    }
\end{pspicture}}

\begin{document}
\Atom{.5}
\end{document}

Result

share|improve this answer

Drawing without atan, just a sin and even without trigonometry for small angles up to 12° (24 infact) without difference, example with 15° and a little gap. Drawing is done in one path.

  1. in pale red the exact solution;
  2. in blue the without trigo.

For 10° :

enter image description here

zoom :

enter image description here

For 15° (small gap) :

enter image description here

\documentclass[tikz,margin=2pt]{standalone}
\usetikzlibrary{calc}
\begin{document}

\def\Rex{5}
\def\Rin{3}
\def\Theeth{2}
\def\Angle{10}
\def\R{.3}
\pgfmathsetmacro\Lt{2*sin(\Angle)*\Rex}
\pgfmathsetmacro\L{2*\Rex*\Angle*3.14159/180}

\begin{tikzpicture}

%\clip (-5,2) rectangle (0,7) ;

% exact solution
% with trigonometry but whithout atan, just a sin
% in red

\fill[fill=red!25,,even odd rule]  (-\Angle:\Rex)
\foreach \i in {0,60,...,300} {
    --(-\Angle+\i:\Rex)
    --++(\i:\Theeth-\R) arc (-90+\i:0+\i:\R)
    --++(90+\i:\Lt-2*\R) arc (0+\i:90+\i:\R)
    --(\Angle+\i:\Rex) arc (\Angle+\i:60-\Angle+\i:\Rex)
} -- cycle (0,0) circle (\Rin);

% approximative solution without trigonometry
% if x is small sin(x) ~ x in radian

\draw[blue] (0,0) circle (\Rin) (-\Angle:\Rex)
\foreach \i in {0,60,...,300} {
    --(-\Angle+\i:\Rex)
    --++(\i:\Theeth-\R) arc (-90+\i:0+\i:\R)
    --++(90+\i:\L-2*\R) arc (0+\i:90+\i:\R)
    --(\Angle+\i:\Rex) arc (\Angle+\i:60-\Angle+\i:\Rex)
} -- cycle ;

\end{tikzpicture}
\end{document}
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.