2022年求空间直线的交 .pdf
《2022年求空间直线的交 .pdf》由会员分享,可在线阅读,更多相关《2022年求空间直线的交 .pdf(6页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、因为一个小任务需要用到求空间直线交点的MATLAB 函数和求空间中两个平面的相交线的函数, 但是在网上找了一下没有,只好自己写了几个函数,自己觉得还能用,在这里给大家分享一下。1.MATLAB求空间中的两个平面的相交线function flag,n,p = PlanePlane2Line(n1,p1,n2,p2)%-% calulate the line shared by two intersecting plane% input: % n1 normal vector of plane one% p1 any point on plane one% n2 normal vector of
2、plane two% p2 any point on plane two% output:% flag whether the two planes are intersecting ( 1 or 0)% n the direction vector of the expected line% p any point in the expected line% author: Lai Zhenzhou from Harbin Institute of Technology% email: % date: 2014.1.16%-if(isvector(n1) & isvector(p1) & i
3、svector(n2) & isvector(p2) error(PlanePlane2Line:the parameter is not vector); endif(length(n1)=3)|(length(p1)=3)|(length(n2)=3)|(length(p2)=3) error(PlanePlane2Line:the parameter is not 3d vector); endA = n1(1) n1(2) n1(3);n2(1) n2(2) n2(3);if(rank(A)2) flag = 0;else flag = 1;endif(flag=1)名师资料总结 -
4、- -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 6 页 - - - - - - - - - % calculate the normal vector n = cross(n1,n2); c1 = n1(1) n1(2) n1(3) -dot(n1,p1); c2 = n2(1) n2(2) n2(3) -dot(n2,p2); % calculate the simplest Row echelon matrix temp1 = rref(A); temp2 = 1 2 3; index
5、(1) = find(temp1(1,:),1,first); % the first nonzero element index(2) = find(temp1(2,:),1,first); % the first nonzero element D = A(:,index(1) A(:,index(2); Y = dot(n1,p1);dot(n2,p2); X = inv(D)*Y;for i=1:3if(i=index(1) & i=index(2) index(3) = i;endend p(index(1) = X(1); p(index(2) = X(2); p(index(3)
6、 = 0;else n=; p=;end%-for test-% flag n p = PlanePlane2Line(1 2 3,1 0 1,2 3 4,0 -1 0)% flag n p = PlanePlane2Line(0 0 1,0.5 0.5 0.5,1 0 0,0 0 1)名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 6 页 - - - - - - - - - 2.MATLAB求空间中两条直线的交点function flag,p = LineLine2Po
7、int(n1,p1,n2,p2)%-% determine the relation between two straight lines and% calulate the intersection point if they are intersecting% input:% n1 direction vector of line one% p1 any point in line one% n2 direction vector of line two% p2 any point in line two% output:% flag the relation of the two lin
8、e% flag = 0 the two line are on different plane % flag = 1 the two line are on the same plane and they are parallel% flag = 2 the two line are on the same plane and they are intersecting% p the point shared by the two intersecting line% author: Lai Zhenzhou from Harbin Institute of Technology% email
9、: % date: 2014.1.17% reference: http:/ & isvector(p1) & isvector(n2) & isvector(p2) error(LineLine2Point: the parameter is not vector); endif(length(n1)=3)|(length(p1)=3)|(length(n2)=3)|(length(p2)=3) error(LineLine2Point: the parameter is not 3d vector); endA = p2(1)-p1(1) p2(2)-p1(2) p2(3)-p1(3);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年求空间直线的交 2022 空间 直线
限制150内