TikZ 사진에 치수 추가하기

TikZ 사진에 치수 추가하기

TikZ 사진에 치수 레이블을 어떻게 추가합니까? 이상적으로는 다음과 같습니다.

|<----- dimension ----->|

직선(예: 다각형의 측면)과 곡선(예: 원의 원주/호 길이)의 측정을 표시하고 싶습니다. 도움을 주셔서 미리 감사드립니다!

답변1

교육 및 과시 목적으로만 사용하세요!

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}

\tikzset{measure length/.style={
              decoration={markings,
              mark connection node=a,
              mark =at position 0.5 with {
                 \node[transform shape,fill=white,scale=0.5,#1] (a) 
                        {\pgfmathparse{\pgfdecoratedpathlength/2.845274}%
                        \pgfmathprintnumber[fixed,precision=1]\pgfmathresult mm};},
             },
             postaction=decorate
       }
}
\begin{document}

\begin{tikzpicture}
\draw[measure length] (-2,-2cm) -- (2cm,-2cm);
\draw[measure length={rotate=180}] (0,0) arc (0:270:1cm) ;
\draw[measure length={rotate=180}] (0,3) arc (0:270:1cm) -- ++(10mm,0);

\foreach \x in {0,...,5}{
\draw[measure length] (2,2) +(\x*60:1cm) -- +({(\x+1)*60)}:1cm);
}

\end{tikzpicture}

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보