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
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 % E-mail: david.legland@inrae.fr 0017 % Created: 2005-02-18 0018 % Copyright 2005-2024 INRA - TPV URPOI - BIA IMASTE 0019 0020 % unify data dimension 0021 if size(p1, 1)==1 0022 p1 = repmat(p1, [size(p2, 1) 1]); 0023 elseif size(p2, 1)==1 0024 p2 = repmat(p2, [size(p1, 1) 1]); 0025 elseif size(p1, 1)~=size(p2, 1) 0026 error('data should have same length, or one data should have length 1'); 0027 end 0028 0029 % middle point 0030 p0 = (p1 + p2)/2; 0031 0032 % normal to plane 0033 n = p2-p1; 0034 0035 % create plane from point and normal 0036 plane = createPlane(p0, n);