diff options
author | Rafael Laboissière <rafael@debian.org> | 2024-03-23 11:24:15 -0300 |
---|---|---|
committer | Rafael Laboissière <rafael@debian.org> | 2024-03-23 11:24:15 -0300 |
commit | 884b6b50c50abfb633b52f567009c0460b27fbf9 (patch) | |
tree | 820e022ff3ac93c30cda3817c814ecbf1f741f6d /inst/ispolycw.m | |
parent | a45e15f167ef0a7cba3e9ed572209f3522658320 (diff) |
New upstream version 4.1.0
Diffstat (limited to 'inst/ispolycw.m')
-rw-r--r-- | inst/ispolycw.m | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/inst/ispolycw.m b/inst/ispolycw.m index 45dbffc..253fb4e 100644 --- a/inst/ispolycw.m +++ b/inst/ispolycw.m @@ -1,5 +1,6 @@ ## Copyright (C) 2016 - Juan Pablo Carbajal ## Copyright (C) 2017 - Piyush Jain +## Copyright (C) 2022 - Nir Krakauer ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -17,19 +18,19 @@ ## -*- texinfo -*- ## @deftypefn {} {@var{ccw} =} ispolycw (@var{p}) ## @deftypefnx {} {@var{ccw} =} ispolycw (@var{px}, @var{py}) -## Returns true if the polygon @var{p} are oriented Clockwise. +## Returns true if the polygon @var{p} are oriented clockwise. ## ## @var{p} is a N-by-2 array containing coordinates of vertices. The coordinates -## of the vertices of the polygon can also be given as two N-by-1 arrways +## of the vertices of the polygon can also be given as two N-by-1 arrays ## @var{px}, @var{py}. ## ## If polygon is self-crossing, the result is undefined. ## -## If x and y contain multiple contours, either in NaN-separated vector form or in cell array form, ispolycw returns a logical array containing one true or false value per contour. +## If @var{px}, @var{py} contain multiple contours, either in NaN-separated vector form or in cell array form, ispolycw returns a logical array containing one true or false value per contour. ## ## If a contour contains two or fewer vertices, ispolycw returns true. ## -## If @var{points} is a cell, each element is considered a polygon, the +## If @var{p} (or @var{px}, @var{py}) is a cell, each element is considered a polygon, the ## resulting @var{cw} array has the same shape as the cell. ## ## @seealso{polygonArea} @@ -38,7 +39,11 @@ function cw = ispolycw (px, py) if iscell (px) - cw = cellfun (@ispolycw, px); + if nargin == 2 + cw = cellfun (@ispolycw, px, py); + else + cw = cellfun (@ispolycw, px); + endif else if nargin == 2; @@ -70,6 +75,8 @@ end %!assert (ispolycw (pcw)); %!assert (ispolycw ({pccw;pcw}), [false;true]); %!assert (ispolycw ({pccw,pcw}), [false,true]); +%!assert (ispolycw ({pccw(:, 1);pcw(:, 1)}, {pccw(:, 2);pcw(:, 2)}), [false;true]); +%!assert (ispolycw ({pccw(:, 1),pcw(:, 1)}, {pccw(:, 2),pcw(:, 2)}), [false,true]); %!assert (ispolycw(ph),[false;true]); %!test |