随着两个平行平面的任何含的四个点躺在每个这两个平面中的一个两个子集3个维多边形可以与6分来鉴定而已,它们中的每3可以表示平面至极含有一个这个多边形的面孔。
对于与{B_0,B_1,B_2}构成的平面平行的平面上的任何6个点{A_0,A_2,A_3},剩下的两个点需要一个条件来允许多边形,否则,我们可以面对任何不连续分布的坐标,这些坐标形成一个随机的非线性形状或一个圆或任何东西。 this illustration显示哪个两个由两个相同的彩色线条也必然平行,得到剩下的点,因为这些线的交叉。
- Sencondo,让我们继续计算给定的最后信息作为背景。
作为开始,分坐标可以被给予或者产生由系统:
syms x y z
P = [x,y,z]
left_x=0;right_x=4;
for j=0:1, for k=0:1, A((j)*2+k+1,1:3)=[left_x;floor(10*rand());floor(10*rand())];end,end
for j=0:1, for k=0:1, B((j)*2+k+1,1:3)=[right_x;floor(10*rand());floor(10*rand())];end,end
,或者手动键入
syms x y z
P = [x,y,z]
left_x=input('enter first x ');
for j=0:1, for k=0:1*~j, A((j)*2+k+1,1:3)=[left_x;input(['print y' char((j)*2+k+49) ' ']);input(['print z' char((j)*2+k+49) ' '])];end,end,
right_x=input('enter second x ');
for j=0:1, for k=0:1*~j, B((j)*2+k+1,1:3)=[right_x;input(['print y' char((j)*2+k+49) ' ']);input(['print z' char((j)*2+k+49) ' '])];end,end,
2-现在我们计算这些点的更靠近x-axix(更靠近)的y轴(更靠近),以找到由每3个点构成的4个虚拟平面的方程。
close_right_point=B((B(:,3)==min(B(:,3))),:)
far_right_point=B((B(:,3)==max(B(:,3))),:)
if(numel(close_right_point(:,1))==1)
temp=B((B(:,3)==min(B(B(:,3)~=min(B(:,3)),3))) ,:);
middler_points(2,:)=temp(1,:);
else
middler_points(2,:)=close_right_point(2,:);
end
closer_point=middler_points(middler_points(:,3)==min(middler_points(1,3),middler_points(2,3)),:)
if(numel(closer_point(:,1))==1)
further_point=middler_points(middler_points(:,3)==max(middler_points(1,3),middler_points(2,3)),:)
else
further_point=closer_point(2,:)
end
close_normal = cross(closer_point(1,:)-close_right_point(1,:), closer_point(1,:)-close_left_point(1,:))
close_plane=dot(close_normal,P-closer_point)
far_normal = cross(further_point-far_right_point(1,:), further_point-far_left_point(1,:))
far_plane=dot(far_normal,P-further_point)
low_left_point=A((A(:,2)==min(A(:,2))),:)
if(numel(low_left_point(:,1))==1)
temp=A((A(:,2)==min(A(A(:,2)~=min(A(:,2)),2))),:);
average_points(1,:)=temp(1,:);
else
average_points(1,:)=low_left_point(2,:);
end
high_left_point=A((A(:,2)==max(A(:,2))),:)
low_right_point=B((B(:,2)==min(B(:,2))),:)
high_right_point=B((B(:,2)==max(B(:,2))),:)
if(numel(low_right_point(:,1))==1)
temp=B((B(:,2)==min(B(B(:,2)~=min(B(:,2)),2))),:);
average_points(2,:)=temp(1,:);
else
average_points(2,:)=low_right_point(2,:);
end
lower_point=average_points(average_points(:,2)==min(average_points(1,2),average_points(2,2)),:)
if(numel(lower_point(:,1))==1)
higher_point=average_points(average_points(:,2)==max(average_points(1,2),average_points(2,2)),:)
else
higher_point=lower_point(2,:);
end
low_normal = cross(lower_point(1,:)-low_right_point(1,:), lower_point(1,:)-low_left_point(1,:))
low_plane=dot(low_normal,P-lower_point)
high_normal = cross(higher_point-high_right_point(1,:), higher_point-high_left_point(1,:))
high_plane=dot(high_normal,P-higher_point)
注意到,法线垂直矢量他们所代表的平面,任何平面的方程式从正常矢量提取。
this是图是如何示出,参见平行平面和6点动态可充分constitue任何3D polygone。
3-几乎具有与成品,保持到下一个阶段,我们通过用户输入接收期望的点的坐标:
X=input('enter X ')
Y=input('enter Y ')
Z=input('enter Z ')
然后,检查出如果点不超越极限右边或左边,与两个平行的平面与y轴
if (X>right_x)
'out-bounds'
return;
end
if (X<left_x)
'out-bounds'
return;
end
然后,画的假想线相交这一点parallelising y轴后,我们确保这一点通过所形成的链段之间保持总是这条线与更高和更低的病毒相交飞机为this simulation shows
if Z> str2num(char(regexp(evalc(['x=' num2str(X) ';y=' num2str(Y) ';' char(solve(far_plane,z))]),'(\d+.\d*)','match')))
'out-bounds'
return;
end
if Z< str2num(char(regexp(evalc(['x=' num2str(X) ';y=' num2str(Y) ';' char(solve(close_plane,z))]),'(\d+.\d*)','match')))
'out-bounds'
return;
end
if Y> str2num(char(regexp(evalc(['x=' num2str(X) ';z=' num2str(Z) ';' char(solve(high_plane,y))]),'(\d+.\d*)','match')))
'out-of-bounds'
return;
end
if Y< str2num(char(regexp(evalc(['x=' num2str(X) ';z=' num2str(Z) ';' char(solve(low_plane,y))]),'(\d+.\d*)','match')))
'out-of-bounds'
return;
end
4-敲定这一切,你可以使用这个数据输入检查该解决方案的有效性设置
0
0
0
6
5.6
0
5.05
4
0
0
6.51
-0.16
6.33
3.59
然后floatting点
1
2
3
成功!您可以通过点击任何点来查看/修改/检查使用此simulation的结果,然后使用任何参数更改定义文本字段,也可以拖动点。
看看[形状功能](http://www.colorado.edu/engineering/CAS/courses.d/AFEM.d/AFEM.Ch11.d/AFEM.Ch11.pdf)。计算自然坐标xi,eta和mu。如果所有这三个都在-1和1之间,那么这个点就在你的盒子里面。 –