INTERSECTTHREEPLANES Return intersection point between 3 planes in space. LINE = intersectThreePlanes(PLANE1, PLANE2, PLANE3) Returns the point or straight line belonging to three planes. PLANE: [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2] POINT: [x0 y0 z0] IF rank of the coefficient matrix r1 = 3 and Rank of the augmented matrix r2 = 3 return point Otherwise returns point with NaN values. See also planes3d, intersectPlanes, intersectLinePlane
0001 function point = intersectThreePlanes(plane1, plane2, plane3) 0002 %INTERSECTTHREEPLANES Return intersection point between 3 planes in space. 0003 % 0004 % LINE = intersectThreePlanes(PLANE1, PLANE2, PLANE3) 0005 % Returns the point or straight line belonging to three planes. 0006 % PLANE: [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2] 0007 % POINT: [x0 y0 z0] 0008 % IF rank of the coefficient matrix r1 = 3 and 0009 % Rank of the augmented matrix r2 = 3 return point 0010 % Otherwise returns point with NaN values. 0011 % 0012 % See also 0013 % planes3d, intersectPlanes, intersectLinePlane 0014 0015 % ------ 0016 % Author: Roozbeh Geraili Mikola 0017 % E-mail: roozbehg@berkeley.edu or roozbehg@live.com 0018 % Created: 2017-09-20 0019 % Copyright 2017-2024 0020 0021 % plane normal 0022 n1 = normalizeVector3d(cross(plane1(:,4:6), plane1(:, 7:9), 2)); 0023 n2 = normalizeVector3d(cross(plane2(:,4:6), plane2(:, 7:9), 2)); 0024 n3 = normalizeVector3d(cross(plane3(:,4:6), plane3(:, 7:9), 2)); 0025 0026 % Uses Hessian form, ie : N.p = d 0027 % I this case, d can be found as : -N.p0, when N is normalized 0028 d1 = dot(n1, plane1(:,1:3), 2); 0029 d2 = dot(n2, plane2(:,1:3), 2); 0030 d3 = dot(n3, plane3(:,1:3), 2); 0031 0032 % create coefficient and augmented matrices 0033 A = [n1;n2;n3]; 0034 D = [d1;d2;d3]; 0035 AD = [n1,d1;n2,d2;n3,d3]; 0036 0037 % calculate rank of the coefficient and augmented matrices 0038 r1 = rank(A); 0039 r2 = rank(AD); 0040 0041 % if rank of the coefficient matrix r1 = 3 and 0042 % rank of the augmented matrix r2 = 3 return point 0043 % and if r1 = 2 and r2 = 2 return line, 0044 % otherwise returns point with NaN values. 0045 if r1 == 3 && r2 == 3 0046 % Intersecting at a point 0047 point = (A\D)'; 0048 else 0049 point = [NaN NaN NaN]; 0050 end 0051