在我的论文中,我正在使用 进行绘图TikZ
,但我收到一个我无法理解的错误。请考虑此代码(从原始代码简化,但仍然非常重要):
\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}
如您所见,设计不正确(有一个明显的交叉点,但不应该存在)。但是我不明白哪里出了问题。有人能帮我吗?
答案1
问题在于您用于弧的起点的 y 坐标:它们不应该是0.7
和-0.7
,而是0.723391823
和-0.723391823
(即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}