封闭多边形的每段无非是直线段(直线方程+系数)、弧线段(椭圆方程+系数)、样条段(样条方程+系数)等等,有了这些参数,逐个计算它们到 A 点的最短距离,然后再从中取个最小的,不就完事儿了吗?
(这也只是思路,hehe)
-------- With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead.
我是来拿分的!!! ------ 图像不大的话,把边缘每个点离它的距离都算一遍,也不会很慢吧。。 ------ 凑热闹来了 ------ 不太懂算法,不过先看看,以后研究 ------ 你是想编程还是画图,编程的话就遍历每个点,比出最短的哪个。画图就用一个圆规,一根尺子很简单就量出来了。 ------ 这个你用MATLAB编程实现,就是将图像导入变成矩阵,通过扫描计算每一个点的距离。我做了一百张不规则的图,算出过每一张图的最大距离。我的MATLAB程序如下: function [point,lr]=final(x) left=[]; for i=1:512 for j=1:512 if (x(i,j)==0) left=[left;i,j,x(i,j)]; break end end end right=[]; for i=1:512 for j=512:-1:1 if (x(i,j)==0) right=[right;i,j,x(i,j)]; break end end end up=[]; if(left(1,2)~=right(1,2)) for i=left(1,2)+1:right(1,2)-1 up=[up;left(1,1),i,x(left(1,1),i)]; end end down=[]; a=size(left,1); if(left(a,2)~=right(a,2)) for i=left(a,2)+1:right(a,2)-1 down=[down;left(a,1),i,x(left(a,1),i)]; end end border=[left;up;right;down]; a=size(left,1); neibu=[]; for i=2:a-1 c=left(i,2)+1; d=right(i,2)-1; for j=c:d neibu=[neibu;left(i,1),j,x(left(i,1),j)]; end end temp=size(neibu,1); r=[]; for i=1:temp temp1=size(border,1); d=[]; for j=1:temp1 temp3=[((neibu(i,1)-border(j,1))^2+(neibu(i,2)-border(j,2))^2)^0.5,((neibu(i,1)-border(j,1))^2+(neibu(i,2)-border(j,2)+1)^2)^0.5]; d=[d,mean(temp3)]; end r=[r;min(d)]; end [lr,i]=max(r); point=[neibu(i,1),neibu(i,2)]; 最小 距离也一样。你也可以用C语言实现。祝你学习顺利! ------ 多看看书了 ------ 进来看一下 ------ 学习学习
桂ICP备07017180号