MATLAB exercise program (Triangle incircle)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.