Matlab 版 (精华区)
寄信人: zjliu (秋天的萝卜)
标 题: 可以告一段落了,再次谢谢您的耐心指教!
发信站: 哈工大紫丁香 (Tue Nov 23 21:12:49 2004)
来 源: 202.118.229.162
【 以下文字转载自 zjliu 的信箱 】
寄信人: ivanhit (ivan)
标 题: 可以告一段落了,再次谢谢您的耐心指教!
发信站: 哈工大紫丁香 (Tue Nov 23 20:59:34 2004)
来 源: 202.118.194.79
附上我最后整理出来的源程序,前者为数值算法,后者为解析算法,两者都可以实现以任
意三个点为起始圆心画任意个外切圆,有时间的话,不妨看看.Thanks!
程序附在下面:(file2太长,注意换行)
file 1:
function circles_1(n,x1,y1,x2,y2,x3,y3)
% circles(n,x1,y1,x2,y2,x3,y3)
% x1,y1,x2,y2,x3,y3 are the position of the first three points.
% n is the times of recursion
% examples:
% circles(5,-2,0,2,0,0,6),
% circles(5,0,0,3,0,0,4,5),
% circles(5,0,0,3,0,0,-4,5),
% author:
% zjliu from HIT,
% schuma from TSINGHUA,
% ivan form HRBUST
%
% $ version 3.0.0 $ $ date 23-Dec-2004 $
if nargin==0
P1=[-2,0];P2=[2,0];P3=[0,6];
n=4;
elseif nargin==1
P1=[0,0]; P2=[0,4]; P3=[3, 0];
elseif nargin~=7
disp('Error->>')
disp('the number of input arguments is wrong!Please input again.')
return
else
P1=[x1,y1];P2=[x2,y2];P3=[x3,y3];
end
x1=P1(1); y1=P1(2);
x2=P2(1); y2=P2(2);
x3=P3(1); y3=P3(2);
if abs(det([x1,y1,1;x2,y2,1;x3,y3,1]))<1e-6
disp('Error->>')
disp('There points on the same line!Please input again.')
return
end
s12=sqrt(sum((P1-P2).^2));
s23=sqrt(sum((P2-P3).^2));
s31=sqrt(sum((P3-P1).^2));
s=(s12+s23+s31)/2;
r1=s-s23; r2=s-s31; r3=s-s12;
warning off
figure
circle(x1,y1,r1,x2,y2,r2,x3,y3,r3,n);
rectangle('Position',[x1-r1,y1-r1,2*r1,2*r1],'curvature',[1 1],
'FaceColor','g');
rectangle('Position',[x2-r2,y2-r2,2*r2,2*r2],'curvature',[1 1],
'FaceColor','g');
rectangle('Position',[x3-r3,y3-r3,2*r3,2*r3],'curvature',[1 1],
'FaceColor','g');
axis equal;
X=[x1,x2,x3];
Y=[y1,y2,y3];
axis([min(X),max(X),min(Y),max(Y)])
% __________________________________________________
function [x,y,r]=circle(x1,y1,r1,x2,y2,r2,x3,y3,r3,n)
%
if n>0
FF=inline('sqrt((x-x1)^2+(y-y1)^2)-r1','x','y','x1','y1','r1');
x0=mean([x1,x3]);
y0=mean([y1,y3]);
xp=x2-x0;
yp=y2-y0;
A=atan((y3-y1)/(x3-x1));
K=[cos(A),sin(A);-sin(A),cos(A)]*[xp;yp];
K1=[x1-x0;y1-y0];
K1=[cos(A),sin(A);-sin(A),cos(A)]*K1;
x22=K(1);
y22=K(2);
x11=K1(1);
y11=K1(2);
c=sqrt((x1-x3)^2+(y1-y3)^2)/2;
a=abs(r1-r3)/2;
b=sqrt(c^2-a^2);
xf=inline('a*sqrt(y^2/b^2+1)','y','a','b');
ymin=0;
ymax=y22;
y=mean([ymin,ymax]);
a=a*sign(x11-r1*sign(x11));
x=xf(y,a,b);
tf1=FF(x,y,x11,y11,r1);
tf2=FF(x,y,x22,y22,r2);
while abs(tf1-tf2)>1e-4;
if tf1>tf2;
ymax=y;
else
ymin=y;
end
y=mean([ymin,ymax]);
x=xf(y,a,b);
tf1=FF(x,y,x11,y11,r1);
tf2=FF(x,y,x22,y22,r2);
end
K=[cos(-A),sin(-A);-sin(-A),cos(-A)]*[x;y];
x=K(1);
y=K(2);
x=x+x0;
y=y+y0;
r=tf1;
circle(x,y,r,x2,y2,r2,x3,y3,r3,n-1);
circle(x1,y1,r1,x,y,r,x3,y3,r3,n-1);
circle(x1,y1,r1,x2,y2,r2,x,y,r,n-1);
rectangle('Position',[x-r,y-r,2*r,2*r],'curvature',[1 1],'FaceColor','g');
end
file2:
function circles_2(varargin)
% popo_circle(x1,y1,x2,y2,x3,y3,n) plots a figure that contains many
circles.
% preferences:
% x1,y1,x2,y2,x3,y3 are the coordinates of the largest circles' center.
% n is the number of recursion
% author:
% schuma from TSINGHUA,
% ivan form HRBUST
% $ version 1.0.0 $ $ date 11-Dec-2004 $
if nargin==0
P1=[0,0]; P2=[0,4]; P3=[3, 0];
n=5;
elseif nargin==1
P1=[0,0]; P2=[0,4]; P3=[3, 0];
n=varargin{1};
elseif nargin~=7
disp('Error->>')
disp('the number of arguments is wrong!Please input again.')
return
else
n=varargin{1};
P1=[varargin{2},varargin{3}]; P2=[varargin{4},varargin{5}];
P3=[varargin{6},varargin{7}];
end
x1=P1(1); y1=P1(2);
x2=P2(1); y2=P2(2);
x3=P3(1); y3=P3(2);
if abs(det([x1,y1,1;x2,y2,1;x3,y3,1]))<1e-6
disp('Error->>')
disp('There points on the same line!Please input again.')
return
end
s12=sqrt(sum((P1-P2).^2));
s23=sqrt(sum((P2-P3).^2));
s31=sqrt(sum((P3-P1).^2));
s=(s12+s23+s31)/2;
r1=s-s23; r2=s-s31; r3=s-s12;
figure
circle(n,x1,y1,r1,x2,y2,r2,x3,y3,r3);
rectangle('Position',[x1-r1,y1-r1,2*r1,2*r1],'curvature',[1 1],
'FaceColor','g');
rectangle('Position',[x2-r2,y2-r2,2*r2,2*r2],'curvature',[1 1],
'FaceColor','g');
rectangle('Position',[x3-r3,y3-r3,2*r3,2*r3],'curvature',[1 1],
'FaceColor','g');
axis equal;
X=[x1,x2,x3];
Y=[y1,y2,y3];
% axis([min(X),max(X),min(Y),max(Y)])
% ------------------------------------------------------------
function circle(n,x1,y1,r1,x2,y2,r2,x3,y3,r3)
% recursion function
if n>0
% solve('(x0-x1)^2+(y0-y1)^2=(r0+r1)^2',
'(x0-x2)^2+(y0-y2)^2=(r0+r2)^2','(x0-x3)^2+(y0-y3)^2=(r0+r3)^2','x0',
'y0','r0');
% simplified solution
r01(1)=1/2*(r1^3*x3^2+r3^3*y1^2+2*y2*x3^2*r3*y1-y3*x2*((2*r3*r1-r3^2-r1^
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x3-2*r1*x2*r2*x3-2*r1*x2*r3*x3-r2^2*x3^2+2*r1^2*x2*x3+2*r1
*y2*y1*r2+2*r1*y1*y3*r3+(-2*y2*y3+y3^2-r3^2+2*r2*r3-r2^2+y2^2)*x1^2+(2*r
3^2*x2+2*y3*y2*x3-2*x2*r2*r3-2*r1*r2*x3+2*r1*r3*x3-2*x2*y1*y2-2*x2*y3^2-
2*y1*y3*x3-2*r1*x2*r3+2*r1*x2*r2+2*x2*y1*y3+2*x3*r2^2-2*y2^2*x3+2*x2*y3*
y2+2*y1*y2*x3-2*r2*r3*x3)*x1);
% the wanted solution should be selected from the 8 possible combinations of
% x, y, r, but I don't know why this solution behaves so strange.
% Anyway, I choose solution from 8 possible options. More conditions
% are added, such as, abs((x0-x1)^2+(y0-y1)^2-(r0+r1)^2)<1e-4, judging
% whether it is a real solution. Remember, there is possibly two real
% solutions satisfying the equations, so the former 4 conditions are
% also necessary.
found=0;
for i_select=0:7
sel(1)=mod(i_select,2)+1; i_select=floor(i_select./2);
sel(2)=mod(i_select,2)+1; i_select=floor(i_select./2);
sel(3)=mod(i_select,2)+1; i_select=floor(i_select./2);
r0=r01(sel(1));
x0=x01(sel(2));
y0=y01(sel(3));
% [x0,y0,r0]
if r0>0 && r0<min([r1,r2,r3]) && ...
det([x1,y1,1;x2,y2,1;x3,y3,1]).*det([x0,y0,1;x2,y2,1;x3,...
y3,1])>0 && ...
det([x1,y1,1;x2,y2,1;x3,y3,1]).*det([x1,y1,1;x0,y0,1;x3,...
y3,1])>0 && ...
det([x1,y1,1;x2,y2,1;x3,y3,1]).*det([x1,y1,1;x2,y2,1;x0,...
y0,1])>0 && ...
abs((x0-x1)^2+(y0-y1)^2-(r0+r1)^2)<1e-6 && ...
abs((x0-x2)^2+(y0-y2)^2-(r0+r2)^2)<1e-6 && ...
abs((x0-x3)^2+(y0-y3)^2-(r0+r3)^2)<1e-6
% the wanted solution is found!
found=1;
break
end
end
if found==0
disp('error!!') % no option meet the condition, perhaps the
threshold is too tight, so that the calculation error exceeds it.
% The long formulae accumulate too many errors.
return
end
circle(n-1,x0,y0,r0,x2,y2,r2,x3,y3,r3);
circle(n-1,x1,y1,r1,x0,y0,r0,x3,y3,r3);
circle(n-1,x1,y1,r1,x2,y2,r2,x0,y0,r0);
rectangle('Position',[x0-r0,y0-r0,2*r0,2*r0],'curvature',[1 1],...
'FaceColor','g');
end
--
*******************************************************
You can fool some people all the time,
or you can fool all people some of time,
but you can`t fool all people all the time.
*******************************************************
---ivanhit
※ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: 202.118.194.79]
※ 修改:·zjliu 于 Nov 23 21:16:58 修改本文·[FROM: 202.118.229.*]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:204.079毫秒