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.

In my thesis I'm doing a drawing with TikZ, but I get an error that I do not understand. Consider this code (simplified from the original, but still quite significant):

\documentclass[border=.5cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc,hobby}

\begin{document}

\begin{tikzpicture}[use Hobby shortcut]
% definitions and macros
\def\pSpess{.5}
\def\pL{2.5}
\def\pAng{55}
\def\pRaggio{4}
\pgfmathsetmacro{\pRaggioMin}{\pRaggio-\pSpess}

% coordinates

% above
\draw (-5,.7) arc (235:270:\pRaggio cm) -- ++(\pL,0) -- ++(0,\pSpess) -- ++(-\pL,0) arc (270:180+\pAng:\pRaggioMin cm) -- (-5,.7) node (a) [pos=.5] {} -- cycle;
    \coordinate (cmu) at ($(a)+(90+\pAng:.15)$); %centro momento
    \coordinate (imu) at ($(cmu)+(180+\pAng:.5)$); %inizio momento
    \coordinate (ccmu) at ($(cmu)+(90+\pAng:.25)$); %punto intermedio momento
    \coordinate (fmu) at ($(cmu)+(\pAng:.5)$); %fine momento
\draw [->] (imu) .. (ccmu) .. (fmu);

% bottom
\draw (-5,-.7) arc (125:90:\pRaggio cm);
\end{tikzpicture}


\end{document}

As you can see the design is not correct (there is a clear intersection that should not be there). However I do not understand what's wrong. Can anyone help me?

enter image description here

share|improve this question
1  
If I understand correctly, the example can be minimised to \begin{tikzpicture} \draw (-5,.7) arc (235:270:4cm); \draw (-5,-.7) arc (125:90:4cm); \end{tikzpicture}, right? –  Jake Jul 17 '13 at 17:47
    
Thanks @SeanAllred! –  Marco87 Jul 17 '13 at 19:27
    
@Marco87 My pleasure :) –  Sean Allred Jul 17 '13 at 19:30
add comment

1 Answer 1

up vote 7 down vote accepted

The problem is due to the y-coordinates you use for the starting points of your arcs: They shouldn't be 0.7 and -0.7, but 0.723391823 and -0.723391823 (which is 1-cos(35 degrees))*4cm).


\documentclass[border=.5cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc,hobby}

\begin{document}

\begin{tikzpicture}[use Hobby shortcut]
% definitions and macros
\def\pSpess{.5}
\def\pL{2.5}
\def\pAng{55}
\def\pRaggio{4}
\pgfmathsetmacro{\pRaggioMin}{\pRaggio-\pSpess}

% coordinates

% above
\draw (-5,{1-cos(35))*\pRaggio cm}) arc (235:270:\pRaggio cm) -- ++(\pL,0) -- ++(0,\pSpess) -- ++(-\pL,0) arc (270:180+\pAng:\pRaggioMin cm) -- (-5,.7) node (a) [pos=.5] {} -- cycle;
    \coordinate (cmu) at ($(a)+(90+\pAng:.15)$); %centro momento
    \coordinate (imu) at ($(cmu)+(180+\pAng:.5)$); %inizio momento
    \coordinate (ccmu) at ($(cmu)+(90+\pAng:.25)$); %punto intermedio momento
    \coordinate (fmu) at ($(cmu)+(\pAng:.5)$); %fine momento
\draw [->] (imu) .. (ccmu) .. (fmu);

% bottom
\draw (-5,{1-cos(35))*-\pRaggio cm}) arc (125:90:\pRaggio cm);
\end{tikzpicture}


\end{document}

enter image description here

share|improve this answer
    
Thank you, @Jake, very much! –  Marco87 Jul 17 '13 at 19:28
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.