我有一个三角形的代码,并且已经找到了可以内切于该三角形的圆心。我想在不使用三角形内切圆半径公式的情况下绘制内切圆。我该如何TikZ
计算这个半径并绘制圆?
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{tikzpicture}
\path (0,1) coordinate (A) (3.5,1.5) coordinate (B) (-1.5,-0.75) coordinate (C);
\draw (A) -- (B) -- (C) -- cycle;
%The angle bisector at A is drawn.
\coordinate (a_path_for_angle_bisector_at_A) at ($(A)!2cm!(B)$);
\coordinate (another_path_for_angle_bisector_at_A) at ($(A)!2cm!(C)$);
\coordinate (midpoint_on_line_segment_to_locate_angle_bisector_at_A) at ($(a_path_for_angle_bisector_at_A)!0.5!(another_path_for_angle_bisector_at_A)$);
\path[name path=a_path_to_locate_center_of_circle] (A) -- ($(A)!1cm!(midpoint_on_line_segment_to_locate_angle_bisector_at_A)$);
%The angle bisector at C is drawn.
\coordinate (a_path_for_angle_bisector_at_C) at ($(C)!2cm!(A)$);
\coordinate (another_path_for_angle_bisector_at_C) at ($(C)!2cm!(B)$);
\coordinate (midpoint_on_line_segment_to_locate_angle_bisector_at_C) at ($(a_path_for_angle_bisector_at_C)!0.5!(another_path_for_angle_bisector_at_C)$);
\path[name path=another_path_to_locate_center_of_circle] (C) -- ($(C)!3cm!(midpoint_on_line_segment_to_locate_angle_bisector_at_C)$);
%The center of the circle inscribed in the triangle is located.
\coordinate[name intersections={of=a_path_to_locate_center_of_circle and another_path_to_locate_center_of_circle, by={O}}];
\draw[fill] (O) circle (1.5pt);
\end{tikzpicture}
\end{document}
答案1
您可以使用
\draw
let
\p1=( $ ( $ (A)!(O)!(B) $ )-(O) $ )
in
(O) circle ({veclen(\x1,\y1)});
(半径是从 到其中一条边O
的投影的线段的长度)。O
完整代码:
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\begin{document}
\begin{tikzpicture}
\path (0,1) coordinate (A) (3.5,1.5) coordinate (B) (-1.5,-0.75) coordinate (C);
\draw (A) -- (B) -- (C) -- cycle;
%The angle bisector at A is drawn.
\coordinate (a_path_for_angle_bisector_at_A) at ($(A)!2cm!(B)$);
\coordinate (another_path_for_angle_bisector_at_A) at ($(A)!2cm!(C)$);
\coordinate (midpoint_on_line_segment_to_locate_angle_bisector_at_A) at ($(a_path_for_angle_bisector_at_A)!0.5!(another_path_for_angle_bisector_at_A)$);
\path[name path=a_path_to_locate_center_of_circle] (A) -- ($(A)!1cm!(midpoint_on_line_segment_to_locate_angle_bisector_at_A)$);
%The angle bisector at C is drawn.
\coordinate (a_path_for_angle_bisector_at_C) at ($(C)!2cm!(A)$);
\coordinate (another_path_for_angle_bisector_at_C) at ($(C)!2cm!(B)$);
\coordinate (midpoint_on_line_segment_to_locate_angle_bisector_at_C) at ($(a_path_for_angle_bisector_at_C)!0.5!(another_path_for_angle_bisector_at_C)$);
\path[name path=another_path_to_locate_center_of_circle] (C) -- ($(C)!3cm!(midpoint_on_line_segment_to_locate_angle_bisector_at_C)$);
%The center of the circle inscribed in the triangle is located.
\coordinate[name intersections={of=a_path_to_locate_center_of_circle and another_path_to_locate_center_of_circle, by={O}}];
\draw[fill] (O) circle (1.5pt);
\draw
let
\p1=( $ ( $ (A)!(O)!(B) $ )-(O) $ )
in
(O) circle ({veclen(\x1,\y1)});
\end{tikzpicture}
\end{document}
答案2
这是一个tkz-euclide
变体。
\documentclass{amsart}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
\tkzDefPoint(0,1){A}
\tkzDefPoint(3.5,1.5){B}
\tkzDefPoint(-1.5,-0.75){C}
\tkzDrawPolygon(A,B,C)
\tkzDefCircle[in](A,B,C)
\tkzGetPoint{O} \tkzGetLength{rIN}
\tkzDrawPoints(A,B,C,O)
\tkzDrawCircle[R,color=red](O,\rIN pt)
\tkzLabelPoints[below](B,C)
\tkzLabelPoints[above left=0mm and -2mm](A,O)
\end{tikzpicture}
\end{document}