Home > matGeom > geom3d > planePoint.m

planePoint

PURPOSE ^

PLANEPOINT Compute 3D position of a point in a plane.

SYNOPSIS ^

function coord = planePoint(plane, point)

DESCRIPTION ^

PLANEPOINT Compute 3D position of a point in a plane.

   POINT = planePoint(PLANE, POS)
   PLANE is a 9 element row vector [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2]
   POS is the coordinate of a point in the plane basis,
   POINT is the 3D coordinate in global basis.

   Example
     plane = [10 20 30  1 0 0  0 1 1];
     pos2d = [3 4];
     pt = planePoint(plane, pos2d)
     pt = 
           13  24   34

   See also
   geom3d, planes3d, planePosition

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function coord = planePoint(plane, point)
0002 %PLANEPOINT Compute 3D position of a point in a plane.
0003 %
0004 %   POINT = planePoint(PLANE, POS)
0005 %   PLANE is a 9 element row vector [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2]
0006 %   POS is the coordinate of a point in the plane basis,
0007 %   POINT is the 3D coordinate in global basis.
0008 %
0009 %   Example
0010 %     plane = [10 20 30  1 0 0  0 1 1];
0011 %     pos2d = [3 4];
0012 %     pt = planePoint(plane, pos2d)
0013 %     pt =
0014 %           13  24   34
0015 %
0016 %   See also
0017 %   geom3d, planes3d, planePosition
0018 
0019 % ------
0020 % Author: David Legland
0021 % e-mail: david.legland@grignon.inra.fr
0022 % Created: 2007-09-18,    using Matlab 7.4.0.287 (R2007a)
0023 % Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.
0024 
0025 %   HISTORY
0026 %   2013-10-09 remove repmat
0027 
0028 % size of input arguments
0029 npl = size(plane, 1);
0030 npt = size(point, 1);
0031 
0032 % check inputs have compatible sizes
0033 if npl ~= npt && npl > 1 && npt > 1
0034     error('geom3d:planePoint:inputSize', ...
0035         'plane and point should have same size, or one of them must have 1 row');
0036 end
0037 
0038 % basis origin, eventually resized
0039 origin = plane(:, 1:3);
0040 if npl == 1 && npt > 1
0041     origin = origin(ones(npt,1), :);
0042 end
0043 
0044 % compute 3D coordinate
0045 coord = origin + ...
0046     bsxfun(@times, plane(:,4:6), point(:,1)) + ...
0047     bsxfun(@times, plane(:,7:9), point(:,2)) ;

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