如何在 Tikz 中繪製域的直徑?

如何在 Tikz 中繪製域的直徑?

我正在寫一篇關於基本集合論的簡短文檔,並希望包含一些圖像。我無法為自己畫出的第一個定義是直徑

直徑非空集合的An維歐幾里德空間是任意一對點之間相距最大的距離A; |A|=sup(|X-y| :XyA)。

我想Tikz為我畫的是這樣的:

在此輸入影像描述

其中的形狀A是一個“隨機”斑點。和Xy自動計算、標記和連接。然後|A|在下面繪製並標記(再次自動)。

有人知道該怎麼做嗎?提前致謝。

答案1

一個殘酷的想法:以下裝飾將標誌著給定路徑上的九十個里程碑。

\documentclass[border=9,tikz]{standalone}
\usetikzlibrary{calc,decorations}

\pgfdeclaredecoration{mark milestone}{initial}{
    \state{initial}[width=0pt,next state=mark]{
        \xdef\markmilestoneindex{0}
        \xdef\markmilestonename{\csname tikz@fig@name\endcsname}
        \pgfmathsetmacro\markmilestonesep{\pgfdecoratedpathlength/90}
        \xdef\markmilestonesep{\markmilestonesep}
    }
    \state{mark}[width=\markmilestonesep pt]{
        \coordinate(\markmilestonename-\markmilestoneindex);
        \pgfmathtruncatemacro\markmilestoneindex{\markmilestoneindex+1}
        \xdef\markmilestoneindex{\markmilestoneindex}
    }
    \state{final}{
        \pgftransformshift{\pgfpointdecoratedpathlast}
        \coordinate(\markmilestonename-\markmilestoneindex);
    }
}

\begin{document}
    \begin{tikzpicture}
        \draw[rounded corners,
              postaction={name=irreshape,decorate,decoration=mark milestone}]
            (0:2)foreach\i in{1,...,11}{--(\i*30:3+rnd)}--cycle
            [sharp corners]; %https://tex.stackexchange.com/questions/38989/
        \draw foreach\i[evaluate={\a=\i*4-180};]in{0,...,90}{
            (irreshape-\i)circle(.4pt)node[anchor=\a]{\tiny\i}
        };
    \end{tikzpicture}
\end{document}

現在你可以計算這些點組成的四千零五段的長度,看看誰最長。

相關內容