Home > matGeom > geom3d > isBelowPlane.m

isBelowPlane

PURPOSE ^

ISBELOWPLANE Test whether a point is below or above a plane.

SYNOPSIS ^

function below = isBelowPlane(point, varargin)

DESCRIPTION ^

ISBELOWPLANE Test whether a point is below or above a plane.

   BELOW = isBelowPlane(POINT, PLANE)
   where POINT is given as coordinate row vector [XP YP ZP], and PLANE is
   given as a row containing initial point and 2 direction vectors, 
   return TRUE if POINT lie below PLANE.

   Example
   isBelowPlane([1 1 1], createPlane([1 2 3], [1 1 1]))
   ans =
       1
   isBelowPlane([3 3 3], createPlane([1 2 3], [1 1 1]))
   ans =
       0

   See also
   planes3d, points3d, linePosition3d, planePosition

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2007-01-05
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function below = isBelowPlane(point, varargin)
0002 %ISBELOWPLANE Test whether a point is below or above a plane.
0003 %
0004 %   BELOW = isBelowPlane(POINT, PLANE)
0005 %   where POINT is given as coordinate row vector [XP YP ZP], and PLANE is
0006 %   given as a row containing initial point and 2 direction vectors,
0007 %   return TRUE if POINT lie below PLANE.
0008 %
0009 %   Example
0010 %   isBelowPlane([1 1 1], createPlane([1 2 3], [1 1 1]))
0011 %   ans =
0012 %       1
0013 %   isBelowPlane([3 3 3], createPlane([1 2 3], [1 1 1]))
0014 %   ans =
0015 %       0
0016 %
0017 %   See also
0018 %   planes3d, points3d, linePosition3d, planePosition
0019 %
0020 % ------
0021 % Author: David Legland
0022 % e-mail: david.legland@grignon.inra.fr
0023 % Created: 2007-01-05
0024 % Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.
0025 
0026 if length(varargin)==1
0027     plane = varargin{1};
0028 elseif length(varargin)==2
0029     plane = createPlane(varargin{1}, varargin{2});
0030 end
0031 
0032 % ensure same dimension for parameters
0033 if size(point, 1)==1
0034     point = repmat(point, [size(plane, 1) 1]);
0035 end
0036 if size(plane, 1)==1
0037     plane = repmat(plane, [size(point, 1) 1]);
0038 end
0039     
0040 % compute position of point projected on 3D line corresponding to plane
0041 % normal, and returns true for points locatd below the plane (pos<=0).
0042 below = linePosition3d(point, [plane(:, 1:3) planeNormal(plane)]) <= 0;

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