The angular bisector of the two angles of a triangle can determine the incircle.
The result is as follows:
The Matlab code is as follows:
Clear all; close all; clc; P = rand (3, 2); % (x, y) V12 = (P (2, :)-P (1 ,:)) /norm (P (2, :)-P (1, :)); % normalization vector v13 = (P (3, :)-P (1, :)) on both sides of a vertex ,:)) /norm (P (3, :)-P (1, :)); V21 = (P (1, :)-P (2, :))/norm (P (1, :)-P (2, :)); % normalization vector V23 = (P (3, :)-P (2, :))/norm (P (3, :)-P (2, :)); V1 = V12 + v13; % angular bisector k1 = V1 (2)/V1 (1 ); b1 = P (1, 2)-K1 * P (1, 1); v2 = V21 + V23; % cross-vertex 2's angle bisector k2 = v2 (2)/V2 (1 ); b2 = P ()-K2 * P (); X0 =-(b1-b2)/(K1-K2); % calculates the intersection of two straight lines, center Y0 =-(-B2 * k1 + B1 * K2)/(K1-K2); k = (P ()-P ()/(P) -P (); B = P ()-K * P (); r = (k * x0-y0 + B)/SQRT (K ^ 2 + 1 ); % calculates the distance from the center of a circle to an edge. The radius is hold on; plot (P (:, 1), P (:, 2); P = circshift (P, 1 ); plot (P (:, 1), P (:, 2); Theta = 0: 0. 0* PI; X = x0 + R * Cos (theta); y = y0 + R * sin (theta); plot (X, Y, '-', x0, y0, '. '); axis equal
MATLAB exercise program (Triangle incircle)