因为一个小任务需要用到求空间直线交点的MATLAB函数和求空间中两个平面的相交线的函数,但是在网上找了一下没有,只好自己写了几个函数,自己觉得还能用,在这里给大家分享一下。1.MATLAB求空间中的两个平面的相交线function[flag,n,p]=PlanePlane2Line(n1,p1,n2,p2)%---------------------------------------------------------%calulatethelinesharedbytwointersectingplane%input:%n1normalvectorofplaneone%p1anypointonplaneone%n2normalvectorofplanetwo%p2anypointonplanetwo%%output:%flagwhetherthetwoplanesareintersecting(1or0)%nthedirectionvectoroftheexpectedline%panypointintheexpectedline%%author:LaiZhenzhoufromHarbinInstituteofTechnology%email:laizhenzhou@126.com%date:2014.1.16%----------------------------------------------------------if(~(isvector(n1)&&isvector(p1)&&isvector(n2)&&isvector(p2)))error('PlanePlane2Line:theparameterisnotvector');endif((length(n1)~=3)||(length(p1)~=3)||(length(n2)~=3)||(length(p2)~=3))error('PlanePlane2Line:theparameterisnot3dvector');endA=[n1(1)n1(2)n1(3);n2(1)n2(2)n2(3)];if(rank(A)