Home > matGeom > geom3d > intersectThreePlanes.m

intersectThreePlanes

PURPOSE ^

INTERSECTTHREEPLANES Return intersection point between 3 planes in space.

SYNOPSIS ^

function point = intersectThreePlanes(plane1, plane2, plane3)

DESCRIPTION ^

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

   ---------
   author : Roozbeh Geraili Mikola
   email  : roozbehg@berkeley.edu or roozbehg@live.com
   created the 09/20/2017.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 %   email  : roozbehg@berkeley.edu or roozbehg@live.com
0018 %   created the 09/20/2017.
0019 %
0020 
0021 %   HISTORY
0022 
0023 % plane normal
0024 n1 = normalizeVector3d(cross(plane1(:,4:6), plane1(:, 7:9), 2));
0025 n2 = normalizeVector3d(cross(plane2(:,4:6), plane2(:, 7:9), 2));
0026 n3 = normalizeVector3d(cross(plane3(:,4:6), plane3(:, 7:9), 2));
0027 
0028 % Uses Hessian form, ie : N.p = d
0029 % I this case, d can be found as : -N.p0, when N is normalized
0030 d1 = dot(n1, plane1(:,1:3), 2);
0031 d2 = dot(n2, plane2(:,1:3), 2);
0032 d3 = dot(n3, plane3(:,1:3), 2);
0033 
0034 % create coefficient and augmented matrices
0035 A = [n1;n2;n3];
0036 D = [d1;d2;d3];
0037 AD = [n1,d1;n2,d2;n3,d3];
0038 
0039 % calculate rank of the coefficient and augmented matrices
0040 r1 = rank(A);
0041 r2 = rank(AD);
0042 
0043 % if rank of the coefficient matrix r1 = 3 and
0044 % rank of the augmented matrix r2 = 3 return point
0045 % and if r1 = 2 and r2 = 2 return line,
0046 % otherwise returns point with NaN values.
0047 if r1 == 3 && r2 == 3
0048     % Intersecting at a point
0049     point = (A\D)';
0050 else
0051     point = [NaN NaN NaN];
0052 end
0053

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019