CREATEVECTOR Create a vector from two points. V12 = createVector(P1, P2) Creates the vector V12, defined as the difference between coordinates of points P1 and P2. P1 and P2 are row vectors with ND elements, ND being the space dimension. If one of the inputs is a N-by-Nd array, the other input is automatically repeated, and the result is N-by-Nd. If both inputs have the same size, the result also have the same size. Example See also vectors2d, vectors3d, points2d ------ Author: David Legland e-mail: david.legland@grignon.inra.fr Created: 2010-12-07, using Matlab 7.9.0.529 (R2009b) Copyright 2010 INRA - Cepia Software Platform.
0001 function vect = createVector(p1, p2) 0002 %CREATEVECTOR Create a vector from two points. 0003 % 0004 % V12 = createVector(P1, P2) 0005 % Creates the vector V12, defined as the difference between coordinates 0006 % of points P1 and P2. 0007 % P1 and P2 are row vectors with ND elements, ND being the space 0008 % dimension. 0009 % 0010 % If one of the inputs is a N-by-Nd array, the other input is 0011 % automatically repeated, and the result is N-by-Nd. 0012 % 0013 % If both inputs have the same size, the result also have the same size. 0014 % 0015 % 0016 % Example 0017 % 0018 % See also 0019 % vectors2d, vectors3d, points2d 0020 % 0021 % 0022 % ------ 0023 % Author: David Legland 0024 % e-mail: david.legland@grignon.inra.fr 0025 % Created: 2010-12-07, using Matlab 7.9.0.529 (R2009b) 0026 % Copyright 2010 INRA - Cepia Software Platform. 0027 0028 vect = bsxfun(@minus, p2, p1);