資源簡介
函數輸入三角形三個點坐標,輸出費馬點坐標,如果三角形頂角大于120度,則輸出的點在三角形外部,使用者可在主函數中自行判斷是否使用該點。
代碼片段和文件信息
function?[a3a4]=fermatpoint(x1y1)
syms?x?y
b=y1(1)-(y1(1)-y1(2))/(x1(1)-x1(2))*x1(1);
if?(y1(3)-(y1(1)-y1(2))/(x1(1)-x1(2))*x1(3)-b)>0
????if?y1(1)>y1(2)
????????if?x1(1)>x1(2)
????????????A=[x1(2);y1(2)];
????????????B=[x1(1);y1(1)];
????????????AB?=?B?-?A;
????????????theta?=?deg2rad(60);
????????????T?=?[cos(theta)?sin(theta);?-sin(theta)?cos(theta)];
????????????C?=?A?+?T*AB;
????????else
????????????A=[x1(2);y1(2)];
????????????B=[x1(1);y1(1)];
????????????AB?=?B?-?A;
????????????theta?=?deg2rad(-60);
????????????T?=?[cos(theta)?sin(theta);?-sin(theta)?cos(theta)];
????????????C?=?A?+?T*AB;
????????end
????else
????????if?x1(1)>x1(2)
????????????A=[x1(1);y1(1)];
????????????B=[x1(2);y1(2)];
????????????AB?=?B?-?A;
????????????theta?=?deg2rad(-60);
????????????T?=?[cos(theta)?sin(theta);?-sin(theta)?cos(theta)];
????????????C?=?A?+?T*AB;
????????else
????????????A=[x1(1);y1(1)];
????????????B=[x1(2);y1(2)];
????????????AB?=?B?-?A;
????????????theta?=?deg2rad(60);
????????????T?=?[cos(theta)?sin(theta);?-sin(theta)?cos(theta)];
????????????C?=?A?+?T*AB;
????????end
????end
else
????if?y1(1)>y1(2)
????????if?x1(1)>x1(2)
????????????A=[x1(2);y1(2)];
????????????B=[x1(1);y1(1)];
????????????AB?=?B?-?A;
????????????theta?=?deg2rad(-60);
????????????T?=?[cos(theta)?sin(theta);?-sin(theta)?cos(theta)];
????????????C?=?A?+?T*AB;
????????else
????????????A=[x1(2);y1(2)];
????????????B=[x1(1);y1(1)];
????????????AB?=?B?-?A;
????????????theta?=?deg2rad(60);
????????????T?=?[cos(theta)?sin(theta);?-sin(theta)?cos(theta)];
????????????C?=?A?+?T*AB;
????????end
????else
????????if?x1(1)>x1(2)
????????????A=[x1(1);y1(1)];
????????????B=[x1(2);y1(2)];
????????????AB?=?B?-?A;
????????????theta?=?deg2rad(60);
????????????T?=?[cos(theta)?sin(theta);?-sin(theta)?cos(theta)];
????????????C?=?A?+?T*AB;
????????else
????????????A=[x1(1);y1(1)];
????????????B=[x1(2);y1(2)];
????????????AB?=?B?-?A;
????????????theta?=?deg2rad(-60);
????????????T?=?[cos(theta)?sin(theta);?-sin(theta)?cos(theta)];
????????????C?=?A?+?T*AB;
????????end
????end
end
b1=y1(2)-(y1(2)-y1(3))/(x1(2)-x1(3))*x1(2);
if?(y1(1)-(y1(2)-y1(3))/(x1(2)-x1(3))*x1(1)-b1)>0
????if?y1(2)>y1(3)
????????if?x1(2)>x1(3)
????????????A1=[x1(3);y1(3)]
- 上一篇:熵權法求權重MATLAB源碼
- 下一篇:bp神經網絡工具箱
評論
共有 條評論