Home > matGeom > geom3d > medianPlane.m

medianPlane

PURPOSE ^

MEDIANPLANE Create a plane in the middle of 2 points.

SYNOPSIS ^

function plane = medianPlane(p1, p2)

DESCRIPTION ^

MEDIANPLANE Create a plane in the middle of 2 points.

   PLANE = medianPlane(P1, P2)
   Creates a plane in the middle of 2 points.
   PLANE is perpendicular to line (P1 P2) and contains the midpoint of P1
   and P2.
   The direction of the normal of PLANE is the same as the vector from P1
   to P2.

   See also:
   planes3d, createPlane

   ---------
   author : David Legland
   INRA - TPV URPOI - BIA IMASTE
   created the 18/02/2005.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plane = medianPlane(p1, p2)
0002 %MEDIANPLANE Create a plane in the middle of 2 points.
0003 %
0004 %   PLANE = medianPlane(P1, P2)
0005 %   Creates a plane in the middle of 2 points.
0006 %   PLANE is perpendicular to line (P1 P2) and contains the midpoint of P1
0007 %   and P2.
0008 %   The direction of the normal of PLANE is the same as the vector from P1
0009 %   to P2.
0010 %
0011 %   See also:
0012 %   planes3d, createPlane
0013 %
0014 %   ---------
0015 %   author : David Legland
0016 %   INRA - TPV URPOI - BIA IMASTE
0017 %   created the 18/02/2005.
0018 %
0019 
0020 %   HISTORY
0021 %   28/06/2007: add doc, and manage multiple inputs
0022 
0023 % unify data dimension
0024 if size(p1, 1)==1
0025     p1 = repmat(p1, [size(p2, 1) 1]);
0026 elseif size(p2, 1)==1
0027     p2 = repmat(p2, [size(p1, 1) 1]);
0028 elseif size(p1, 1)~=size(p2, 1)    
0029     error('data should have same length, or one data should have length 1');
0030 end
0031 
0032 % middle point
0033 p0  = (p1 + p2)/2;
0034 
0035 % normal to plane
0036 n   = p2-p1;
0037 
0038 % create plane from point and normal
0039 plane = createPlane(p0, n);

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