Tkz-Euclide 描画なしで高度ポイントを取得

Tkz-Euclide 描画なしで高度ポイントを取得

描画せずに座標のみを取得することは可能ですか?(または、 を使用せずに他のショートカットはありますかtkz-euclide

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
    \coordinate (A) at (0,0);
    \coordinate (B) at (4,4);
    \coordinate (C) at (4,2);

    \draw(A)--(B);
    \tkzDrawAltitude[color=blue](A,B)(C) \tkzGetPoint{D}

    \fill[red] (A) circle (2pt);
    \fill[red] (B) circle (2pt);
    \fill[red] (C) circle (2pt);
    \fill[blue] (D) circle (2pt);

\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

答え1

はい、calcこれらの投影法があります。構文については、セクション13.5.5 射影修飾子の構文pgfmanual の。

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
    \coordinate (A) at (0,0);
    \coordinate (B) at (4,4);
    \coordinate (C) at (4,2);

    \draw(A)--(B);
    \draw[blue] ($(A)!(C)!(B)$) coordinate (D) -- (C);

    \fill[red] (A) circle (2pt);
    \fill[red] (B) circle (2pt);
    \fill[red] (C) circle (2pt);
    \fill[blue] (D) circle (2pt);

\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

答え2

tkz-euclide の場合、正しいコードは次のとおりです。

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
    \tkzDefPoint(0,0){A}
    \tkzDefPoint(4,4){B}
    \tkzDefPoint(4,2){C}
    \tkzDrawSegment(A,B)
    \tkzDefPointsBy[projection=onto A--B](C){D}.
    \tkzDrawPoints[color=red](A,B,C)
    \tkzDrawPoints[color=blue](D)
        \tkzLabelPoints(A,B,C,D)
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

答え3

代替案マーモットの素晴らしい回答です。\pgfmathanglebetweenpointsこのコマンドは線の角度を与えます。このコマンドとintersectionsライブラリを使用すると、描画せずに座標を取得できます。

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc,intersections}
\newcommand{\pgfextractangle}[3]{%
    \pgfmathanglebetweenpoints{\pgfpointanchor{#2}{center}}
                              {\pgfpointanchor{#3}{center}}
    \global\let#1\pgfmathresult  
}
\begin{document}
\begin{tikzpicture}
    \coordinate (A) at (0,0);
    \coordinate (B) at (4,4);
    \coordinate (C) at (4,2);
    \path[draw, name path=line1](A)--(B);
    \pgfextractangle{\angle}{A}{B}
    \fill[red] (A) circle (2pt);
    \fill[red] (B) circle (2pt);
    \fill[red] (C) circle (2pt);
    \path [name path=line2] (C)--++(\angle+90:3); % Add 90 degree to calculated angle for orthogonality.
    \path[name intersections={of=line1 and line2,by={D}}];
    \fill[blue] (D) circle (2pt);
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

関連情報