繪製與角度相關的弧的問題

繪製與角度相關的弧的問題

我需要繪製弧來表示等邊三角形內的角度。為此,我在 calc 套件的幫助下使用 tikz 中的 arc 函數。但是,如果我使用自動解決方案來計算頂點之間的差異向量的度數,則會得到不需要的結果(以下範例程式碼中的黑色弧線)。

\begin{tikzpicture}[scale=8]
\coordinate (center) at (0, 0);
\coordinate (A) at (-0.5, 0);
\coordinate (B) at (0.5, 0);
\coordinate (C) at (0, {sqrt(3)/2});
\draw (A) -- (B) -- (C) -- cycle;
\coordinate (C1) at ($(C)!0.1!(A)$);
\coordinate (C2) at ($(C)!0.1!(B)$);
\draw
   let \p1 = ($(C1) - (C)$),
   \p2 = ($(C2) - (C)$),
   \n0 = {veclen(\x1,\y1)},            
   \n1 = {atan2(\x1, \y1)},  
   \n2 = {atan2(\x2, \y2)}   
 in (C) arc(\n1:\n2:\n0);
\path
    let     \p1 = ($(C1) - (C)$),
\p2 = ($(C2) - (C)$),
\n0 = {veclen(\x1, \y1)},
\n1 = {atan2(\x1, \y1)},
\n2 = {atan2(\x2, \y2)}
in node at  (C) {$\n1,\, \n2$};
\draw[red] (C1) arc(240:300:0.1);
\end{tikzpicture}

如果我顯示初始角度和最終角度的值,它們會以 pt 形式出現,轉換後的值類似於 +60° 和 -60°。這些價值觀顯然是錯誤的。反之亦然,如果我手動設定正確的角度,那麼弧度就很好。儘管如此,我需要透過“自動”解決方案,因為我無法手動計算更複雜圖形的初始角度和最終角度。誰能告訴我如何解決這個問題?另外,有沒有辦法以度數而不是點數顯示初始角度和最終角度?非常感謝!

答案1

也許你只是想要這個?

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=8]
  \draw (-0.5,0) coordinate (A) -- (0.5,0) coordinate (B) -- (0,{sqrt(3)/2}) coordinate (C) -- cycle ($(C)!0.1!(A)$) coordinate (C1) ($(C)!0.1!(B)$) coordinate (C2);
  \draw
  let \p1 = ($(C1) - (C)$),
  \p2 = ($(C2) - (C)$),
  \n0 = {veclen(\x1,\y1)},
  \n1 = {atan2(\y1,\x1)},
  \n2 = {atan2(\y2,\x2)}
  in (C1) arc(\n1:\n2:\n0);
\end{tikzpicture}
\end{document}

角度

請注意,atan2將位元y作為其第一個參數 - 而不是x- 並且 應該從and notarc開始。(C1)(C)

答案2

不知道為什麼您決定應用如此大的比例,而不是僅僅使用更大的測量值。儘管這意味著加載額外的包,但這裡有一個tkz-euclide.

輸出

在此輸入影像描述

程式碼

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\begin{tikzpicture}
\tkzDefPoint(-4,0){A}
\tkzDefPoint(4,0){B}

\tkzDefTriangle[equilateral](A,B)
\tkzGetPoint{C}

\tkzDrawPolygon(A,B,C)

\tkzMarkAngle[size=1cm](A,C,B)
\end{tikzpicture}
\end{document}

相關內容