- 积分
- 8
- 注册时间
- 2006-9-14
- 仿真币
-
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2008-4-5 14:18:16
|
显示全部楼层
来自 大连理工大学
To:pcqsl
Actually,checking the intersection of two convex hulln,two conditions must be considered.The following pictures show what should be taken into account:
I think the ways you supplied are just available for the second conditon.Maybe the following function show what your mean,I call it Volume Add text Method-
- function N=AddVolume
- % 体积和法测试两多面体是否相交,相交则N=1,反之N=0
- % 但是此法不能判断另一类特殊的多面体相交情况
- % 2008 3 23 cheng wf
- % chengwf@yahoo.cn
- clear all
- clc
- [x,y,z]=sphere(20);
- i=1+round(rand.*4);
- x1=x(11,i);y1=y(11,i);z1=z(11,i);
- x2=x(11,i+5);y2=y(11,i+5);z2=z(11,i+5);
- x3=x(11,i+10);y3=y(11,i+10);z3=z(11,i+10);
- x4=x(11,i+15);y4=y(11,i+15);z4=z(11,i+15);
- i1_row=1;i1_coloun=1+round(rand.*19);
- j1_row=21;j1_coloun=1+round(rand.*19);
- z5=z(i1_row,i1_coloun);
- x5=x(i1_row,i1_coloun);
- y5=y(i1_row,i1_coloun);
- z6=z(j1_row,j1_coloun);
- x6=x(j1_row,j1_coloun);
- y6=y(j1_row,j1_coloun);
- if i<=3
- j=i+2;
- elseif i>3&i<=5
- j=i-2;
- end
- x7=x(16,j);y7=y(16,j);z7=z(16,j);
- x8=x(16,j+5);y8=y(16,j+5);z8=z(16,j+5);
- x9=x(16,j+10);y9=y(16,j+10);z9=z(16,j+10);
- x10=x(16,j+15);y10=y(16,j+15);z10=z(16,j+15);
- x11=x(6,j);y11=y(6,j);z11=z(6,j);
- x12=x(6,j+5);y12=y(6,j+5);z12=z(6,j+5);
- x13=x(6,j+10);y13=y(6,j+10);z13=z(6,j+10);
- x14=x(6,j+15);y14=y(6,j+15);z14=z(6,j+15);
- xi=[x1;x2;x3;x4;x5;x6;x7;x8;x9;x10;x11;x12;x13;x14];
- yi=[y1;y2;y3;y4;y5;y6;y7;y8;y9;y10;y11;y12;y13;y14];
- zi=[z1;z2;z3;z4;z5;z6;z7;z8;z9;z10;z11;z12;z13;z14];
- X=[xi,yi,zi];
- [c,V1]=convhulln(X);
- hold on
- for i=1:size(c,1)
- j=c(i,[1 2 3 1]);
- patch(X(j,1),X(j,2),X(j,3),[.5 .5 .5]);
- end
- view(3)
- % X2=[xi+1.5,yi,zi]; % 不相交 N=0
- X2=[xi+.5,yi,zi]; % 相交 N=1
- [c2,V2]=convhulln(X2);
- for i=1:size(c2,1);
- j=c2(i,[1 2 3 1]);
- patch(X2(j,1),X2(j,2),X2(j,3),[.5 .3 .2]);
- end
- % ======相交判断=====
- % 体积和测试法
- i=0;
- j=0;
- % N=0; % 不相交
- for i=1:length(X) % 对第1个多面体的每个顶点进行检测
- v=0;
- for j=1:size(c2,1)
- k=c2(j,;
- x_convexj=[X2(k,1);X(i,1)];
- y_convexj=[X2(k,2);X(i,2)];
- z_convexj=[X2(k,3);X(i,3)];
- convexj=[x_convexj,y_convexj,z_convexj];
- [L,vj]=convhulln(convexj);
- v=v+vj;
- end
- if abs(v-V2)<5*10e-5
- % if v==V2
- N=1.0 % 相交
- return
- else
- N=0 % 是否相交,待定
- % 调用其他函数判断另一种相交情况
- end
- end
- return
复制代码
[ 本帖最后由 chengweifeng 于 2008-4-5 21:24 编辑 ] |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
|