• 大小: 5KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-02
  • 语言: Matlab
  • 标签: Matlab  

资源简介

函数输入三角形三个点坐标,输出费马点坐标,如果三角形顶角大于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)]

评论

共有 条评论