syms x1 x2 x3 y1 y2 y3
A = [x1 y1; x2 y2; x3 y3];
% 平移(将(x1,y1)平移到原点(0,0))
A(3,:)= A(3,:)-A(1,:);
A(2,:)= A(2,:)-A(1,:);
A(1,:)= 0;
% 旋转(将原(x2,y2)点旋转到x轴上)
d12 = sqrt(A(2,1)^2+A(2,2)^2); % 平移后原点到点2的距离
d13 = sqrt(A(3,1)^2+A(3,2)^2); % 平移后原点到点3的距离
st2 = atan(A(2,2)/A(2,1)); % 平移后点2的角度
st3 = atan(A(3,2)/A(3,1)); % 平移后点3的角度
A(2,1) = d12;
A(2,2) = 0;
A(3,1) = d13*cos(st3-st2);
A(3,2) = d13*sin(st3-st2);
%% 验证
[x1,x2,x3,y1,y2,y3] = deal(1,3,2,1,2,3);
plot(x1,y1,'ko',x2,y2,'ko',x3,y3,'ko');
axis([-1 6 -1 6]);
grid on
hold on;
line([x1 x2 x3 x1],[y1 y2 y3 y1],'color','k');
B = subs(A);
plot(B(:,1),B(:,2),'ro');
line([B(:,1);B(1,1)],[B(:,2);B(1,2)],'color','r');