%% 直线为轴中心对称的圆
clc;
clear;
hold on
syms x y;
% 画对称轴
x1=-20:0.1:20;
k=1;
b1=10;
f1(x)=k.*x+b1;
plot(x1,f1(x1));
theta=0:2*pi/3600:2*pi;
R=4;
Circle1=10+R*cos(theta);
Circle2=10+R*sin(theta);
plot(Circle1,Circle2,'m','Linewidth',3);
x1=Circle1;
y1=Circle2;
% 对称点坐标(2*x0-x1,2f(x0)-y1)
b0=y1+(1/k).*x1;
x0=(b0-b1).*(k/(k^2+1));
x2=2*x0-x1;
y2=2*f1(x0)-y1;
plot(x2,y2,'r-');
axis equal
%% 直线为轴中心对称的三角形
close all; clear all; clc
hold on
x1=-20:0.1:20;
syms x
k=1/2;
b1=4;
f1(x)=k.*(x+2)+b1;
plot(x1,f1(x1),'b');
x1=1;x2=2;x3=1;
y1=1;y2=2;y3=3;
triangle_x1=[x1,x2,x3,x1];
triangle_y1=[y1,y2,y3,y1];
fill(triangle_x1,triangle_y1,'r');
% 对称点坐标(2*x0-x1,2f(x0)-y1)
b0=triangle_y1+(1/k).* triangle_x1;
x0=(b0-b1).*(k/(k^2+1));
triangle_x2=2*x0-triangle_x1;
triangle_y2=2*f1(x0)-triangle_y1;
% triangle_y2=[1,2,1,1];
fill(triangle_x2,triangle_y2,'b');
axis([-5 5 -5 30])
axis equal;
%% 点为中心对称的三角形
close all; clear all; clc
hold on
x0=1.5;
y0=2;
plot(x0,y0,'*')
x1=1;x2=2;x3=1;
y1=1;y2=2;y3=3;
triangle_x1=[x1,x2,x3,x1];
triangle_y1=[y1,y2,y3,y1];
fill(triangle_x1,triangle_y1,'r');
triangle_x2=2*x0-triangle_x1;
triangle_y2=2*y0-triangle_y1;
fill(triangle_x2,triangle_y2,'b');
axis equal;