求空间直线的交点Word格式文档下载.docx
- 文档编号:20617822
- 上传时间:2023-01-24
- 格式:DOCX
- 页数:8
- 大小:15.83KB
求空间直线的交点Word格式文档下载.docx
《求空间直线的交点Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《求空间直线的交点Word格式文档下载.docx(8页珍藏版)》请在冰豆网上搜索。
if(~(isvector(n1)&
&
isvector(p1)&
isvector(n2)&
isvector(p2)))error('
Plane2Line:
theparameterisnotvector'
);
end
if((length(n1)~=3)||(length(p1)~=3)||(length(n2)~=3)||(length(p2)~=3))error('
theparameterisnot3dvector'
A=[n1
(1)n1
(2)n1
(3);
n2
(1)n2
(2)n2
(3)];
if(rank(A)<
2)
flag=0;
else
flag=1;
if(flag==1)
%calculatethenormalvector
n=cross(n1,n2);
c1=[n1
(3)-dot(n1,p1)];
c2=[n2
(3)-dot(n2,p2)];
%calculatethesimplestRowechelonmatrixtemp1=rref(A);
temp2=[123];
index
(1)=find(temp1(1,:
),1,'
first'
%thefirstnonzeroelementindex
(2)=find(temp1(2,:
%thefirstnonzeroelementD=[A(:
index
(1))A(:
index
(2))];
Y=[dot(n1,p1);
dot(n2,p2)];
X=inv(D)*Y;
fori=1:
3if(i~=index
(1)&
i~=index
(2))index
(3)=i;
endp(index
(1))=X
(1);
p(index
(2))=X
(2);
(3))=0;
elsen=[];
p=[];
end
fortest
%[flagnp]=Plane2Line([123],[101],[234],[0-10])%[flagnp]=
Plane2Line([O01],[0.50.50.5],[100],[001])2.MATLAB求空间中两条直线的交点
function[flag,p]=Line2Point(n1,p1,n2,p2)
%determinetherelationbetweentwostraightlinesand
%calulatetheintersectionpointiftheyareintersecting%%input:
%n1directionvectoroflineone
%p1anypointinlineone
%n2directionvectoroflinetwo
%p2anypointinlinetwo%%output:
%flagtherelationofthetwoline
%flag=0thetwolineareondifferentplane
%flag=1thetwolineareonthesameplaneandtheyareparallel%
flag=2thetwolineareonthesameplaneandtheyareintersecting
%pthepointsharedbythetwointersectingline%%author:
2014.1.17
%reference:
http:
isvector(p2)))error('
Line2Point:
if((length(n1)~=3)||(length(p1)~=3)||(length(n2)~=3)||(length(p2)~=3))
error('
A=[p2
(1)-p1
(1)p2
(2)-p1
(2)p2
(3)-p1
n1
(2)
];
if(det(A)~=0)flag=0;
elseif(rank(A(2:
3,:
))<
2)flag=1;
elseflag=2;
endendif(flag==2)B=rref(A(2:
));
(1)=find(B(1,:
),1,'
index
(2)=find(B(2,:
fori=1:
3
if(i~=index
(2))
Y(1,1)=-p1(index
(1))+p2(index
(1));
Y(2,1)=-p1(index
(2))+p2(index
(2));
D=[n1(index
(1))-n2(index
n1(index
(2))-n2(index
t=inv(D)*Y;
p
(1)=p1
(1)+n1
(1)*t
p
(2)=p1
(2)+n1
(2)*t
p(3)=p1
(3)+n1
(3)*t
p=[];
%fortest
%[flagp]=Line2Point([100],[000],[010],[110])%[flagp]=Line2Point([110],[000],[010],[110])
%[flagp]=Line2Point([11-1],[001],[010],[110])%[flagp]=Line2Point([11-1],[001],[11-1],[110])%[flagp]=Line2Point([111],[000],[200],[211])
%[flagp]=Line2Point([0-42050-21025],[-100],[00145],[000])
3.MATLAB求空间中直线和某一线段的交点
function[flag,p]=LineSegment2Point(n1,p1,p21,p22)
%determinetherelationbetweenastraightlineand
%alinesegmentandcalulatetheintersectingpoint
%iftheyareintersecting%%input:
%n1directionvectorofthestraightline
%p1anypointinthestraightline
%p21anypointinthelinesegment
%p22anyanotherdifferentpointinthelinesegment%%output:
%flag=0thestraightlineandlinesegmentarenotintersecting%flag=1thestraightlineandlinesegmentareintersecting%pthepointsharedbythetwointersectingline%%author:
isvector(p21)&
isvector(p22)))error('
LineSegment2Point:
if((length(n1)~=3)||(length(p1)~=3)||(length(p21)~=3)||(length(p22)~=3))
if((p21
(1)==p22
(1))&
(p21
(2)==p22
(2))&
(3)==p22
(3)))
thetwoappointedpointsoflinesegmentarethesame'
%calculatethedirectionvectoroflinesegment
n2=[p22
(1)-p21
(1),p22
(2)-p21
(2),p22
(3)-p21
[flag0,p0]=Line2Point(n1,p1,n2,p21);
if(flag0==2)
if(norm(p0-p21)<
=norm(p22-p21)&
norm(p0-p22)<
=norm(p22-p21))flag=1;
p=p0;
%[flagp]=LineSegment2Point([001],[000],[011],[021])%[flagp]=LineSegment2Point([111],[000],[011],[021])%[flagp]=LineSegment2Point([111],[000],[011],[111])%[flagp]=LineSegment2Point([111],[000],[011],[211])
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 空间 直线 交点
![提示](https://static.bdocx.com/images/bang_tan.gif)