From 884b6b50c50abfb633b52f567009c0460b27fbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Laboissi=C3=A8re?= Date: Sat, 23 Mar 2024 11:24:15 -0300 Subject: New upstream version 4.1.0 --- inst/ispolycw.m | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'inst/ispolycw.m') 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 -- cgit v1.2.3