From: <jpi...@us...> - 2012-02-10 13:22:36
|
Revision: 9613 http://octave.svn.sourceforge.net/octave/?rev=9613&view=rev Author: jpicarbajal Date: 2012-02-10 13:22:25 +0000 (Fri, 10 Feb 2012) Log Message: ----------- geometry: Bug fixes Modified Paths: -------------- trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/inst/io/@svg/path2polygon.m trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-02-10 12:32:17 UTC (rev 9612) +++ trunk/octave-forge/main/geometry/NEWS 2012-02-10 13:22:25 UTC (rev 9613) @@ -1,6 +1,17 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== +geometry-1.4.X Release Date: XX Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Bug fixes + - @svg/path2polygon.m + +* Known issues + - simplifypolygon.m returns empty polygons when points are repeated, i.e when + the polygon is not correctly formed. + +=============================================================================== geometry-1.4.0 Release Date: 2012-01-25 Release Manager: Juan Pablo Carbajal =============================================================================== Modified: trunk/octave-forge/main/geometry/inst/io/@svg/path2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/@svg/path2polygon.m 2012-02-10 12:32:17 UTC (rev 9612) +++ trunk/octave-forge/main/geometry/inst/io/@svg/path2polygon.m 2012-02-10 13:22:25 UTC (rev 9613) @@ -1,5 +1,5 @@ %% Copyright (c) 2011 Juan Pablo Carbajal <car...@if...> -%% +%% %% 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 %% the Free Software Foundation, either version 3 of the License, or @@ -16,13 +16,13 @@ %% -*- texinfo -*- %% @deftypefn {Function File} @var{P} = path2polygon (@var{id}) %% Converts the SVG path to an array of polygons. -%% +%% %% @end deftypefn function P = path2polygon (obj,varargin) narg = numel(varargin); - + if narg == 1 id = varargin{1}; @@ -38,16 +38,21 @@ error("svg:path2polygon:InvalidArgument", "Wrong number of arguments."); end - + + P = shape2polygon(getpath(obj, id)); + +endfunction + +%{ pd = obj.Path.(id).data; P = cellfun(@(x)convertpath(x,n),pd,'UniformOutput',false); P = cell2mat(P); - + end function p = convertpath(x,np) n = size(x,2); - + switch n case 2 p = zeros(2,2); @@ -63,3 +68,4 @@ end end +%} Modified: trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m 2012-02-10 12:32:17 UTC (rev 9612) +++ trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m 2012-02-10 13:22:25 UTC (rev 9613) @@ -35,6 +35,11 @@ polygonsimp = polygon(circshift (ind,1),:); + if isempty(polygonsimp) + warning('simplifypolygon:devel',"The simplification gives an empty polygon. Returning original\n"); + polygonsimp = polygon; + end + endfunction %!test Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-02-10 12:32:17 UTC (rev 9612) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-02-10 13:22:25 UTC (rev 9613) @@ -57,6 +57,10 @@ %! square = {[1 -0.5; 0 -0.5]; [0 0.5; 1 -0.5]; [-1 0.5; 0 0.5]; [0 -0.5; -1 0.5]}; %! CoM = shapecentroid (square); %! assert (CoM, [0 0], sqrt(eps)); +%! square_t = shapetransform (square,[1;1]); +%! CoM_t = shapecentroid (square_t); +%! assert (CoM, [0 0], sqrt(eps)); +%! assert (CoM_t, [1 1], sqrt(eps)); %!test %! circle = {[1.715729 -6.715729 0 5; ... @@ -69,3 +73,5 @@ %! -1.715729 6.715729 0 -5]}; %! CoM = shapecentroid (circle); %! assert (CoM , [0 0], 5e-3); + +%!test Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m 2012-02-10 12:32:17 UTC (rev 9612) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m 2012-02-10 13:22:25 UTC (rev 9613) @@ -17,7 +17,7 @@ %% @deftypefn {Function File} {@var{h} = } shapeplot (@var{shape}) %% @deftypefnx {Function File} {@var{h} = } shapeplot (@var{shape}, @var{N}) %% @deftypefnx {Function File} {@var{h} = } shapeplot (@dots{}, @var{param}, @var{value}) -%% Pots a 2D shape defined by piecewise smooth polynomials. +%% Pots a 2D shape defined by piecewise smooth polynomials in the current axis. %% %% @var{pp} is a cell where each elements is a 2-by-(poly_degree+1) matrix %% containing a pair of polynomials. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |