tikzで、intersections を使って線の交点を求めた座標を知りたいので、表示したいです。
どのようにしたら交点の座標を表示できますか?
よろしくお願いします。
パッと思いつく方法は次のようなものです。
\tikzmath を使う
後者のほうが応用範囲が広いので、こちらの例を示します。
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{intersections,math}
\begin{document}
\begin{tikzpicture}[x=1pt,y=1pt]
\draw[name path=Circle] (0,0) circle[radius=60];
\draw[name path=Line] (0,0)--(60,60);
\path[name intersections={of=Circle and Line, by={A}}];
% 所望の点に「A」という名前が付いている
\tikzmath{
coordinate \c; \c{A} = (A);
% \cx{A} が「42.45473pt」に, \cy{A} が「42.42291pt」に
% 展開されるようになる.
}
\typeout{(\cx{A}, \cy{A})}% 端末に表示
\fill (A) circle[radius=2pt]
% ノードのラベルに入れる
node[right=6pt] {(\cx{A}, \cy{A})};
\end{tikzpicture}
\end{document}
\cx{A}、\cy{A} を pgfmath の計算式で使うこともできます。しかし、「tikzpicture 環境の外に持っていきたい」という場合はチョットした TeX 言語が要りそうです。
飯島さんの例と同様に「TikZのxyz座標系での座標値に換算する」例を挙げておきます。
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{intersections,math}
\begin{document}
\begin{tikzpicture}% x, y は任意
\draw[name path=Circle] (0,0) circle[radius=2];
\draw[name path=Line] (0,0)--(2,2);
\path[name intersections={of=Circle and Line, by={A}}];
\tikzmath{
% \c{...} はcanvas座標系での値が入っている
coordinate \c; \c{A} = (A); \c{U} = (1,1);
% 型宣言のない変数(\xA,\yA)はreal型
\xA = \cx{A}/\cx{U}; \yA = \cy{A}/\cy{U};
}
\typeout{(\xA, \yA)}%==>(1.41515, 1.4141)
\end{tikzpicture}
\end{document}