急急急!本人毕设要用matlab画三角形三个角的角平分线,三角形三个点是随便给定(但不是随即生成),本人没有学过matlab,求高手指点(最好留个联系方式,以便答谢)
% p1,p2,p3是三个顶点,自己设定,联系邮箱[email protected]
clc; clear; close all
p1 = rand(1,2);
p2 = rand(1,2);
p3 = rand(1,2);
a = sqrt(sum((p2-p3).^2));
b = sqrt(sum((p1-p3).^2));
c = sqrt(sum((p2-p1).^2));
cent = [(a*p1(1)+b*p2(1)+c*p3(1))/(a+b+c), (a*p1(2)+b*p2(2)+c*p3(2))/(a+b+c)]
m = [p1;p2;p3];
t=0:0.05:1;
figure,
hold on
plot((p2(1)-p1(1)).*t+p1(1), (p2(2)-p1(2)).*t+p1(2), 'b-');
plot((p3(1)-p1(1)).*t+p1(1), (p3(2)-p1(2)).*t+p1(2), 'b-');
plot((p2(1)-p3(1)).*t+p3(1), (p2(2)-p3(2)).*t+p3(2), 'b-');
plot((p1(1)-cent(1)).*t+cent(1), (p1(2)-cent(2)).*t+cent(2), 'r-');
plot((p2(1)-cent(1)).*t+cent(1), (p2(2)-cent(2)).*t+cent(2), 'r-');
plot((p3(1)-cent(1)).*t+cent(1), (p3(2)-cent(2)).*t+cent(2), 'r-');
hold off
axis equal on
追问很好用,太感谢了,你能给我留个联系方式么?
追答