summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Laboissiere <rafael@laboissiere.net>2016-02-12 13:30:40 -0200
committerRafael Laboissiere <rafael@laboissiere.net>2016-02-12 13:30:40 -0200
commita82b811ff82f76adefb1a2866e13cc1ef1acb690 (patch)
treec1da2964d40094b86b7945c262ffafa96cfd870d
parent7926d5d2da963b04da90798ec697dfee139da3b8 (diff)
Imported Upstream version 2.1.0
-rw-r--r--.hgtags5
-rw-r--r--DESCRIPTION8
-rw-r--r--INDEX3
-rw-r--r--NEWS17
-rw-r--r--PKG_ADD6
-rw-r--r--PKG_DEL6
-rw-r--r--inst/geom2d/distancePointEdge.m17
-rw-r--r--inst/geom2d/distancePointLine.m13
-rw-r--r--inst/geom2d/findClosestPoint.m64
-rw-r--r--inst/io/@svg/plot.m2
-rw-r--r--inst/io/data2geo.m3
-rw-r--r--inst/meshes3d/createCube.m3
-rw-r--r--inst/meshes3d/createCubeOctahedron.m4
-rw-r--r--inst/polygons2d/distancePointPolyline.m88
-rw-r--r--inst/polygons2d/projPointOnPolyline.m147
15 files changed, 326 insertions, 60 deletions
diff --git a/.hgtags b/.hgtags
deleted file mode 100644
index 3161e61..0000000
--- a/.hgtags
+++ /dev/null
@@ -1,5 +0,0 @@
-9f5b4ecc44f5a2718bfb5f83388fefd948c2a8dc release-2.0.0
-9f5b4ecc44f5a2718bfb5f83388fefd948c2a8dc release-2.0.0
-0000000000000000000000000000000000000000 release-2.0.0
-0000000000000000000000000000000000000000 release-2.0.0
-200eaaa7c3c97a6c5e19d30585efc313d3474247 release-2.0.0
diff --git a/DESCRIPTION b/DESCRIPTION
index 544a5f1..e3c7bc9 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,11 +1,11 @@
Name: Geometry
-Version: 2.0.0
-Date: 2015-04-27
-Author: David Legland <david.legland@grignon.inra.fr>, Juan Pablo Carbajal <ajuanpi+dev@gmail.com>, Simeon Simeonov <sss41@cam.ac.uk>
+Version: 2.1.0
+Date: 2016-02-04
+Author: Juan Pablo Carbajal <ajuanpi+dev@gmail.com>, Simeon Simeonov <sss41@cam.ac.uk>, David Legland <david.legland@grignon.inra.fr>,
Maintainer: Juan Pablo Carbajal <ajunapi+dev@gmail.com>
Title: Computational Geometry
Description: Library for geometric computing extending MatGeom functions. Useful to create, transform, manipulate and display geometric primitives.
Depends: octave (>= 4.0.0)
Autoload: no
License: GPLv3+, FreeBSD
-Url: http://octave.sf.net, http://matgeom.sf.net
+Url: http://octave.sf.net, https://github.com/dlegland/matGeom
diff --git a/INDEX b/INDEX
index 0b42479..c94de19 100644
--- a/INDEX
+++ b/INDEX
@@ -17,6 +17,7 @@ geometry >> Computational Geometry
closed_path
distancePoints
drawPoint
+ findClosestPoint
isCounterClockwise
isPointOnRay
isPointInCircle
@@ -75,6 +76,8 @@ geometry >> Computational Geometry
pointOnLine
projPointOnLine
reverseLine
+2D Polylines
+ projPointOnPolyline
2D Boxes
clipEdge
clipLine
diff --git a/NEWS b/NEWS
index 195853e..766dfb3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,24 @@
Summary of important user-visible changes for releases of the geometry package
===============================================================================
+geometry-2.1.0 Release Date: 2016-02-07 Release Manager: Juan Pablo Carbajal
+===============================================================================
+
+** Added Functions
+
+ projPointOnPolyline: the function is added for compatibility, but it is just
+ a wrapper of distancePointPolyline.
+ findClosestPoint
+
+
+** Improved Functions
+ distancePointPolyline is now updated with a spee dup of 100x. It also calculates
+ the projections, so projPointOnPolyline is obsolete.
+
+===============================================================================
geometry-2.0.0 Release Date: 2015-04-27 Release Manager: Juan Pablo Carbajal
===============================================================================
-** Geometry 2.0.0 is not compatible with versions of octave older
+** Geometry 2.0.0 is not compatible with versions of octave older
than 4.0. Thi si due to inputParser being used in the functions
curve2polyline, cov2ellipse and simplifypolyline. If you do not
need this functions you should no problems using octave > 3.6.0
diff --git a/PKG_ADD b/PKG_ADD
index c0d0b91..c26723e 100644
--- a/PKG_ADD
+++ b/PKG_ADD
@@ -1,9 +1,9 @@
#1
dirlist = {"geom2d","io","polygons2d","shape2d", "graphs",...
"geom3d","meshes3d","polynomialCurves2d"};
-## Get full path, with luck we can retireve the package name from here
-dirname = fileparts (canonicalize_file_name (mfilename ("fullpath")));
-pp = strsplit (dirname,filesep (), true);
+## Get full path, with luck we can retreive the package name from here
+dirname = fileparts (make_absolute_filename (mfilename ("fullpath")));
+pp = strsplit (dirname,filesep , true);
arch = cstrcat (octave_config_info ("canonical_host_type"),
"-", octave_config_info ("api_version"));
pkg_name = pp{end};
diff --git a/PKG_DEL b/PKG_DEL
index 3cd96ec..93e4a90 100644
--- a/PKG_DEL
+++ b/PKG_DEL
@@ -1,9 +1,9 @@
#1
dirlist = {"geom2d","io","polygons2d","shape2d", "graphs",...
"geom3d","meshes3d","polynomialCurves2d"};
-## Get full path, with luck we can retireve the package name from here
-dirname = fileparts (canonicalize_file_name (mfilename ("fullpath")));
-pp = strsplit (dirname,filesep (), true);
+## Get full path, with luck we can retrieve the package name from here
+dirname = fileparts (make_absolute_filename (mfilename ("fullpath")));
+pp = strsplit (dirname,filesep, true);
arch = cstrcat (octave_config_info ("canonical_host_type"),
"-", octave_config_info ("api_version"));
pkg_name = pp{end};
diff --git a/inst/geom2d/distancePointEdge.m b/inst/geom2d/distancePointEdge.m
index ca1a97f..b2e693e 100644
--- a/inst/geom2d/distancePointEdge.m
+++ b/inst/geom2d/distancePointEdge.m
@@ -2,16 +2,16 @@
## Copyright (C) 2004-2011 INRA - CEPIA Nantes - MIAJ (Jouy-en-Josas)
## Copyright (C) 2012 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
## All rights reserved.
-##
+##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
-##
+##
## 1 Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## 2 Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
-##
+##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS''
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -68,11 +68,14 @@ function [dist, tp] = distancePointEdge(point, edge, opt=[])
# compute position of points projected on the supporting line
# (Size of tp is the max number of edges or points)
- delta = dx .* dx + dy .* dy;
- mask = delta < eps;
+ delta = dx .* dx + dy .* dy;
+ mask = delta < eps;
delta(mask) = 1;
+
warning ('off', 'Octave:broadcast','local');
- tp = ((point(:, 1) - edge(1, :)) .* dx + (point(:, 2) - edge(2, :)) .* dy) ./ delta;
+
+ tp = ((point(:, 1) - edge(1, :)) .* dx + ...
+ (point(:, 2) - edge(2, :)) .* dy) ./ delta;
tp(:,mask) = 0;
# change position to ensure projected point is located on the edge
@@ -84,7 +87,7 @@ function [dist, tp] = distancePointEdge(point, edge, opt=[])
p0y = (edge(2,:) + tp .* dy);
# compute distance between point and its projection on the edge
- dist = sqrt((point(:,1) - p0x) .^ 2 + (point(:,2) - p0y) .^ 2);
+ dist = sqrt ((point(:,1) - p0x) .^ 2 + (point(:,2) - p0y) .^ 2);
warning ('on', 'Octave:broadcast','local');
diff --git a/inst/geom2d/distancePointLine.m b/inst/geom2d/distancePointLine.m
index 7640be7..506d63e 100644
--- a/inst/geom2d/distancePointLine.m
+++ b/inst/geom2d/distancePointLine.m
@@ -2,16 +2,16 @@
## Copyright (C) 2004-2011 INRA - CEPIA Nantes - MIAJ (Jouy-en-Josas)
## Copyright (C) 2012 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
## All rights reserved.
-##
+##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
-##
+##
## 1 Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## 2 Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
-##
+##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS''
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -28,7 +28,7 @@
## Minimum distance between a point and a line
##
## D = distancePointLine(POINT, LINE)
-## Return the euclidean distance between line LINE and point POINT.
+## Return the euclidean distance between line LINE and point POINT.
##
## LINE has the form : [x0 y0 dx dy], and POINT is [x y].
##
@@ -43,7 +43,7 @@
## @seealso{lines2d, points2d, distancePoints, distancePointEdge}
## @end deftypefn
-function dist = distancePointLine(point, line)
+function dist = distancePointLine (point, line)
if size(line, 1)==1 && size(point, 1)>1
line = repmat(line, [size(point, 1) 1]);
@@ -62,8 +62,7 @@ function dist = distancePointLine(point, line)
# compute distances between points and their projections
- dx = point - p0;
+ dx = point - p0;
dist = sqrt(sum(dx.*dx, 2));
endfunction
-
diff --git a/inst/geom2d/findClosestPoint.m b/inst/geom2d/findClosestPoint.m
new file mode 100644
index 0000000..0a44fa1
--- /dev/null
+++ b/inst/geom2d/findClosestPoint.m
@@ -0,0 +1,64 @@
+## Copyright (C) 2004-2015 David Legland <david.legland@grignon.inra.fr>
+## Copyright (C) 2004-2015 INRA - CEPIA Nantes - MIAJ (Jouy-en-Josas)
+## Copyright (C) 2016 Adapted to Octave by Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
+## All rights reserved.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions are met:
+##
+## 1 Redistributions of source code must retain the above copyright notice,
+## this list of conditions and the following disclaimer.
+## 2 Redistributions in binary form must reproduce the above copyright
+## notice, this list of conditions and the following disclaimer in the
+## documentation and/or other materials provided with the distribution.
+##
+## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS''
+## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+## ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+## CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {[@var{index}, @var{mindist}] =} findClosestPoint (@var{point}, @var{pointarray})
+## Find index of closest point in an array and the distance between @var{point} and closest point in @var{pointarray}.
+##
+## Example:
+##@example
+## pts = rand(10, 2);
+## findClosestPoint(pts(4, :), pts)
+## ans =
+## 4
+##@end example
+## @seealso{points2d, minDistancePoints, distancePoints}
+## @end deftypefn
+
+function [index, minDist] = findClosestPoint(coord, points)
+
+ % number of point in first input to process
+ np = size (coord, 1);
+
+ % allocate memory for result
+ index = zeros (np, 1);
+ minDist = zeros (np, 1);
+
+ for i = 1:np
+ % compute squared distance between current point and all point in array
+ dist = sumsq (coord(i,:) - points, 2);
+
+ % keep index of closest point
+ [minDist(i), index(i)] = min(dist);
+ endfor
+endfunction
+
+%!demo
+%! pts = rand (10, 2);
+%! pt = rand (1, 2);
+%! [idx d] = findClosestPoint (pt, pts);
+%! printf ("Point (%g,%g).\n", pt);
+%! printf ("The %dth is the closest point (%g,%g).\n", idx, pts(idx,:));
+%! printf ("The distance between them is %g.\n", d);
diff --git a/inst/io/@svg/plot.m b/inst/io/@svg/plot.m
index 5b7921b..205d5fd 100644
--- a/inst/io/@svg/plot.m
+++ b/inst/io/@svg/plot.m
@@ -40,7 +40,7 @@ function h = plot(obj, varargin)
for i = 1:npath
x = []; y = [];
- data = obj.Path.(ids(i)).data;
+ data = obj.Path.(ids{i}).data;
for j = 1:numel(data)
x = cat (2, x, polyval (data{j}(1,:),t));
diff --git a/inst/io/data2geo.m b/inst/io/data2geo.m
index 02a334a..16feaa4 100644
--- a/inst/io/data2geo.m
+++ b/inst/io/data2geo.m
@@ -105,7 +105,8 @@ endfunction
%! pkg load msh fpl
%! T = msh2m_gmsh(filename);
%! pdemesh(T.p,T.e,T.t)
-%!
+%! view(2)
+%! axis tight
%! # --------------------------------------------------------------------------
%! # We load the drawing6.svg file into Octave and transform it into a polygon.
%! # Then we create a temporary file where the .geo mesh will be written.
diff --git a/inst/meshes3d/createCube.m b/inst/meshes3d/createCube.m
index a24698f..2667d0d 100644
--- a/inst/meshes3d/createCube.m
+++ b/inst/meshes3d/createCube.m
@@ -81,4 +81,5 @@ endfunction
%!demo
%! [n e f] = createCube;
-%! drawMesh(n, f);
+%! drawMesh (n, f);
+%! view (3);
diff --git a/inst/meshes3d/createCubeOctahedron.m b/inst/meshes3d/createCubeOctahedron.m
index 3314a33..78f1dcd 100644
--- a/inst/meshes3d/createCubeOctahedron.m
+++ b/inst/meshes3d/createCubeOctahedron.m
@@ -76,5 +76,5 @@ endfunction
%!demo
%! [n e f] = createCubeOctahedron;
-%! drawMesh(n, f);
-
+%! drawMesh (n, f);
+%! view (3);
diff --git a/inst/polygons2d/distancePointPolyline.m b/inst/polygons2d/distancePointPolyline.m
index bc69606..3da07e9 100644
--- a/inst/polygons2d/distancePointPolyline.m
+++ b/inst/polygons2d/distancePointPolyline.m
@@ -1,17 +1,17 @@
-## Copyright (C) 2004-2011 David Legland <david.legland@grignon.inra.fr>
+## Copyright (C) 2004-2011 David Legland
## Copyright (C) 2004-2011 INRA - CEPIA Nantes - MIAJ (Jouy-en-Josas)
-## Copyright (C) 2012 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
+## Copyright (C) 2016 Juan Pablo Carbajal
## All rights reserved.
-##
+##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
-##
+##
## 1 Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## 2 Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
-##
+##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS''
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -23,6 +23,9 @@
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+## Author: 2004-2011 David Legland <david.legland@grignon.inra.fr>
+## Author: 2016 Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
+
## -*- texinfo -*-
## @deftypefn {Function File} {@var{dist} = } distancePointPolyline (@var{point},@var{poly})
## Compute shortest distance between a point and a polyline
@@ -40,36 +43,71 @@
## @seealso{polygons2d, points2d,distancePointEdge, projPointOnPolyline}
## @end deftypefn
-function varargout = distancePointPolyline(point, poly, varargin)
+function [minDist pos] = distancePointPolyline (point, poly, closed = false)
+
+ # check if input polyline is closed or not
+ if strcmp ('closed', closed)
+ closed = true;
+ elseif strcmp ('open', closed)
+ closed = false;
+ endif
+
+ # closes the polyline if necessary
+ if closed
+ poly = [poly; poly(1,:)];
+ endif
# number of points
- Np = size(point, 1);
+ Np = size (point, 1);
# allocate memory for result
- minDist = inf * ones(Np, 1);
+ minDist = inf (Np, 1);
## construct the set of edges
edges = [poly(1:end-1, :) poly(2:end, :)];
## compute distance between current each point and all edges
- dist = distancePointEdge(point, edges);
- ## get the minimum distance
- minDist = min(dist, [], 2);
+ [dist edgepos] = distancePointEdge (point, edges);
- ## original loopy verion:
- # process each point
- # for p = 1:Np
- # # construct the set of edges
- # edges = [poly(1:end-1, :) poly(2:end, :)];
- # # compute distance between current each point and all edges
- # dist = distancePointEdge(point(p, :), edges);
- # # update distance if necessary
- # minDist(p) = min(dist);
- # end
+ ## get the minimum distance
+ [minDist i] = min (dist, [], 2);
- # process output arguments
- if nargout<=1
- varargout{1} = minDist;
- end
+ # Contributed by Raghu Charan A 02.2016
+ pos = [];
+ if nargout == 2
+ Ne = size (edgepos, 2);
+ j = sub2ind ([Np,Ne], (1:Np).', i);
+ pos = i - 1 + edgepos(j);
+ endif
endfunction
+
+%!demo
+%! point = [2 1] .* rand (10,2) - [1 0];
+%! t = linspace (0,pi,25).';
+%! poly = [cos(t) sin(t)];
+%! [d pos] = distancePointPolyline (point,poly);
+%!
+%! # Calculate the projection on the polyline to plot
+%! p_ = zeros (10, 2);
+%!
+%! # projection on vertices of the polyline
+%! isvertex = abs (pos - fix (pos)) < eps;
+%! p_(isvertex,:) = poly (pos(isvertex)+1,:);
+%!
+%! # the rest
+%! pos = pos (!isvertex);
+%! i = fix (pos) + 1;
+%! x = pos - fix (pos);
+%! p_(!isvertex,:) = poly(i,:) + x.*(poly(i+1,:)-poly(i,:));
+%!
+%! # Plot
+%! plot (poly(:,1), poly(:,2),'.-', ...
+%! point(:,1), point(:,2), 'o', ...
+%! p_(:,1), p_(:,2),'.');
+%! legend ('Polyline', 'Points', 'Projections');
+%! line ([point(:,1) p_(:,1)].',[point(:,2) p_(:,2)].');
+%! arrayfun (@(i)text ((p_(i,1)+point(i,1))/2, (p_(i,2)+point(i,2))/2, ...
+%! sprintf("%.2f", d(i))), 1:10);
+%! axis tight
+%! axis equal
diff --git a/inst/polygons2d/projPointOnPolyline.m b/inst/polygons2d/projPointOnPolyline.m
new file mode 100644
index 0000000..5134576
--- /dev/null
+++ b/inst/polygons2d/projPointOnPolyline.m
@@ -0,0 +1,147 @@
+## Copyright (C) 2003-2011 David Legland
+## Copyright (C) 2015 Adapted by Juan Pablo Carbajal
+## All rights reserved.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions are met:
+##
+## 1 Redistributions of source code must retain the above copyright notice,
+## this list of conditions and the following disclaimer.
+## 2 Redistributions in binary form must reproduce the above copyright
+## notice, this list of conditions and the following disclaimer in the
+## documentation and/or other materials provided with the distribution.
+##
+## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS''
+## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+## ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+## CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+##
+## The views and conclusions contained in the software and documentation are
+## those of the authors and should not be interpreted as representing official
+## policies, either expressed or implied, of the copyright holders.
+
+## Author: David Legland <david.legland@grignon.inra.fr>
+## Adapted: JuanPi Carbajal <ajuanpi+dev@gmail.com>
+
+## -*- texinfo -*-
+## @deftypefn {Function File} {[@var{P}, @var{D}] =} projPointOnPolyline (@var{point}, @var{poly})
+## @deftypefnx {Function File} {[@dots{}] =} projPointOnPolyline (@dots{}, @var{closed})
+##
+## Compute the position of the orthogonal projection of a point on a
+## polyline.
+##
+## @var{point} is a 1x2 row vector containing point coordinates
+## @var{poly} is a Nx2 array containing coordinates of polyline vertices
+## @var{pos} is the position of the point on the polyline, between 0 and the
+## number of vertices of the polyline. @var{pos} can be a non-integer value, in
+## this case, the integer part correspond to the polyline edge index
+## (between 0 and N-1), and the floating-point part correspond to the
+## relative position on i-th edge (between 0 and 1, 0: edge start, 1: edge
+## end).
+##
+## When @var{point} is an array of points, returns a column vector with as many
+## rows as the number of points.
+##
+## If third input argument @var{closed} is given, it specifies if the polyline
+## is closed or not. @var{closed} can be one of:
+## @table @asis
+## @item 'closed'
+## The polyline is closed
+##
+## @item 'open'
+## The polyline is open
+##
+## @item a logical column vector
+## It should have the same number of elements as the number of points and it
+## specifies individually if each polyline is closed (true=closed).
+##
+## @end table
+##
+## @seealso{points2d, polygons2d, polylinePoint, distancePointPolyline}
+## @end deftypefn
+
+function [pos minDist] = projPointOnPolyline (point, poly, closed=false)
+
+ warning ('Octave:deprecated-keyword', ...
+ "This function is deprecated use distancePointPolyline instead.\n");
+
+ [minDist pos] = distancePointPolyline (point, poly, closed);
+
+# # check if input polyline is closed or not
+# if strcmp ('closed', closed)
+# closed = true;
+# elseif strcmp ('open', closed)
+# closed = false;
+# endif
+
+# # closes the polyline if necessary
+# if closed
+# poly = [poly; poly(1,:)];
+# endif
+
+# # number of points
+# Np = size (point, 1);
+
+# # number of vertices in polyline
+# Nv = size (poly, 1);
+
+# # allocate memory results
+# pos = zeros (Np, 1);
+# minDist = inf (Np, 1);
+
+# # iterate on points
+# for p=1:Np
+# # compute smallest distance to each edge
+# for i=1:Nv-1
+# # build current edge
+# edge = [poly(i,:) poly(i+1,:)];
+
+# # compute distance between current point and edge
+# [dist edgePos] = distancePointEdge (point(p, :), edge);
+
+# # update distance and position if necessary
+# if dist < minDist(p)
+# minDist(p) = dist;
+# pos(p) = i - 1 + edgePos;
+# endif
+# endfor
+# endfor
+
+endfunction
+
+%!demo
+%! warning ("off", "Octave:deprecated-keyword", "local");
+%! point = [2 1] .* rand (10,2) - [1 0];
+%! t = linspace (0,pi,25).';
+%! poly = [cos(t) sin(t)];
+%! [pos d] = arrayfun (@(i)projPointOnPolyline (point(i,:),poly), (1:10).');
+%!
+%! # Calculate the projection on the polyline to plot
+%! p_ = zeros (10, 2);
+%!
+%! # projection on vertices of the polyline
+%! isvertex = abs (pos - fix (pos)) < eps;
+%! p_(isvertex,:) = poly (pos(isvertex)+1,:);
+%!
+%! # the rest
+%! pos = pos (!isvertex);
+%! i = fix (pos) + 1;
+%! x = pos - fix (pos);
+%! p_(!isvertex,:) = poly(i,:) + x.*(poly(i+1,:)-poly(i,:));
+%!
+%! # Plot
+%! plot (poly(:,1), poly(:,2),'.-', ...
+%! point(:,1), point(:,2), 'o', ...
+%! p_(:,1), p_(:,2),'.');
+%! legend ('Polyline', 'Points', 'Projections');
+%! line ([point(:,1) p_(:,1)].',[point(:,2) p_(:,2)].');
+%! arrayfun (@(i)text ((p_(i,1)+point(i,1))/2, (p_(i,2)+point(i,2))/2, ...
+%! sprintf("%.2f", d(i))), 1:10);
+%! axis tight
+%! axis equal