From: <jpi...@us...> - 2011-11-03 23:53:48
|
Revision: 8972 http://octave.svn.sourceforge.net/octave/?rev=8972&view=rev Author: jpicarbajal Date: 2011-11-03 23:53:42 +0000 (Thu, 03 Nov 2011) Log Message: ----------- geometry. almost released Modified Paths: -------------- trunk/octave-forge/main/geometry/PKG_ADD trunk/octave-forge/main/geometry/PKG_DEL trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m Added Paths: ----------- trunk/octave-forge/main/geometry/NEWS Removed Paths: ------------- trunk/octave-forge/main/geometry/doc/NEWS Copied: trunk/octave-forge/main/geometry/NEWS (from rev 8970, trunk/octave-forge/main/geometry/doc/NEWS) =================================================================== --- trunk/octave-forge/main/geometry/NEWS (rev 0) +++ trunk/octave-forge/main/geometry/NEWS 2011-11-03 23:53:42 UTC (rev 8972) @@ -0,0 +1,167 @@ +Summary of important user-visible changes for releases of the geometry package + +=============================================================================== +geometry-1.0.0 Release Date: 2011-09-26 Release Manager: Juan Pablo Carbajal +=============================================================================== + +** First official release. + +=============================================================================== +geometry-1.0.1 Release Date: 2011-09-27 Release Manager: Juan Pablo Carbajal +=============================================================================== + +Improvements to the docstrings of all functions. + +=============================================================================== +geometry-1.1 Release Date: 2011-10-04 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Starting to add geom2d from matGeom +angle2Points.m +angle3Points.m +angleAbsDiff.m +angleDiff.m +angles2d.m +angleSort.m +createLine.m +deg2rad.m +edgeAngle.m +lineAngle.m +normalizeAngle.m +rad2deg.m +vectorAngle.m + +=============================================================================== +geometry-1.1.1 Release Date: 2011-10-06 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Continue to add geom2d from matGeom (boxes and clips) + cbezier2poly.m + boxes2d.m + clipEdge.m + clipLine.m + clipPoints.m + drawBezierCurve.m + drawBox.m + clipRay.m + intersectBoxes.m + intersectLines.m + linePosition.m + mergeBoxes.m + randomPointInBox.m + drawLine.m + +=============================================================================== +geometry-1.1.2 Release Date: 2011-10-09 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Continue to add geom2d from matGeom (rays and vectors) + createRay.m + drawEdge.m + drawRay.m + isParallel.m + isPerpendicular.m + isPointOnRay.m + normalizeVector.m + rays2d.m + rotateVector.m + transformVector.m + vectorNorm.m + vectors2d.m + +=============================================================================== +geometry-1.1.3 Release Date: 2011-10-13 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Continue to add geom2d from matGeom (transforms and points2d) + createBasisTransform.m + createHomothecy.m + createLineReflection.m + createRotation.m + createScaling.m + createTranslation.m + transformPoint.m + transforms2d.m + fitAffineTransform2d.m + transformEdge.m + transformLine.m + centroid.m + distancePoints.m + midPoint.m + polarPoint.m + drawPoint.m + isCounterClockwise.m + minDistancePoints.m + pointOnLine.m + points2d.m + intersectLineEdge.m + isPointOnEdge.m + +=============================================================================== +geometry-1.2 Release Date: 2011-10-21 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* All geom2d added + createCircle.m + createDirectedCircle.m + createEdge.m + medianLine.m + Contents.m + bisector.m + cartesianLine.m + drawArrow.m + edges2d.m + lines2d.m + orthogonalLine.m + parallelLine.m + projPointOnLine.m + drawCenteredEdge.m + drawCircle.m + drawCircleArc.m + drawEllipse.m + drawEllipseArc.m + drawLabels.m + drawOrientedBox.m + drawParabola.m + drawRect.m + drawShape.m + circles2d.m + ellipses2d.m + createVector.m + inertiaEllipse.m + changelog.txt + readme.txt + hexagonalGrid.m + squareGrid.m + triangleGrid.m + intersectCircles.m + intersectEdges.m + intersectLineCircle.m + isLeftOriented.m + isPointInCircle.m + isPointInEllipse.m + isPointOnCircle.m + isPointOnLine.m + edgeLength.m + edgePosition.m + edgeToLine.m + circleArcAsCurve.m + circleAsPolygon.m + crackPattern.m + crackPattern2.m + distancePointEdge.m + distancePointLine.m + ellipseAsPolygon.m + enclosingCircle.m + radicalAxis.m + reverseEdge.m + reverseLine.m + +=============================================================================== +geometry-1.2.1 Release Date: 2011-11-02 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Adding SVG object and demo for data2geom (converting SVG to msh format) + +=============================================================================== + Modified: trunk/octave-forge/main/geometry/PKG_ADD =================================================================== --- trunk/octave-forge/main/geometry/PKG_ADD 2011-11-03 23:40:25 UTC (rev 8971) +++ trunk/octave-forge/main/geometry/PKG_ADD 2011-11-03 23:53:42 UTC (rev 8972) @@ -1,5 +1,5 @@ %1 -dirlist = {"geom2d","io","polygons2d"}; +dirlist = {"geom2d","io","polygons2d","shape2d"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); if (! exist (fullfile (dirname, "inst"), "dir")) Modified: trunk/octave-forge/main/geometry/PKG_DEL =================================================================== --- trunk/octave-forge/main/geometry/PKG_DEL 2011-11-03 23:40:25 UTC (rev 8971) +++ trunk/octave-forge/main/geometry/PKG_DEL 2011-11-03 23:53:42 UTC (rev 8972) @@ -1,5 +1,5 @@ %1 -dirlist = {"geom2d","io","polygons2d"}; +dirlist = {"geom2d","io","polygons2d","shape2d"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); if (! exist (fullfile (dirname, "inst"), "dir")) Deleted: trunk/octave-forge/main/geometry/doc/NEWS =================================================================== --- trunk/octave-forge/main/geometry/doc/NEWS 2011-11-03 23:40:25 UTC (rev 8971) +++ trunk/octave-forge/main/geometry/doc/NEWS 2011-11-03 23:53:42 UTC (rev 8972) @@ -1,167 +0,0 @@ -Summary of important user-visible changes for releases of the geometry package - -=============================================================================== -geometry-1.0.0 Release Date: 2011-09-26 Release Manager: Juan Pablo Carbajal -=============================================================================== - -** First official release. - -=============================================================================== -geometry-1.0.1 Release Date: 2011-09-27 Release Manager: Juan Pablo Carbajal -=============================================================================== - -Improvements to the docstrings of all functions. - -=============================================================================== -geometry-1.1 Release Date: 2011-10-04 Release Manager: Juan Pablo Carbajal -=============================================================================== - -* Starting to add geom2d from matGeom -angle2Points.m -angle3Points.m -angleAbsDiff.m -angleDiff.m -angles2d.m -angleSort.m -createLine.m -deg2rad.m -edgeAngle.m -lineAngle.m -normalizeAngle.m -rad2deg.m -vectorAngle.m - -=============================================================================== -geometry-1.1.1 Release Date: 2011-10-06 Release Manager: Juan Pablo Carbajal -=============================================================================== - -* Continue to add geom2d from matGeom (boxes and clips) - cbezier2poly.m - boxes2d.m - clipEdge.m - clipLine.m - clipPoints.m - drawBezierCurve.m - drawBox.m - clipRay.m - intersectBoxes.m - intersectLines.m - linePosition.m - mergeBoxes.m - randomPointInBox.m - drawLine.m - -=============================================================================== -geometry-1.1.2 Release Date: 2011-10-09 Release Manager: Juan Pablo Carbajal -=============================================================================== - -* Continue to add geom2d from matGeom (rays and vectors) - createRay.m - drawEdge.m - drawRay.m - isParallel.m - isPerpendicular.m - isPointOnRay.m - normalizeVector.m - rays2d.m - rotateVector.m - transformVector.m - vectorNorm.m - vectors2d.m - -=============================================================================== -geometry-1.1.3 Release Date: 2011-10-13 Release Manager: Juan Pablo Carbajal -=============================================================================== - -* Continue to add geom2d from matGeom (transforms and points2d) - createBasisTransform.m - createHomothecy.m - createLineReflection.m - createRotation.m - createScaling.m - createTranslation.m - transformPoint.m - transforms2d.m - fitAffineTransform2d.m - transformEdge.m - transformLine.m - centroid.m - distancePoints.m - midPoint.m - polarPoint.m - drawPoint.m - isCounterClockwise.m - minDistancePoints.m - pointOnLine.m - points2d.m - intersectLineEdge.m - isPointOnEdge.m - -=============================================================================== -geometry-1.2 Release Date: 2011-10-21 Release Manager: Juan Pablo Carbajal -=============================================================================== - -* All geom2d added - createCircle.m - createDirectedCircle.m - createEdge.m - medianLine.m - Contents.m - bisector.m - cartesianLine.m - drawArrow.m - edges2d.m - lines2d.m - orthogonalLine.m - parallelLine.m - projPointOnLine.m - drawCenteredEdge.m - drawCircle.m - drawCircleArc.m - drawEllipse.m - drawEllipseArc.m - drawLabels.m - drawOrientedBox.m - drawParabola.m - drawRect.m - drawShape.m - circles2d.m - ellipses2d.m - createVector.m - inertiaEllipse.m - changelog.txt - readme.txt - hexagonalGrid.m - squareGrid.m - triangleGrid.m - intersectCircles.m - intersectEdges.m - intersectLineCircle.m - isLeftOriented.m - isPointInCircle.m - isPointInEllipse.m - isPointOnCircle.m - isPointOnLine.m - edgeLength.m - edgePosition.m - edgeToLine.m - circleArcAsCurve.m - circleAsPolygon.m - crackPattern.m - crackPattern2.m - distancePointEdge.m - distancePointLine.m - ellipseAsPolygon.m - enclosingCircle.m - radicalAxis.m - reverseEdge.m - reverseLine.m - -=============================================================================== -geometry-1.2.1 Release Date: 2011-11-02 Release Manager: Juan Pablo Carbajal -=============================================================================== - -* Adding SVG object and demo for data2geom (converting SVG to msh format) - -=============================================================================== - Modified: trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m 2011-11-03 23:40:25 UTC (rev 8971) +++ trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m 2011-11-03 23:53:42 UTC (rev 8972) @@ -21,6 +21,7 @@ %% %% @seealso{shape2polygon} %% @end deftypefn + function polygonsimp = simplifypolygon (polygon) # Filter colinear points Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2011-11-03 23:40:25 UTC (rev 8971) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2011-11-03 23:53:42 UTC (rev 8972) @@ -21,11 +21,13 @@ %% containing a pair of polynomials. %% %% Format of @var{T} can be one of : +%% @example %% @group -%% [c] , [a b] , [a b c] or [a b c] -%% [f] [d e] [d e f] [d e f] -%% [0 0 1] +%% [c] , [a b] , [a b c] or [a b c] +%% [f] [d e] [d e f] [d e f] +%% [0 0 1] %% @end group +%% @end example %% %% @seealso{shape2polygon, shapeplot} %% @end deftypefn @@ -95,7 +97,7 @@ %! T = shapecentroid (shape)(:); %! shape = shapetransform (shape,-T + [2; 0]); %! -%! cla +%! close %! shapeplot (shape,10,'-r','linewidth',2) %! hold on %! for i = 1:9 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-04 00:11:39
|
Revision: 8973 http://octave.svn.sourceforge.net/octave/?rev=8973&view=rev Author: jpicarbajal Date: 2011-11-04 00:11:32 +0000 (Fri, 04 Nov 2011) Log Message: ----------- geometry. Details of CAPs files Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION trunk/octave-forge/main/geometry/NEWS Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2011-11-03 23:53:42 UTC (rev 8972) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2011-11-04 00:11:32 UTC (rev 8973) @@ -1,6 +1,6 @@ Name: Geometry Version: 1.2.2 -Date: 2011-11-9 +Date: 2011-11-4 Author: David Legland <dav...@gr...>, Juan Pablo Carbajal <car...@if...> Maintainer: Juan Pablo Carbajal <car...@if...> Title: Computational Geometry Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2011-11-03 23:53:42 UTC (rev 8972) +++ trunk/octave-forge/main/geometry/NEWS 2011-11-04 00:11:32 UTC (rev 8973) @@ -1,106 +1,31 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== -geometry-1.0.0 Release Date: 2011-09-26 Release Manager: Juan Pablo Carbajal +geometry-1.2.2 Release Date: 2011-11-04 Release Manager: Juan Pablo Carbajal =============================================================================== -** First official release. +* Improved SVG interface. Thanks to jwe and carandraug. +* Adding files to manipulate and convert 2D shapes defined with smooth + polynomials. -=============================================================================== -geometry-1.0.1 Release Date: 2011-09-27 Release Manager: Juan Pablo Carbajal -=============================================================================== + shape2polygon.m + shapearea.m + shapecentroid.m + shapeplot.m + shapetransform.m -Improvements to the docstrings of all functions. +* Inverted the order in the NEWS file. New entries are on top. =============================================================================== -geometry-1.1 Release Date: 2011-10-04 Release Manager: Juan Pablo Carbajal +geometry-1.2.1 Release Date: 2011-11-02 Release Manager: Juan Pablo Carbajal =============================================================================== -* Starting to add geom2d from matGeom -angle2Points.m -angle3Points.m -angleAbsDiff.m -angleDiff.m -angles2d.m -angleSort.m -createLine.m -deg2rad.m -edgeAngle.m -lineAngle.m -normalizeAngle.m -rad2deg.m -vectorAngle.m +* Adding SVG object and demo for data2geom (converting SVG to msh format) =============================================================================== -geometry-1.1.1 Release Date: 2011-10-06 Release Manager: Juan Pablo Carbajal +geometry-1.2.0 Release Date: 2011-10-21 Release Manager: Juan Pablo Carbajal =============================================================================== -* Continue to add geom2d from matGeom (boxes and clips) - cbezier2poly.m - boxes2d.m - clipEdge.m - clipLine.m - clipPoints.m - drawBezierCurve.m - drawBox.m - clipRay.m - intersectBoxes.m - intersectLines.m - linePosition.m - mergeBoxes.m - randomPointInBox.m - drawLine.m - -=============================================================================== -geometry-1.1.2 Release Date: 2011-10-09 Release Manager: Juan Pablo Carbajal -=============================================================================== - -* Continue to add geom2d from matGeom (rays and vectors) - createRay.m - drawEdge.m - drawRay.m - isParallel.m - isPerpendicular.m - isPointOnRay.m - normalizeVector.m - rays2d.m - rotateVector.m - transformVector.m - vectorNorm.m - vectors2d.m - -=============================================================================== -geometry-1.1.3 Release Date: 2011-10-13 Release Manager: Juan Pablo Carbajal -=============================================================================== - -* Continue to add geom2d from matGeom (transforms and points2d) - createBasisTransform.m - createHomothecy.m - createLineReflection.m - createRotation.m - createScaling.m - createTranslation.m - transformPoint.m - transforms2d.m - fitAffineTransform2d.m - transformEdge.m - transformLine.m - centroid.m - distancePoints.m - midPoint.m - polarPoint.m - drawPoint.m - isCounterClockwise.m - minDistancePoints.m - pointOnLine.m - points2d.m - intersectLineEdge.m - isPointOnEdge.m - -=============================================================================== -geometry-1.2 Release Date: 2011-10-21 Release Manager: Juan Pablo Carbajal -=============================================================================== - * All geom2d added createCircle.m createDirectedCircle.m @@ -158,10 +83,100 @@ reverseLine.m =============================================================================== -geometry-1.2.1 Release Date: 2011-11-02 Release Manager: Juan Pablo Carbajal +geometry-1.1.3 Release Date: 2011-10-13 Release Manager: Juan Pablo Carbajal =============================================================================== -* Adding SVG object and demo for data2geom (converting SVG to msh format) +* Continue to add geom2d from matGeom (transforms and points2d) + createBasisTransform.m + createHomothecy.m + createLineReflection.m + createRotation.m + createScaling.m + createTranslation.m + transformPoint.m + transforms2d.m + fitAffineTransform2d.m + transformEdge.m + transformLine.m + centroid.m + distancePoints.m + midPoint.m + polarPoint.m + drawPoint.m + isCounterClockwise.m + minDistancePoints.m + pointOnLine.m + points2d.m + intersectLineEdge.m + isPointOnEdge.m =============================================================================== +geometry-1.1.2 Release Date: 2011-10-09 Release Manager: Juan Pablo Carbajal +=============================================================================== +* Continue to add geom2d from matGeom (rays and vectors) + createRay.m + drawEdge.m + drawRay.m + isParallel.m + isPerpendicular.m + isPointOnRay.m + normalizeVector.m + rays2d.m + rotateVector.m + transformVector.m + vectorNorm.m + vectors2d.m + +=============================================================================== +geometry-1.1.1 Release Date: 2011-10-06 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Continue to add geom2d from matGeom (boxes and clips) + cbezier2poly.m + boxes2d.m + clipEdge.m + clipLine.m + clipPoints.m + drawBezierCurve.m + drawBox.m + clipRay.m + intersectBoxes.m + intersectLines.m + linePosition.m + mergeBoxes.m + randomPointInBox.m + drawLine.m + +=============================================================================== +geometry-1.1.0 Release Date: 2011-10-04 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Starting to add geom2d from matGeom + angle2Points.m + angle3Points.m + angleAbsDiff.m + angleDiff.m + angles2d.m + angleSort.m + createLine.m + deg2rad.m + edgeAngle.m + lineAngle.m + normalizeAngle.m + rad2deg.m + vectorAngle.m + +=============================================================================== +geometry-1.0.1 Release Date: 2011-09-27 Release Manager: Juan Pablo Carbajal +=============================================================================== + +Improvements to the docstrings of all functions. + +=============================================================================== +geometry-1.0.0 Release Date: 2011-09-26 Release Manager: Juan Pablo Carbajal +=============================================================================== + +** First official release. + +=============================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-04 18:41:10
|
Revision: 8980 http://octave.svn.sourceforge.net/octave/?rev=8980&view=rev Author: jpicarbajal Date: 2011-11-04 18:41:03 +0000 (Fri, 04 Nov 2011) Log Message: ----------- geometry. Improving docstrign of @svg/normalize Modified Paths: -------------- trunk/octave-forge/main/geometry/INDEX trunk/octave-forge/main/geometry/inst/io/@svg/normalize.m Modified: trunk/octave-forge/main/geometry/INDEX =================================================================== --- trunk/octave-forge/main/geometry/INDEX 2011-11-04 16:44:40 UTC (rev 8979) +++ trunk/octave-forge/main/geometry/INDEX 2011-11-04 18:41:03 UTC (rev 8980) @@ -116,13 +116,13 @@ cbezier2poly 2D Polygons drawPolygon - simplifypolygon.m + simplifypolygon 2D Piecewise polynomial shapes - polygon2shape.m - shape2polygon.m - shapecentroid.m - shapeplot.m - shapetransform.m + polygon2shape + shape2polygon + shapecentroid + shapeplot + shapetransform 2D Others bisector crackPattern2 Modified: trunk/octave-forge/main/geometry/inst/io/@svg/normalize.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/@svg/normalize.m 2011-11-04 16:44:40 UTC (rev 8979) +++ trunk/octave-forge/main/geometry/inst/io/@svg/normalize.m 2011-11-04 18:41:03 UTC (rev 8980) @@ -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 @@ -15,7 +15,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} @var{SVGn} = normalize (@var{SVG}) -%% TODO: normalizes and SVG. +%% normalizes and SVG. %% @end deftypefn function [SVGn bb] = normalize (obj) @@ -34,13 +34,13 @@ p = shape2polygon(obj.Path.(ids{ip}).data); bb = mergeBoxes(bb, [min(p) max(p)]([1 3 2 4])); end - + if npath > 1 v = mean(v)(:); else v = v.'; end - + %% check whether document and bounding box agree. bbHeight = bb(2)-bb(1); bbWidth = bb(4)-bb(2); @@ -66,7 +66,7 @@ for ip = 1:npath SVGn.Path.(ids{ip}).data = shapetransform(obj.Path.(ids{ip}).data,-v); - + % Put to middle SVGn.Path.(ids{ip}).data = ... shapetransform(SVGn.Path.(ids{ip}).data,[0; -bbHeight/2]); @@ -76,21 +76,20 @@ % Put to bottom SVGn.Path.(ids{ip}).data = ... shapetransform(SVGn.Path.(ids{ip}).data,[0; bbHeight/2]); - + % Scale SVGn.Path.(ids{ip}).data = ... shapetransform(SVGn.Path.(ids{ip}).data,S); - + p = shape2polygon(SVGn.Path.(ids{ip}).data); bb = mergeBoxes(bb, [min(p) max(p)]([1 3 2 4])); end bbHeight = bb(2)-bb(1); bbWidth = bb(4)-bb(2); - + SVGn.Data.height = bbHeight; SVGn.Data.width = bbWidth; SVGn.Data.normalized = true; end end - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-20 23:38:57
|
Revision: 9157 http://octave.svn.sourceforge.net/octave/?rev=9157&view=rev Author: jpicarbajal Date: 2011-11-20 23:38:51 +0000 (Sun, 20 Nov 2011) Log Message: ----------- geometry. fixing octclip strcuture Modified Paths: -------------- trunk/octave-forge/main/geometry/NEWS Added Paths: ----------- trunk/octave-forge/main/geometry/inst/octclip/oc_polybool.m Removed Paths: ------------- trunk/octave-forge/main/geometry/inst/octclip/inst/ Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2011-11-20 23:32:21 UTC (rev 9156) +++ trunk/octave-forge/main/geometry/NEWS 2011-11-20 23:38:51 UTC (rev 9157) @@ -5,6 +5,7 @@ =============================================================================== * Geometry merged with octCLIP. +* Geometry autoloads. =============================================================================== geometry-1.2.2 Release Date: 2011-11-04 Release Manager: Juan Pablo Carbajal Copied: trunk/octave-forge/main/geometry/inst/octclip/oc_polybool.m (from rev 9156, trunk/octave-forge/main/geometry/inst/octclip/inst/oc_polybool.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/octclip/oc_polybool.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/octclip/oc_polybool.m 2011-11-20 23:38:51 UTC (rev 9157) @@ -0,0 +1,264 @@ +## Copyright (C) 2011, José Luis García Pallero, <jgp...@gm...> +## +## This file is part of OctCLIP. +## +## OctCLIP 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 (at +## your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Function File}{[@var{X},@var{Y},@var{nPol},@var{nInt},@var{nPert}] =}_oc_polybool(@var{sub},@var{clip},@var{op}) +## @deftypefnx{Function File}{[@var{X},@var{Y},@var{nPol},@var{nInt},@var{nPert}] =}_oc_polybool(@var{sub},@var{clip}) +## +## This function performs boolean operations between two polygons using the +## Greiner-Hormann algorithm (http://davis.wpi.edu/~matt/courses/clipping/). +## +## @var{sub} is a two column matrix containing the X and Y coordinates of the +## vertices for the subject polygon. +## +## @var{clip} is a two column matrix containing the X and Y coordinates of the +## vertices for the clipper polygon. +## +## @var{op} is a text string containing the operation to perform between +## @var{sub} and @var{clip}. Possible values are: +## +## @itemize @bullet +## @item @var{'AND'} +## Intersection of @var{sub} and @var{clip} (value by default). +## @item @var{'OR'} +## Union of @var{subt} and @var{clip}. +## @item @var{'AB'} +## Operation @var{sub} - @var{clip}. +## @item @var{'BA'} +## Operation of @var{clip} - @var{sub}. +## @end itemize +## +## For the matrices @var{sub} and @var{clip}, the first point is not needed to +## be repeated at the end (but is permitted). Pairs of (NaN,NaN) coordinates in +## @var{sub} and/or @var{clip} are ommitted. +## +## @var{X} is a column vector containing the X coordinates of the vertices for. +## resultant polygon(s). +## +## @var{Y} is a column vector containing the Y coordinates of the vertices for. +## resultant polygon(s). +## +## @var{nPol} is the number of output polygons. +## +## @var{nInt} is the number of intersections between @var{sub} and @var{clip}. +## +## @var{nPert} is the number of perturbed points of the @var{clip} polygon in +## any particular case (points in the oborder of the other polygon) occurs see +## http://davis.wpi.edu/~matt/courses/clipping/ for details. +## @end deftypefn + + + + +function [X,Y,nPol,nInt,nPert] = oc_polybool(sub,clip,op) + +try + functionName = 'oc_polybool'; + minArg = 2; + maxArg = 3; + +%******************************************************************************* +%NUMBER OF INPUT ARGUMENTS CHECKING +%******************************************************************************* + + %number of input arguments checking + if (nargin<minArg)||(nargin>maxArg) + error(['Incorrect number of input arguments (%d)\n\t ',... + 'Correct number of input arguments = %d or %d'],... + nargin,minArg,maxArg); + end + %check if we omit the op argument + if nargin==minArg + %by default, use AND + op = 'AND'; + end + +%******************************************************************************* +%INPUT ARGUMENTS CHECKING +%******************************************************************************* + + %checking input arguments + [op] = checkInputArguments(sub,clip,op); +catch + %error message + error('\n\tIn function %s:\n\t -%s ',functionName,lasterr); +end + +%******************************************************************************* +%COMPUTATION +%******************************************************************************* + +try + %calling oct function + [X,Y,nPol,nInt,nPert] = _oc_polybool(sub,clip,op); +catch + %error message + error('\n\tIn function %s:\n\tIn function %s ',functionName,lasterr); +end + + + + +%******************************************************************************* +%AUXILIARY FUNCTION +%******************************************************************************* + + + + +function [outOp] = checkInputArguments(sub,clip,inOp) + +%sub must be matrix type +if ismatrix(sub) + %a dimensions + [rowSub,colSub] = size(sub); +else + error('The first input argument is not numeric'); +end +%clip must be matrix type +if ismatrix(clip) + %b dimensions + [rowClip,colClip] = size(clip); +else + error('The second input argument is not numeric'); +end +%checking dimensions +if (colSub~=2)||(colClip~=2) + error('The columns of input arguments must be 2'); +end +%operation must be a text string +if ~ischar(inOp) + error('The third input argument is not a text string'); +else + %upper case + outOp = toupper(inOp); + %check values + if (~strcmp(outOp,'AND'))&&(~strcmp(outOp,'OR'))&& ... + (~strcmp(outOp,'AB'))&&(~strcmp(outOp,'BA')) + error('The third input argument is not correct'); + end +end + + + + +%*****END OF FUNCIONS***** + + + + +%*****FUNCTION TESTS***** + + + + +%tests for input arguments +%!error(oc_polybool) +%!error(oc_polybool(1,2,3,4)) +%!error(oc_polybool('string',2,3)) +%!error(oc_polybool(1,'string',3)) +%!error(oc_polybool(1,2,3)) +%demo program +%!demo +%! %subject polygon +%! clSub = [9.0 7.5 +%! 9.0 3.0 +%! 2.0 3.0 +%! 2.0 4.0 +%! 8.0 4.0 +%! 8.0 5.0 +%! 2.0 5.0 +%! 2.0 6.0 +%! 8.0 6.0 +%! 8.0 7.0 +%! 2.0 7.0 +%! 2.0 7.5 +%! 9.0 7.5]; +%! %clipper polygon +%! clClip = [2.5 1.0 +%! 7.0 1.0 +%! 7.0 8.0 +%! 6.0 8.0 +%! 6.0 2.0 +%! 5.0 2.0 +%! 5.0 8.0 +%! 4.0 8.0 +%! 4.0 2.0 +%! 3.0 2.0 +%! 3.0 8.0 +%! 2.5 8.0 +%! 2.5 1.0]; +%! %limits for the plots +%! clXLim = [1.5 11.75]; +%! clYLim = [0.5 8.50]; +%! %compute intersection +%! [clXI,clYI] = oc_polybool(clSub,clClip,'and'); +%! %compute union +%! [clXU,clYU] = oc_polybool(clSub,clClip,'or'); +%! %compute A-B +%! [clXA,clYA] = oc_polybool(clSub,clClip,'ab'); +%! %compute B-A +%! [clXB,clYB] = oc_polybool(clSub,clClip,'ba'); +%! %plot window for intersection +%! subplot(2,2,1); +%! plot(clXI,clYI,'r.-','markersize',10,'linewidth',3,clSub(:,1),clSub(:,2),... +%! clClip(:,1),clClip(:,2)); +%! axis('equal'); +%! xlim(clXLim); +%! ylim(clYLim); +%! title('OctCLIP intersection'); +%! legend('Intersection','Subject polygon','Clipper polygon',... +%! 'location','southeast'); +%! %plot window for union +%! subplot(2,2,2); +%! plot(clXU,clYU,'r.-','markersize',10,'linewidth',3,clSub(:,1),clSub(:,2),... +%! clClip(:,1),clClip(:,2)); +%! axis('equal'); +%! xlim(clXLim); +%! ylim(clYLim); +%! title('OctCLIP union'); +%! legend('Union','Subject polygon','Clipper polygon','location','southeast'); +%! %plot window for A-B +%! subplot(2,2,3); +%! plot(clXA,clYA,'r.-','markersize',10,'linewidth',3,clSub(:,1),clSub(:,2),... +%! clClip(:,1),clClip(:,2)); +%! axis('equal'); +%! xlim(clXLim); +%! ylim(clYLim); +%! title('OctCLIP A-B'); +%! legend('A-B','Subject polygon','Clipper polygon','location','southeast'); +%! %plot window for B-A +%! subplot(2,2,4); +%! plot(clXB,clYB,'r.-','markersize',10,'linewidth',3,clSub(:,1),clSub(:,2),... +%! clClip(:,1),clClip(:,2)); +%! axis('equal'); +%! xlim(clXLim); +%! ylim(clYLim); +%! title('OctCLIP B-A'); +%! legend('B-A','Subject polygon','Clipper polygon','location','southeast'); +%! %input message +%! disp('Press ENTER to continue ...'); +%! pause(); +%! %kill and close the plot window +%! clf(); +%! close(); + + + + +%*****END OF TESTS***** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-20 23:49:20
|
Revision: 9158 http://octave.svn.sourceforge.net/octave/?rev=9158&view=rev Author: jpicarbajal Date: 2011-11-20 23:49:14 +0000 (Sun, 20 Nov 2011) Log Message: ----------- geometry. Adding pre_intall to manage compilation of octCLIP Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION Added Paths: ----------- trunk/octave-forge/main/geometry/pre_install.m Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2011-11-20 23:38:51 UTC (rev 9157) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2011-11-20 23:49:14 UTC (rev 9158) @@ -8,4 +8,4 @@ Depends: octave (>= 3.4.0) Autoload: yes License: GPL version 3 and BSD (see files) -Url: http://octave.sf.net, http://matgeom.sf.net +Url: http://octave.sf.net, http://matgeom.sf.net, http://davis.wpi.edu/~matt/courses/clipping/, https://bitbucket.org/jgpallero/octclip Added: trunk/octave-forge/main/geometry/pre_install.m =================================================================== --- trunk/octave-forge/main/geometry/pre_install.m (rev 0) +++ trunk/octave-forge/main/geometry/pre_install.m 2011-11-20 23:49:14 UTC (rev 9158) @@ -0,0 +1,23 @@ +function pre_install (desc) +%% Prepares for installation a package that is organized in subfolders + + %% List of folders with src subfolder + subfld = {"octclip"}; + + %% Create correct strings + subfld_ready = strcat({[pwd() filesep()]}, + subfld,[filesep() "src"]); + + %% Destination folder + to_fld = strcat(pwd,filesep ()); + + + %% Copy files to package/src folder + for from_fld = subfld_ready + %% TODO handle merging of Makefiles + warning("Multiple Makefiles not handled") + disp (["mv " from_fld{1} " " to_fld]) + %system (["mv " from_fld{1} " " to_fld]); + end + +end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-21 00:40:14
|
Revision: 9159 http://octave.svn.sourceforge.net/octave/?rev=9159&view=rev Author: jpicarbajal Date: 2011-11-21 00:40:08 +0000 (Mon, 21 Nov 2011) Log Message: ----------- geometry. Adding post installation function Modified Paths: -------------- trunk/octave-forge/main/geometry/pre_install.m Added Paths: ----------- trunk/octave-forge/main/geometry/post_install.m Added: trunk/octave-forge/main/geometry/post_install.m =================================================================== --- trunk/octave-forge/main/geometry/post_install.m (rev 0) +++ trunk/octave-forge/main/geometry/post_install.m 2011-11-21 00:40:08 UTC (rev 9159) @@ -0,0 +1,13 @@ +function post_install (desc) +%% Prepares for installation a package that is organized in subfolders +%% Since src is compiled only in the package main dir +%% I need to remove the PKG_ADD and PKG_DEL from the architecture dependent folder + + arch = cstrcat (octave_config_info ("canonical_host_type"), + "-", octave_config_info ("api_version")); + if exist (arch,"dir") + system(["ls " arch]) + pause + end + +end Modified: trunk/octave-forge/main/geometry/pre_install.m =================================================================== --- trunk/octave-forge/main/geometry/pre_install.m 2011-11-20 23:49:14 UTC (rev 9158) +++ trunk/octave-forge/main/geometry/pre_install.m 2011-11-21 00:40:08 UTC (rev 9159) @@ -5,19 +5,23 @@ subfld = {"octclip"}; %% Create correct strings - subfld_ready = strcat({[pwd() filesep()]}, - subfld,[filesep() "src"]); + subfld_ready = strcat ({[pwd() filesep() "inst" filesep()]}, + subfld,[filesep() "src" filesep() "*"]); %% Destination folder - to_fld = strcat(pwd,filesep ()); + to_fld = strcat (pwd (),[filesep() "src"]); %% Copy files to package/src folder - for from_fld = subfld_ready %% TODO handle merging of Makefiles - warning("Multiple Makefiles not handled") - disp (["mv " from_fld{1} " " to_fld]) - %system (["mv " from_fld{1} " " to_fld]); + warning ("Multiple Makefiles not handled") + if !exist("src","dir") + system(["mkdir " to_fld]); end + for from_fld = subfld_ready + system (["mv " from_fld{1} " " to_fld]); + system (["rm -R " from_fld{1}(1:end-2)]); + end + end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-21 01:08:45
|
Revision: 9160 http://octave.svn.sourceforge.net/octave/?rev=9160&view=rev Author: jpicarbajal Date: 2011-11-21 01:08:38 +0000 (Mon, 21 Nov 2011) Log Message: ----------- geometry. fixing compilation issue, but not satisfactorily Modified Paths: -------------- trunk/octave-forge/main/geometry/PKG_ADD trunk/octave-forge/main/geometry/PKG_DEL trunk/octave-forge/main/geometry/pre_install.m Removed Paths: ------------- trunk/octave-forge/main/geometry/post_install.m Modified: trunk/octave-forge/main/geometry/PKG_ADD =================================================================== --- trunk/octave-forge/main/geometry/PKG_ADD 2011-11-21 00:40:08 UTC (rev 9159) +++ trunk/octave-forge/main/geometry/PKG_ADD 2011-11-21 01:08:38 UTC (rev 9160) @@ -2,16 +2,23 @@ dirlist = {"geom2d","io","polygons2d","shape2d","octclip"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); -if (! exist (fullfile (dirname, "inst"), "dir")) - for ii=1:length (dirlist) - addpath ( [ dirname filesep dirlist{ii}],"-end") - endfor -else - warning("geometry:Devel","Adding path for testing."); - for ii=1:length(dirlist) - addpath ([ dirname "/inst/" dirlist{ii}]) - endfor -endif +%% If we are not in Architecture dependent folder +arch = cstrcat (octave_config_info ("canonical_host_type"), + "-", octave_config_info ("api_version")); +if !strcmp(arch , strsplit (fileparts(dbstack ()(1).file),filesep (), true){end}) + if (! exist (fullfile (dirname, "inst"), "dir")) + for ii=1:length (dirlist) + addpath ( [ dirname filesep dirlist{ii}],"-end") + endfor + else + warning("geometry:Devel","Adding path for testing."); + for ii=1:length(dirlist) + addpath ([ dirname "/inst/" dirlist{ii}]) + endfor + endif + +end + warning('off', 'Octave:fopen-file-in-path'); clear dirlist dirname Modified: trunk/octave-forge/main/geometry/PKG_DEL =================================================================== --- trunk/octave-forge/main/geometry/PKG_DEL 2011-11-21 00:40:08 UTC (rev 9159) +++ trunk/octave-forge/main/geometry/PKG_DEL 2011-11-21 01:08:38 UTC (rev 9160) @@ -2,16 +2,23 @@ dirlist = {"geom2d","io","polygons2d","shape2d","octclip"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); -if (! exist (fullfile (dirname, "inst"), "dir")) - for ii=1:length (dirlist) - ## Run this if the package is installed - rmpath ( [ dirname filesep dirlist{ii}]) - end -else - warning("geometry:Devel","Removing path for testing."); - for ii=1:length(dirlist) - rmpath ([ dirname "/inst/" dirlist{ii}]) - endfor -endif +%% If we are not in Architecture dependent folder +arch = cstrcat (octave_config_info ("canonical_host_type"), + "-", octave_config_info ("api_version")); +if !strcmp(arch , strsplit (fileparts(dbstack ()(1).file),filesep (), true){end}) + if (! exist (fullfile (dirname, "inst"), "dir")) + for ii=1:length (dirlist) + ## Run this if the package is installed + rmpath ( [ dirname filesep dirlist{ii}]) + end + else + warning("geometry:Devel","Removing path for testing."); + for ii=1:length(dirlist) + rmpath ([ dirname "/inst/" dirlist{ii}]) + endfor + endif + +end + clear dirlist dirname Deleted: trunk/octave-forge/main/geometry/post_install.m =================================================================== --- trunk/octave-forge/main/geometry/post_install.m 2011-11-21 00:40:08 UTC (rev 9159) +++ trunk/octave-forge/main/geometry/post_install.m 2011-11-21 01:08:38 UTC (rev 9160) @@ -1,13 +0,0 @@ -function post_install (desc) -%% Prepares for installation a package that is organized in subfolders -%% Since src is compiled only in the package main dir -%% I need to remove the PKG_ADD and PKG_DEL from the architecture dependent folder - - arch = cstrcat (octave_config_info ("canonical_host_type"), - "-", octave_config_info ("api_version")); - if exist (arch,"dir") - system(["ls " arch]) - pause - end - -end Modified: trunk/octave-forge/main/geometry/pre_install.m =================================================================== --- trunk/octave-forge/main/geometry/pre_install.m 2011-11-21 00:40:08 UTC (rev 9159) +++ trunk/octave-forge/main/geometry/pre_install.m 2011-11-21 01:08:38 UTC (rev 9160) @@ -14,7 +14,8 @@ %% Copy files to package/src folder %% TODO handle merging of Makefiles - warning ("Multiple Makefiles not handled") + warning ("Copying subfolder src to package main dir, but multiple Makefiles are not handled") + if !exist("src","dir") system(["mkdir " to_fld]); end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-21 01:27:34
|
Revision: 9161 http://octave.svn.sourceforge.net/octave/?rev=9161&view=rev Author: jpicarbajal Date: 2011-11-21 01:27:28 +0000 (Mon, 21 Nov 2011) Log Message: ----------- geometry. Simplifying hack in PKG* files Modified Paths: -------------- trunk/octave-forge/main/geometry/PKG_ADD trunk/octave-forge/main/geometry/PKG_DEL Modified: trunk/octave-forge/main/geometry/PKG_ADD =================================================================== --- trunk/octave-forge/main/geometry/PKG_ADD 2011-11-21 01:08:38 UTC (rev 9160) +++ trunk/octave-forge/main/geometry/PKG_ADD 2011-11-21 01:27:28 UTC (rev 9161) @@ -2,23 +2,24 @@ dirlist = {"geom2d","io","polygons2d","shape2d","octclip"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); -%% If we are not in Architecture dependent folder +%% If we are in Architecture dependent folder add from outside arch = cstrcat (octave_config_info ("canonical_host_type"), "-", octave_config_info ("api_version")); -if !strcmp(arch , strsplit (fileparts(dbstack ()(1).file),filesep (), true){end}) +pp = strsplit (dirname,filesep (), true); +if strcmp(arch , pp{end}) + dirname = [strcat(filesep(),{pp{1:end-1}}){:}]; +end - if (! exist (fullfile (dirname, "inst"), "dir")) - for ii=1:length (dirlist) - addpath ( [ dirname filesep dirlist{ii}],"-end") - endfor - else - warning("geometry:Devel","Adding path for testing."); - for ii=1:length(dirlist) - addpath ([ dirname "/inst/" dirlist{ii}]) - endfor - endif +if (! exist (fullfile (dirname, "inst"), "dir")) + for ii=1:length (dirlist) + addpath ( [ dirname filesep dirlist{ii}],"-end") + endfor +else + warning("geometry:Devel","Adding path for testing."); + for ii=1:length(dirlist) + addpath ([ dirname "/inst/" dirlist{ii}]) + endfor +endif -end - warning('off', 'Octave:fopen-file-in-path'); -clear dirlist dirname +clear dirlist dirname pp Modified: trunk/octave-forge/main/geometry/PKG_DEL =================================================================== --- trunk/octave-forge/main/geometry/PKG_DEL 2011-11-21 01:08:38 UTC (rev 9160) +++ trunk/octave-forge/main/geometry/PKG_DEL 2011-11-21 01:27:28 UTC (rev 9161) @@ -5,20 +5,21 @@ %% If we are not in Architecture dependent folder arch = cstrcat (octave_config_info ("canonical_host_type"), "-", octave_config_info ("api_version")); -if !strcmp(arch , strsplit (fileparts(dbstack ()(1).file),filesep (), true){end}) +pp = strsplit (dirname,filesep (), true); +if strcmp(arch , pp{end}) + dirname = [strcat(filesep(),{pp{1:end-1}}){:}]; +end - if (! exist (fullfile (dirname, "inst"), "dir")) - for ii=1:length (dirlist) - ## Run this if the package is installed - rmpath ( [ dirname filesep dirlist{ii}]) - end - else - warning("geometry:Devel","Removing path for testing."); - for ii=1:length(dirlist) - rmpath ([ dirname "/inst/" dirlist{ii}]) - endfor - endif +if (! exist (fullfile (dirname, "inst"), "dir")) + for ii=1:length (dirlist) + ## Run this if the package is installed + rmpath ( [ dirname filesep dirlist{ii}]) + end +else + warning("geometry:Devel","Removing path for testing."); + for ii=1:length(dirlist) + rmpath ([ dirname "/inst/" dirlist{ii}]) + endfor +endif -end - -clear dirlist dirname +clear dirlist dirname pp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-20 23:32:30
|
Revision: 9156 http://octave.svn.sourceforge.net/octave/?rev=9156&view=rev Author: jpicarbajal Date: 2011-11-20 23:32:21 +0000 (Sun, 20 Nov 2011) Log Message: ----------- geometry. Merging with octCLIP Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION trunk/octave-forge/main/geometry/INDEX trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/PKG_ADD trunk/octave-forge/main/geometry/PKG_DEL Added Paths: ----------- trunk/octave-forge/main/geometry/inst/octclip/ trunk/octave-forge/main/geometry/inst/octclip/inst/ trunk/octave-forge/main/geometry/inst/octclip/inst/oc_polybool.m trunk/octave-forge/main/geometry/inst/octclip/src/ trunk/octave-forge/main/geometry/inst/octclip/src/Makefile trunk/octave-forge/main/geometry/inst/octclip/src/_oc_polybool.cc trunk/octave-forge/main/geometry/inst/octclip/src/compilador.c trunk/octave-forge/main/geometry/inst/octclip/src/errores.c trunk/octave-forge/main/geometry/inst/octclip/src/eucli.c trunk/octave-forge/main/geometry/inst/octclip/src/fgeneral.c trunk/octave-forge/main/geometry/inst/octclip/src/greiner.c trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/ trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/compilador.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/constantes.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/errores.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/eucli.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/fgeneral.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/general.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/geom.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/greiner.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/polig.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/ptopol.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/segmento.h trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/ventorno.h trunk/octave-forge/main/geometry/inst/octclip/src/octclip.h trunk/octave-forge/main/geometry/inst/octclip/src/polig.c trunk/octave-forge/main/geometry/inst/octclip/src/ptopol.c trunk/octave-forge/main/geometry/inst/octclip/src/segmento.c trunk/octave-forge/main/geometry/inst/octclip/src/ventorno.c Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2011-11-20 23:09:21 UTC (rev 9155) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2011-11-20 23:32:21 UTC (rev 9156) @@ -1,11 +1,11 @@ Name: Geometry -Version: 1.2.2 -Date: 2011-11-4 -Author: David Legland <dav...@gr...>, Juan Pablo Carbajal <car...@if...> +Version: 1.3.0 +Date: 2011-11-24 +Author: David Legland <dav...@gr...>, José Luis García Pallero <jgp...@gm...>, Juan Pablo Carbajal <car...@if...> Maintainer: Juan Pablo Carbajal <car...@if...> Title: Computational Geometry Description: Library for geometric computing extending MatGeom functions. Useful to create, transform, manipulate and display geometric primitives. Depends: octave (>= 3.4.0) -Autoload: no +Autoload: yes License: GPL version 3 and BSD (see files) Url: http://octave.sf.net, http://matgeom.sf.net Modified: trunk/octave-forge/main/geometry/INDEX =================================================================== --- trunk/octave-forge/main/geometry/INDEX 2011-11-20 23:09:21 UTC (rev 9155) +++ trunk/octave-forge/main/geometry/INDEX 2011-11-20 23:32:21 UTC (rev 9156) @@ -117,6 +117,7 @@ 2D Polygons drawPolygon simplifypolygon + oc_polybool 2D Piecewise polynomial shapes polygon2shape shape2polygon Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2011-11-20 23:09:21 UTC (rev 9155) +++ trunk/octave-forge/main/geometry/NEWS 2011-11-20 23:32:21 UTC (rev 9156) @@ -1,6 +1,12 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== +geometry-1.3.0 Release Date: 2011-11-24 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Geometry merged with octCLIP. + +=============================================================================== geometry-1.2.2 Release Date: 2011-11-04 Release Manager: Juan Pablo Carbajal =============================================================================== Modified: trunk/octave-forge/main/geometry/PKG_ADD =================================================================== --- trunk/octave-forge/main/geometry/PKG_ADD 2011-11-20 23:09:21 UTC (rev 9155) +++ trunk/octave-forge/main/geometry/PKG_ADD 2011-11-20 23:32:21 UTC (rev 9156) @@ -1,5 +1,5 @@ %1 -dirlist = {"geom2d","io","polygons2d","shape2d"}; +dirlist = {"geom2d","io","polygons2d","shape2d","octclip"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); if (! exist (fullfile (dirname, "inst"), "dir")) Modified: trunk/octave-forge/main/geometry/PKG_DEL =================================================================== --- trunk/octave-forge/main/geometry/PKG_DEL 2011-11-20 23:09:21 UTC (rev 9155) +++ trunk/octave-forge/main/geometry/PKG_DEL 2011-11-20 23:32:21 UTC (rev 9156) @@ -1,5 +1,5 @@ %1 -dirlist = {"geom2d","io","polygons2d","shape2d"}; +dirlist = {"geom2d","io","polygons2d","shape2d","octclip"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); if (! exist (fullfile (dirname, "inst"), "dir")) Added: trunk/octave-forge/main/geometry/inst/octclip/inst/oc_polybool.m =================================================================== --- trunk/octave-forge/main/geometry/inst/octclip/inst/oc_polybool.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/octclip/inst/oc_polybool.m 2011-11-20 23:32:21 UTC (rev 9156) @@ -0,0 +1,264 @@ +## Copyright (C) 2011, José Luis García Pallero, <jgp...@gm...> +## +## This file is part of OctCLIP. +## +## OctCLIP 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 (at +## your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Function File}{[@var{X},@var{Y},@var{nPol},@var{nInt},@var{nPert}] =}_oc_polybool(@var{sub},@var{clip},@var{op}) +## @deftypefnx{Function File}{[@var{X},@var{Y},@var{nPol},@var{nInt},@var{nPert}] =}_oc_polybool(@var{sub},@var{clip}) +## +## This function performs boolean operations between two polygons using the +## Greiner-Hormann algorithm (http://davis.wpi.edu/~matt/courses/clipping/). +## +## @var{sub} is a two column matrix containing the X and Y coordinates of the +## vertices for the subject polygon. +## +## @var{clip} is a two column matrix containing the X and Y coordinates of the +## vertices for the clipper polygon. +## +## @var{op} is a text string containing the operation to perform between +## @var{sub} and @var{clip}. Possible values are: +## +## @itemize @bullet +## @item @var{'AND'} +## Intersection of @var{sub} and @var{clip} (value by default). +## @item @var{'OR'} +## Union of @var{subt} and @var{clip}. +## @item @var{'AB'} +## Operation @var{sub} - @var{clip}. +## @item @var{'BA'} +## Operation of @var{clip} - @var{sub}. +## @end itemize +## +## For the matrices @var{sub} and @var{clip}, the first point is not needed to +## be repeated at the end (but is permitted). Pairs of (NaN,NaN) coordinates in +## @var{sub} and/or @var{clip} are ommitted. +## +## @var{X} is a column vector containing the X coordinates of the vertices for. +## resultant polygon(s). +## +## @var{Y} is a column vector containing the Y coordinates of the vertices for. +## resultant polygon(s). +## +## @var{nPol} is the number of output polygons. +## +## @var{nInt} is the number of intersections between @var{sub} and @var{clip}. +## +## @var{nPert} is the number of perturbed points of the @var{clip} polygon in +## any particular case (points in the oborder of the other polygon) occurs see +## http://davis.wpi.edu/~matt/courses/clipping/ for details. +## @end deftypefn + + + + +function [X,Y,nPol,nInt,nPert] = oc_polybool(sub,clip,op) + +try + functionName = 'oc_polybool'; + minArg = 2; + maxArg = 3; + +%******************************************************************************* +%NUMBER OF INPUT ARGUMENTS CHECKING +%******************************************************************************* + + %number of input arguments checking + if (nargin<minArg)||(nargin>maxArg) + error(['Incorrect number of input arguments (%d)\n\t ',... + 'Correct number of input arguments = %d or %d'],... + nargin,minArg,maxArg); + end + %check if we omit the op argument + if nargin==minArg + %by default, use AND + op = 'AND'; + end + +%******************************************************************************* +%INPUT ARGUMENTS CHECKING +%******************************************************************************* + + %checking input arguments + [op] = checkInputArguments(sub,clip,op); +catch + %error message + error('\n\tIn function %s:\n\t -%s ',functionName,lasterr); +end + +%******************************************************************************* +%COMPUTATION +%******************************************************************************* + +try + %calling oct function + [X,Y,nPol,nInt,nPert] = _oc_polybool(sub,clip,op); +catch + %error message + error('\n\tIn function %s:\n\tIn function %s ',functionName,lasterr); +end + + + + +%******************************************************************************* +%AUXILIARY FUNCTION +%******************************************************************************* + + + + +function [outOp] = checkInputArguments(sub,clip,inOp) + +%sub must be matrix type +if ismatrix(sub) + %a dimensions + [rowSub,colSub] = size(sub); +else + error('The first input argument is not numeric'); +end +%clip must be matrix type +if ismatrix(clip) + %b dimensions + [rowClip,colClip] = size(clip); +else + error('The second input argument is not numeric'); +end +%checking dimensions +if (colSub~=2)||(colClip~=2) + error('The columns of input arguments must be 2'); +end +%operation must be a text string +if ~ischar(inOp) + error('The third input argument is not a text string'); +else + %upper case + outOp = toupper(inOp); + %check values + if (~strcmp(outOp,'AND'))&&(~strcmp(outOp,'OR'))&& ... + (~strcmp(outOp,'AB'))&&(~strcmp(outOp,'BA')) + error('The third input argument is not correct'); + end +end + + + + +%*****END OF FUNCIONS***** + + + + +%*****FUNCTION TESTS***** + + + + +%tests for input arguments +%!error(oc_polybool) +%!error(oc_polybool(1,2,3,4)) +%!error(oc_polybool('string',2,3)) +%!error(oc_polybool(1,'string',3)) +%!error(oc_polybool(1,2,3)) +%demo program +%!demo +%! %subject polygon +%! clSub = [9.0 7.5 +%! 9.0 3.0 +%! 2.0 3.0 +%! 2.0 4.0 +%! 8.0 4.0 +%! 8.0 5.0 +%! 2.0 5.0 +%! 2.0 6.0 +%! 8.0 6.0 +%! 8.0 7.0 +%! 2.0 7.0 +%! 2.0 7.5 +%! 9.0 7.5]; +%! %clipper polygon +%! clClip = [2.5 1.0 +%! 7.0 1.0 +%! 7.0 8.0 +%! 6.0 8.0 +%! 6.0 2.0 +%! 5.0 2.0 +%! 5.0 8.0 +%! 4.0 8.0 +%! 4.0 2.0 +%! 3.0 2.0 +%! 3.0 8.0 +%! 2.5 8.0 +%! 2.5 1.0]; +%! %limits for the plots +%! clXLim = [1.5 11.75]; +%! clYLim = [0.5 8.50]; +%! %compute intersection +%! [clXI,clYI] = oc_polybool(clSub,clClip,'and'); +%! %compute union +%! [clXU,clYU] = oc_polybool(clSub,clClip,'or'); +%! %compute A-B +%! [clXA,clYA] = oc_polybool(clSub,clClip,'ab'); +%! %compute B-A +%! [clXB,clYB] = oc_polybool(clSub,clClip,'ba'); +%! %plot window for intersection +%! subplot(2,2,1); +%! plot(clXI,clYI,'r.-','markersize',10,'linewidth',3,clSub(:,1),clSub(:,2),... +%! clClip(:,1),clClip(:,2)); +%! axis('equal'); +%! xlim(clXLim); +%! ylim(clYLim); +%! title('OctCLIP intersection'); +%! legend('Intersection','Subject polygon','Clipper polygon',... +%! 'location','southeast'); +%! %plot window for union +%! subplot(2,2,2); +%! plot(clXU,clYU,'r.-','markersize',10,'linewidth',3,clSub(:,1),clSub(:,2),... +%! clClip(:,1),clClip(:,2)); +%! axis('equal'); +%! xlim(clXLim); +%! ylim(clYLim); +%! title('OctCLIP union'); +%! legend('Union','Subject polygon','Clipper polygon','location','southeast'); +%! %plot window for A-B +%! subplot(2,2,3); +%! plot(clXA,clYA,'r.-','markersize',10,'linewidth',3,clSub(:,1),clSub(:,2),... +%! clClip(:,1),clClip(:,2)); +%! axis('equal'); +%! xlim(clXLim); +%! ylim(clYLim); +%! title('OctCLIP A-B'); +%! legend('A-B','Subject polygon','Clipper polygon','location','southeast'); +%! %plot window for B-A +%! subplot(2,2,4); +%! plot(clXB,clYB,'r.-','markersize',10,'linewidth',3,clSub(:,1),clSub(:,2),... +%! clClip(:,1),clClip(:,2)); +%! axis('equal'); +%! xlim(clXLim); +%! ylim(clYLim); +%! title('OctCLIP B-A'); +%! legend('B-A','Subject polygon','Clipper polygon','location','southeast'); +%! %input message +%! disp('Press ENTER to continue ...'); +%! pause(); +%! %kill and close the plot window +%! clf(); +%! close(); + + + + +%*****END OF TESTS***** Added: trunk/octave-forge/main/geometry/inst/octclip/src/Makefile =================================================================== --- trunk/octave-forge/main/geometry/inst/octclip/src/Makefile (rev 0) +++ trunk/octave-forge/main/geometry/inst/octclip/src/Makefile 2011-11-20 23:32:21 UTC (rev 9156) @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +CC=mkoctfile + +.PHONY: all +all: compile clean + +.PHONY: compile +compile: + $(CC) -c -Wall -Wextra -I. compilador.c -o compilador.o + $(CC) -c -Wall -Wextra -I. errores.c -o errores.o + $(CC) -c -Wall -Wextra -I. eucli.c -o eucli.o + $(CC) -c -Wall -Wextra -I. fgeneral.c -o fgeneral.o + $(CC) -c -Wall -Wextra -I. greiner.c -o greiner.o + $(CC) -c -Wall -Wextra -I. polig.c -o polig.o + $(CC) -c -Wall -Wextra -I. ptopol.c -o ptopol.o + $(CC) -c -Wall -Wextra -I. segmento.c -o segmento.o + $(CC) -c -Wall -Wextra -I. ventorno.c -o ventorno.o + $(CC) -s -Wall -Wextra -I. _oc_polybool.cc *.o + +.PHONY: clean +clean: + rm -rf *.o *~ Added: trunk/octave-forge/main/geometry/inst/octclip/src/_oc_polybool.cc =================================================================== --- trunk/octave-forge/main/geometry/inst/octclip/src/_oc_polybool.cc (rev 0) +++ trunk/octave-forge/main/geometry/inst/octclip/src/_oc_polybool.cc 2011-11-20 23:32:21 UTC (rev 9156) @@ -0,0 +1,240 @@ +/* -*- coding: utf-8 -*- */ +/* Copyright (C) 2011 José Luis García Pallero, <jgp...@gm...> + * + * This file is part of OctCLIP. + * + * OctCLIP 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 + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + */ +/******************************************************************************/ +/******************************************************************************/ +#define HELPTEXT "\ +-*- texinfo -*-\n\ +@deftypefn{Loadable Function}{[@var{X},@var{Y},@var{nPol},@var{nInt},\ +@var{nPert}] =}_oc_polybool(@var{sub},@var{clip},@var{op})\n\ +\n\ +@cindex Performs boolean operations between two polygons.\n\ +\n\ +This function performs boolean operations between two polygons using the\n\ +Greiner-Hormann algorithm (http://davis.wpi.edu/~matt/courses/clipping/).\n\ +\n\ +@var{sub} is a two column matrix containing the X and Y coordinates of the\n\ +vertices for the subject polygon.\n\n\ +@var{clip} is a two column matrix containing the X and Y coordinates of the\n\ +vertices for the clipper polygon.\n\n\ +@var{op} is a text string containing the operation to perform between\n\ +@var{sub} and @var{clip}. Possible values are:\n\ +\n\ +@itemize @bullet\n\ +@item @var{'AND'}\n\ +Intersection of @var{sub} and @var{clip}.\n\n\ +@item @var{'OR'}\n\ +Union of @var{subt} and @var{clip}.\n\n\ +@item @var{'AB'}\n\ +Operation @var{sub} - @var{clip}.\n\n\ +@item @var{'BA'}\n\ +Operation of @var{clip} - @var{sub}.\n\ +@end itemize\n\ +\n\ +For the matrices @var{sub} and @var{clip}, the first point is not needed to\n\ +be repeated at the end (but is permitted). Pairs of (NaN,NaN) coordinates in\n\ +@var{sub} and/or @var{clip} are ommitted.\n\ +\n\ +@var{X} is a column vector containing the X coordinates of the vertices for.\n\ +resultant polygon(s).\n\n\ +@var{Y} is a column vector containing the Y coordinates of the vertices for.\n\ +resultant polygon(s).\n\n\ +@var{nPol} is the number of output polygons.\n\n\ +@var{nInt} is the number of intersections between @var{sub} and @var{clip}.\n\n\ +@var{nPert} is the number of perturbed points of the @var{clip} polygon in\n\ +any particular case (points in the oborder of the other polygon) occurs see\n\ +http://davis.wpi.edu/~matt/courses/clipping/ for details.\n\ +\n\ +This function do not check if the dimensions of @var{sub} and @var{clip} are\n\ +correct.\n\ +\n\ +@end deftypefn" +/******************************************************************************/ +/******************************************************************************/ +#include<octave/oct.h> +#include<cstdio> +#include<cstring> +#include<cstdlib> +#include<cmath> +#include"octclip.h" +/******************************************************************************/ +/******************************************************************************/ +#define ERRORTEXT 1000 +/******************************************************************************/ +/******************************************************************************/ +DEFUN_DLD(_oc_polybool,args,,HELPTEXT) +{ + //error message + char errorText[ERRORTEXT+1]="_oc_polybool:\n\t"; + //output list + octave_value_list outputList; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //checking input arguments + if(args.length()!=3) + { + //error text + sprintf(&errorText[strlen(errorText)], + "Incorrect number of input arguments\n\t" + "See help _oc_polybool"); + //error message + error(errorText); + } + else + { + //loop index + size_t i=0; + //polygons and operation + ColumnVector xSubj=args(0).matrix_value().column(0); + ColumnVector ySubj=args(0).matrix_value().column(1); + ColumnVector xClip=args(1).matrix_value().column(0); + ColumnVector yClip=args(1).matrix_value().column(1); + std::string opchar=args(2).string_value(); + //computation vectors + double* xA=NULL; + double* yA=NULL; + double* xB=NULL; + double* yB=NULL; + //double linked lists + vertPoliClip* polA=NULL; + vertPoliClip* polB=NULL; + //operation identifier + enum GEOC_OP_BOOL_POLIG op=GeocOpBoolInter; + //output struct + poligGreiner* result=NULL; + //number of polygons, intersections and perturbations + size_t nPol=0,nInter=0,nPert=0; + //number of elements for the output vectors + size_t nElem=0; + //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + //pointers to data + xA = xSubj.fortran_vec(); + yA = ySubj.fortran_vec(); + xB = xClip.fortran_vec(); + yB = yClip.fortran_vec(); + //create double linked lists for subject and clipper polygons + polA = CreaPoliClip(xA,yA,static_cast<size_t>(xSubj.length()),1,1); + polB = CreaPoliClip(xB,yB,static_cast<size_t>(xClip.length()),1,1); + //error checking + if((polB==NULL)||(polB==NULL)) + { + //free peviously allocated memory + LibMemPoliClip(polA); + LibMemPoliClip(polB); + //error text + sprintf(&errorText[strlen(errorText)],"Error in memory allocation"); + //error message + error(errorText); + //exit + return outputList; + } + //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + //select operation + if((!strcmp(opchar.c_str(),"AND"))||(!strcmp(opchar.c_str(),"and"))) + { + op = GeocOpBoolInter; + } + else if((!strcmp(opchar.c_str(),"OR"))||(!strcmp(opchar.c_str(),"or"))) + { + op = GeocOpBoolUnion; + } + else if((!strcmp(opchar.c_str(),"AB"))||(!strcmp(opchar.c_str(),"ab"))) + { + op = GeocOpBoolAB; + } + else if((!strcmp(opchar.c_str(),"BA"))||(!strcmp(opchar.c_str(),"ba"))) + { + op = GeocOpBoolBA; + } + else + { + //free peviously allocated memory + LibMemPoliClip(polA); + LibMemPoliClip(polB); + //error text + sprintf(&errorText[strlen(errorText)], + "The third input argument (op=%s) is not correct", + opchar.c_str()); + //error message + error(errorText); + //exit + return outputList; + } + //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + //clipping + result = PoliBoolGreiner(polA,polB,op,GEOC_GREINER_FAC_EPS_PERTURB, + &nInter,&nPert); + //error checking + if(result==NULL) + { + //free peviously allocated memory + LibMemPoliClip(polA); + LibMemPoliClip(polB); + //error text + sprintf(&errorText[strlen(errorText)],"Error in memory allocation"); + //error message + error(errorText); + //exit + return outputList; + } + //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + //number or output polygons + nPol = result->nPolig; + //dimensions for the output vectors + if(nPol) + { + nElem = result->nElem; + } + else + { + nElem = 0; + } + //output vectors + ColumnVector xResult(nElem); + ColumnVector yResult(nElem); + //copy output data + for(i=0;i<nElem;i++) + { + xResult(i) = result->x[i]; + yResult(i) = result->y[i]; + } + //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + //output parameters list + outputList(0) = xResult; + outputList(1) = yResult; + outputList(2) = nPol; + outputList(3) = nInter; + outputList(4) = nPert; + //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + //free memory + LibMemPoliClip(polA); + LibMemPoliClip(polB); + LibMemPoligGreiner(result); + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //exit + return outputList; +} Added: trunk/octave-forge/main/geometry/inst/octclip/src/compilador.c =================================================================== --- trunk/octave-forge/main/geometry/inst/octclip/src/compilador.c (rev 0) +++ trunk/octave-forge/main/geometry/inst/octclip/src/compilador.c 2011-11-20 23:32:21 UTC (rev 9156) @@ -0,0 +1,75 @@ +/* -*- coding: utf-8 -*- */ +/** +\ingroup general geopot +@{ +\file compilador.c +\brief Definición de funciones para la detección de compiladores. +\author José Luis García Pallero, jgp...@gm... +\date 28 de abril de 2011 +\version 1.0 +\section Licencia Licencia +Copyright (c) 2011, José Luis García Pallero. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +- 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. +- Neither the name of the copyright holders nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +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 COPYRIGHT HOLDER 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. +*/ +/******************************************************************************/ +/******************************************************************************/ +#include"libgeoc/compilador.h" +/******************************************************************************/ +/******************************************************************************/ +int EsCompiladorGNU(int* noGnu) +{ + //variable de salida + int salida=0; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //inicializamos la variable noGnu, si ha lugar + if(noGnu!=NULL) + { + //inicializamos la variable a 0 + *noGnu = 0; + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //para que sea GCC, la constante __GNUC__ ha de estar definida +#if defined(__GNUC__) + //el compilador es GCC + salida = 1; + //comprobamos si es el compilador de intel +#if defined(__INTEL_COMPILER) + if(noGnu!=NULL) + { + //el compilador es de intel + *noGnu = 1; + } +#endif +#endif + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return salida; +} +/******************************************************************************/ +/******************************************************************************/ +/** @} */ Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/compilador.c ___________________________________________________________________ Added: svn:executable + * Added: trunk/octave-forge/main/geometry/inst/octclip/src/errores.c =================================================================== --- trunk/octave-forge/main/geometry/inst/octclip/src/errores.c (rev 0) +++ trunk/octave-forge/main/geometry/inst/octclip/src/errores.c 2011-11-20 23:32:21 UTC (rev 9156) @@ -0,0 +1,112 @@ +/* -*- coding: utf-8 -*- */ +/** +\ingroup anespec errores eop fichero general geodesia geom geopot gshhs marea +\ingroup matriz mmcc orden snx texto +@{ +\file errores.c +\brief Definición de funciones para el tratamiento de errores. + +En el momento de la compilación ha de seleccionarse el comportamiento de la +función \ref GeocError. Para realizar la selección es necesario definir las +variables para el preprocesador \em ESCRIBE_MENSAJE_ERROR si se quiere que la +función imprima un mensaje de error y/o \em FIN_PROGRAMA_ERROR si se quiere que +la función termine la ejecución del programa en curso. Si no se define ninguna +variable, la función no ejecuta ninguna acción. En \p gcc, las variables para el +preprocesador se pasan como \em -DXXX, donde \em XXX es la variable a +introducir. +\author José Luis García Pallero, jgp...@gm... +\date 09 de enero de 2011 +\section Licencia Licencia +Copyright (c) 2009-2011, José Luis García Pallero. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +- 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. +- Neither the name of the copyright holders nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +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 COPYRIGHT HOLDER 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. +*/ +/******************************************************************************/ +/******************************************************************************/ +#include"libgeoc/errores.h" +/******************************************************************************/ +/******************************************************************************/ +int GeocTipoError(void) +{ + //variable de salida + int valor=GEOC_TIPO_ERR_NADA; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //distinguimos los posibles casos según las variables del preprocesador +#if defined(ESCRIBE_MENSAJE_ERROR) && defined(FIN_PROGRAMA_ERROR) + //mensaje de error y terminación del programa + valor = GEOC_TIPO_ERR_MENS_Y_EXIT; +#elif defined(ESCRIBE_MENSAJE_ERROR) + //mensaje de error + valor = GEOC_TIPO_ERR_MENS; +#elif defined(FIN_PROGRAMA_ERROR) + //terminación del programa + valor = GEOC_TIPO_ERR_EXIT; +#endif + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return valor; +} +/******************************************************************************/ +/******************************************************************************/ +void GeocError(const char mensaje[], + const char funcion[]) +{ + //hacemos una copia para que en la compilación no dé warning si sólo se + //termina la ejecución del programa o no se hace nada + mensaje = mensaje; + funcion = funcion; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //distinguimos los posibles casos según las variables del preprocesador +#if defined(ESCRIBE_MENSAJE_ERROR) && defined(FIN_PROGRAMA_ERROR) + //imprimimos el nombre de la función y el mensaje + fprintf(stderr,"En la función '%s'\n",funcion); + fprintf(stderr,"%s\n",mensaje); + //indicamos que el programa finalizará + fprintf(stderr,"El programa finalizará mediante la llamada a la función " + "'exit(EXIT_FAILURE)'\n"); + //detenemos la ejecución del programa + exit(EXIT_FAILURE); +#elif defined(ESCRIBE_MENSAJE_ERROR) + //imprimimos el nombre de la función y el mensaje + fprintf(stderr,"En la función '%s'\n",funcion); + fprintf(stderr,"%s\n",mensaje); + //salimos de la función + return; +#elif defined(FIN_PROGRAMA_ERROR) + //indicamos que el programa finalizará + fprintf(stderr,"El programa finalizará mediante la llamada a la función " + "'exit(EXIT_FAILURE)'\n"); + //detenemos la ejecución del programa + exit(EXIT_FAILURE); +#else + //salimos de la función + return; +#endif +} +/******************************************************************************/ +/******************************************************************************/ +/** @} */ Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/errores.c ___________________________________________________________________ Added: svn:executable + * Added: trunk/octave-forge/main/geometry/inst/octclip/src/eucli.c =================================================================== --- trunk/octave-forge/main/geometry/inst/octclip/src/eucli.c (rev 0) +++ trunk/octave-forge/main/geometry/inst/octclip/src/eucli.c 2011-11-20 23:32:21 UTC (rev 9156) @@ -0,0 +1,160 @@ +/* -*- coding: utf-8 -*- */ +/** +\ingroup geom interp +@{ +\file eucli.c +\brief Definición de funciones para la realización de cálculos de geometría + euclídea. +\author José Luis García Pallero, jgp...@gm... +\date 27 de octubre de 2009 +\section Licencia Licencia +Copyright (c) 2009-2010, José Luis García Pallero. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +- 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. +- Neither the name of the copyright holders nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +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 COPYRIGHT HOLDER 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. +*/ +/******************************************************************************/ +/******************************************************************************/ +#include"libgeoc/eucli.h" +/******************************************************************************/ +/******************************************************************************/ +double Dist2D(const double x1, + const double y1, + const double x2, + const double y2) +{ + //calculamos y salimos de la función + return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); +} +/******************************************************************************/ +/******************************************************************************/ +void Dist2DVC(const double x1, + const double y1, + const double x2, + const double y2, + const double varx1, + const double varx1y1, + const double vary1, + const double varx2, + const double varx2y2, + const double vary2, + double* dist, + double* varDist) +{ + //matrices auxiliares + double j[4],jvc[4]; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //calculamos la distancia + *dist = Dist2D(x1,y1,x2,y2); + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //rellenamos la matriz jacobiana + j[0] = -(x2-x1)/(*dist); + j[1] = -(y2-y1)/(*dist); + j[2] = -j[0]; + j[3] = -j[1]; + //producto de la matriz jacobiana por la matriz de varianza-covarianza + jvc[0] = j[0]*varx1+j[1]*varx1y1; + jvc[1] = j[0]*varx1y1+j[1]*vary1; + jvc[2] = j[2]*varx2+j[3]*varx2y2; + jvc[3] = j[2]*varx2y2+j[3]*vary2; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //realizamos la propagación de errores + *varDist = jvc[0]*j[0]+jvc[1]*j[1]+jvc[2]*j[2]+jvc[3]*j[3]; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return; +} +/******************************************************************************/ +/******************************************************************************/ +double Dist3D(const double x1, + const double y1, + const double z1, + const double x2, + const double y2, + const double z2) +{ + //calculamos y salimos de la función + return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)); +} +/******************************************************************************/ +/******************************************************************************/ +void Dist3DVC(const double x1, + const double y1, + const double z1, + const double x2, + const double y2, + const double z2, + const double varx1, + const double varx1y1, + const double varx1z1, + const double vary1, + const double vary1z1, + const double varz1, + const double varx2, + const double varx2y2, + const double varx2z2, + const double vary2, + const double vary2z2, + const double varz2, + double* dist, + double* varDist) +{ + //matrices auxiliares + double j[6],jvc[6]; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //calculamos la distancia + *dist = Dist3D(x1,y1,z1,x2,y2,z2); + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //rellenamos la matriz jacobiana + j[0] = -(x2-x1)/(*dist); + j[1] = -(y2-y1)/(*dist); + j[2] = -(z2-z1)/(*dist); + j[3] = -j[0]; + j[4] = -j[1]; + j[5] = -j[2]; + //producto de la matriz jacobiana por la matriz de varianza-covarianza + jvc[0] = j[0]*varx1+j[1]*varx1y1+j[2]*varx1z1; + jvc[1] = j[0]*varx1y1+j[1]*vary1+j[2]*vary1z1; + jvc[2] = j[0]*varx1z1+j[1]*vary1z1+j[2]*varz1; + jvc[3] = j[3]*varx2+j[4]*varx2y2+j[5]*varx2z2; + jvc[4] = j[3]*varx2y2+j[4]*vary2+j[5]*vary2z2; + jvc[5] = j[3]*varx2z2+j[4]*vary2z2+j[5]*varz2; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //realizamos la propagación de errores + *varDist = jvc[0]*j[0]+jvc[1]*j[1]+jvc[2]*j[2]+jvc[3]*j[3]+jvc[4]*j[4]+ + jvc[5]*j[5]; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return; +} +/******************************************************************************/ +/******************************************************************************/ +/** @} */ Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/eucli.c ___________________________________________________________________ Added: svn:executable + * Added: trunk/octave-forge/main/geometry/inst/octclip/src/fgeneral.c =================================================================== --- trunk/octave-forge/main/geometry/inst/octclip/src/fgeneral.c (rev 0) +++ trunk/octave-forge/main/geometry/inst/octclip/src/fgeneral.c 2011-11-20 23:32:21 UTC (rev 9156) @@ -0,0 +1,500 @@ +/* -*- coding: utf-8 -*- */ +/** +\ingroup eop general geom geopot matriz +@{ +\file fgeneral.c +\brief Definición de funciones de utilidad general. +\author José Luis García Pallero, jgp...@gm... +\date 10 de octubre de 2009 +\version 1.0 +\section Licencia Licencia +Copyright (c) 2009-2011, José Luis García Pallero. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +- 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. +- Neither the name of the copyright holders nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +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 COPYRIGHT HOLDER 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. +*/ +/******************************************************************************/ +/******************************************************************************/ +#include"libgeoc/fgeneral.h" +/******************************************************************************/ +/******************************************************************************/ +void BuscaSegmento1DInc(const double valor, + const double* lista, + const size_t nDatos, + const size_t incDatos, + size_t* posInicio, + size_t* posFin) +{ + //variable para recorrer bucles + size_t i=0; + //variable indicadora de búsqueda secuencial + int busca=0; + //variables para calcular posiciones + size_t pos1=0,pos2=0; + //posiciones en memoria + size_t posm=0,pos1m=0,pos2m=0; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //CONSIDERAMOS QUE LA LISTA CONTIENE ENTEROS EQUIESPACIADOS UNA UNIDAD + //posición del valor anterior al de trabajo + pos1 = (size_t)(floor(valor)-lista[0]); + //posición del valor posterior al de trabajo + pos2 = (size_t)(ceil(valor)-lista[0]); + //si pos1==pos2, valor puede ser un extremo de la lista + if(pos1==pos2) + { + if(pos1!=(nDatos-1)) + { + //calculamos el punto final del segmento + pos2++; + } + else + { + //calculamos el punto inicial del segmento + pos1--; + } + } + //calculamos las posiciones en memoria + pos1m = pos1*incDatos; + pos2m = pos2*incDatos; + //comprobamos si el segmento detectado es válido + if((lista[pos1m]!=round(lista[pos1m]))|| + (lista[pos2m]!=round(lista[pos2m]))|| + ((lista[pos2m]-lista[pos1m])!=1.0)|| + (valor<lista[pos1m])||(valor>lista[pos2m])) + { + //indicamos que se ha de hacer una búsqueda secuencial + busca = 1; + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //LA LISTA CONTIENE REALES NO EQUIESPACIADOS + if(busca) + { + //recorremos todos los elementos de la lista + for(i=0;i<nDatos;i++) + { + //posición en memoria + posm = i*incDatos; + //comprobamos si estamos ante un límite + if(lista[posm]>=valor) + { + //comprobamos el tipo de límite + if(lista[posm]>valor) + { + //extraemos las posiciones + pos1 = i-1; + pos2 = i; + } + else + { + //comprobamos si estamos trabajando con el último elemento + if(i==(nDatos-1)) + { + //extraemos las posiciones + pos1 = i-1; + pos2 = i; + } + else + { + //extraemos las posiciones + pos1 = i; + pos2 = i+1; + } + } + //salimos del bucle + break; + } + } + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //asignamos las variables de salida + *posInicio = pos1; + *posFin = pos2; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return; +} +/******************************************************************************/ +/******************************************************************************/ +void BuscaSegmento1D(const double valor, + const double* lista, + const size_t nDatos, + size_t* posInicio, + size_t* posFin) +{ + //realizamos la búsqueda con incremento igual a 1 + BuscaSegmento1DInc(valor,lista,nDatos,1,posInicio,posFin); +} +/******************************************************************************/ +/******************************************************************************/ +void BuscaPosNWEnMalla(const double xPto, + const double yPto, + const double xMin, + const double xMax, + const double yMin, + const double yMax, + const double pasoX, + const double pasoY, + size_t* fil, + size_t* col) +{ + //dimensiones de la matriz + size_t f=0,c=0; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //calculamos las dimensiones de la matriz de trabajo + f = (size_t)(round((yMax-yMin)/pasoY)+1.0); + c = (size_t)(round((xMax-xMin)/pasoX)+1.0); + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //calculamos la fila y comprobamos si es el extremo S + *fil = f-1-(size_t)((yPto-yMin)/pasoY); + if(*fil==(f-1)) + { + //retrasamos una fila + (*fil)--; + } + //calculamos la columna y comprobamos si es el extremo E + *col = (size_t)((xPto-xMin)/pasoX); + if(*col==(c-1)) + { + //retrasamos una columna + (*col)--; + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return; +} +/******************************************************************************/ +/******************************************************************************/ +void MinMax(const double* lista, + const size_t nDatos, + size_t* posMin, + size_t* posMax) +{ + //índice para recorrer bucles + size_t i=0; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //consideramos que el primer elemento es el mayor y el menor + *posMin = 0; + *posMax = 0; + //recorremos el resto de elementos de la lista + for(i=1;i<nDatos;i++) + { + //comprobamos si el elemento actual es menor que el considerado menor + if(lista[i]<lista[*posMin]) + { + //asignamos la nueva posición + *posMin = i; + } + //comprobamos si el elemento actual es mayor que el considerado mayor + if(lista[i]>lista[*posMax]) + { + //asignamos la nueva posición + *posMax = i; + } + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return; +} +/******************************************************************************/ +/******************************************************************************/ +void MinMaxAbs(const double* lista, + const size_t nDatos, + size_t* posMin, + size_t* posMax) +{ + //índice para recorrer bucles + size_t i=0; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //consideramos que el primer elemento es el mayor y el menor + *posMin = 0; + *posMax = 0; + //recorremos el resto de elementos de la lista + for(i=1;i<nDatos;i++) + { + //comprobamos si el elemento actual es menor que el considerado menor + if(fabs(lista[i])<fabs(lista[*posMin])) + { + //asignamos la nueva posición + *posMin = i; + } + //comprobamos si el elemento actual es mayor que el considerado mayor + if(fabs(lista[i])>fabs(lista[*posMax])) + { + //asignamos la nueva posición + *posMax = i; + } + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return; +} +/******************************************************************************/ +/******************************************************************************/ +void MinMaxSizeT(const size_t* lista, + const size_t nDatos, + size_t* posMin, + size_t* posMax) +{ + //índice para recorrer bucles + size_t i=0; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //consideramos que el primer elemento es el mayor y el menor + *posMin = 0; + *posMax = 0; + //recorremos el resto de elementos de la lista + for(i=1;i<nDatos;i++) + { + //comprobamos si el elemento actual es menor que el considerado menor + if(lista[i]<lista[*posMin]) + { + //asignamos la nueva posición + *posMin = i; + } + //comprobamos si el elemento actual es mayor que el considerado mayor + if(lista[i]>lista[*posMax]) + { + //asignamos la nueva posición + *posMax = i; + } + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return; +} +/******************************************************************************/ +/******************************************************************************/ +double** AsigMemMatrizC(const size_t fil, + const size_t col) +{ + //índices para recorrer bucles + size_t i=0; + //matriz de salida + double** matriz=NULL; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //asignamos memoria para el array principal + matriz = (double**)malloc(fil*sizeof(double*)); + //comprobamos los errores + if(matriz==NULL) + { + //mensaje de error + GEOC_ERROR("Error de asignación de memoria"); + //salimos de la función + return NULL; + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //asignamos toda la memoria al primer puntero + matriz[0] = (double*)malloc(fil*col*sizeof(double)); + //comprobamos los errores + if(matriz[0]==NULL) + { + //liberamos la memoria previamente asignada + free(matriz); + //mensaje de error + GEOC_ERROR("Error de asignación de memoria"); + //salimos de la función + return NULL; + } + //recorremos el resto de filas + for(i=1;i<fil;i++) + { + //vamos asignando las direcciones de inicio de cada fila + matriz[i] = &matriz[0][i*col]; + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return matriz; +} +/******************************************************************************/ +/******************************************************************************/ +void LibMemMatrizC(double** matriz) +{ + //sólo trabajamos si hay memoria asignada + if(matriz!=NULL) + { + //sólo trabajamos si hay memoria asignada + if(matriz[0]!=NULL) + { + //liberamos la memoria de los datos + free(matriz[0]); + } + //liberamos la memoria del array principal + free(matriz); + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //salimos de la función + return; +} +/******************************************************************************/ +/******************************************************************************/ +double GeocNan(void) +{ + //devolvemos el valor de NaN + //le calculamos el valor absoluto porque, en algunos sistemas, al imprimir + //un valor GEOC_NAN normal, éste sale con un signo negativo delante + return fabs(GEOC_NAN); +} +/******************************************************************************/ +/******************************************************************************/ +int EsGeocNan(const double valor) +{ + //comparamos y salimos de la función + return valor!=valor; +} +/******************************************************************************/ +/******************************************************************************/ +size_t* PosRepeEnVector(const double* datos, + const size_t nDatos, + const size_t incDatos, + size_t* nRepe) +{ + //índice para recorrer bucles + size_t i=0; + //número de repeticiones encontradas + size_t numRep=0; + //datos de las posiciones de trabajo + double dato=0.0,datoTrab=0.0; + //variable de salida + size_t* pos=NULL; + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //asignamos memoria para el vector de salida + pos = (size_t*)malloc(nDatos*sizeof(double)); + //comprobamos los posibles errores + if(pos==NULL) + { + //mensaje de error + GEOC_ERROR("Error de asignación de memoria"); + //salimos de la función + return NULL; + } + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //inicializamos la primera posición, extraemos el dato e inicializamos el + //contador de repeticiones + pos[0] = 0; + dato = datos[0]; + numRep = 1; + //recorremos el resto de elementos del vector + for(i=1;i<nDatos;i++) + { + //extraemos el dato de trabajo + datoTrab = datos[i*incDatos]; + //lo comparamos con el dato de referencia + if(datoTrab!=dato) + { + //asignamos la nueva posición + pos[numRep] = i; + //aumentamos el contador de repeticiones + numRep++; + //convertimos el nuevo dato en dato de referencia + dato = datoTrab; + } + } + //////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////... [truncated message content] |
From: <jpi...@us...> - 2012-01-25 10:33:30
|
Revision: 9564 http://octave.svn.sourceforge.net/octave/?rev=9564&view=rev Author: jpicarbajal Date: 2012-01-25 10:33:20 +0000 (Wed, 25 Jan 2012) Log Message: ----------- geometry: Adding basic graph tools Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION trunk/octave-forge/main/geometry/INDEX trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/PKG_ADD trunk/octave-forge/main/geometry/PKG_DEL Added Paths: ----------- trunk/octave-forge/main/geometry/inst/graphs/ trunk/octave-forge/main/geometry/inst/graphs/delaunayGraph.m trunk/octave-forge/main/geometry/inst/graphs/drawGraph.m trunk/octave-forge/main/geometry/inst/graphs/knnGraph.m trunk/octave-forge/main/geometry/inst/graphs/voronoi2d.m Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2012-01-24 21:37:54 UTC (rev 9563) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2012-01-25 10:33:20 UTC (rev 9564) @@ -1,6 +1,6 @@ Name: Geometry Version: 1.3.0 -Date: 2011-11-24 +Date: 2012-01-25 Author: David Legland <dav...@gr...>, José Luis García Pallero <jgp...@gm...>, Juan Pablo Carbajal <car...@if...> Maintainer: Juan Pablo Carbajal <car...@if...> Title: Computational Geometry Modified: trunk/octave-forge/main/geometry/INDEX =================================================================== --- trunk/octave-forge/main/geometry/INDEX 2012-01-24 21:37:54 UTC (rev 9563) +++ trunk/octave-forge/main/geometry/INDEX 2012-01-25 10:33:20 UTC (rev 9564) @@ -136,6 +136,8 @@ isCounterClockwise squareGrid triangleGrid +Geometric graphs + Input svgload svgnormalize Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-01-24 21:37:54 UTC (rev 9563) +++ trunk/octave-forge/main/geometry/NEWS 2012-01-25 10:33:20 UTC (rev 9564) @@ -1,6 +1,13 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== +geometry-1.4.0 Release Date: 2012-01-25 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Added basic geometric graphs creation and manipulation. + + +=============================================================================== geometry-1.3.0 Release Date: 2011-11-24 Release Manager: Juan Pablo Carbajal =============================================================================== Modified: trunk/octave-forge/main/geometry/PKG_ADD =================================================================== --- trunk/octave-forge/main/geometry/PKG_ADD 2012-01-24 21:37:54 UTC (rev 9563) +++ trunk/octave-forge/main/geometry/PKG_ADD 2012-01-25 10:33:20 UTC (rev 9564) @@ -1,5 +1,5 @@ %1 -dirlist = {"geom2d","io","polygons2d","shape2d","octclip"}; +dirlist = {"geom2d","io","polygons2d","shape2d","octclip", "graphs"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); %% If we are in Architecture dependent folder add from outside Modified: trunk/octave-forge/main/geometry/PKG_DEL =================================================================== --- trunk/octave-forge/main/geometry/PKG_DEL 2012-01-24 21:37:54 UTC (rev 9563) +++ trunk/octave-forge/main/geometry/PKG_DEL 2012-01-25 10:33:20 UTC (rev 9564) @@ -1,5 +1,5 @@ %1 -dirlist = {"geom2d","io","polygons2d","shape2d","octclip"}; +dirlist = {"geom2d","io","polygons2d","shape2d","octclip","graphs"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); %% If we are not in Architecture dependent folder Added: trunk/octave-forge/main/geometry/inst/graphs/delaunayGraph.m =================================================================== --- trunk/octave-forge/main/geometry/inst/graphs/delaunayGraph.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/graphs/delaunayGraph.m 2012-01-25 10:33:20 UTC (rev 9564) @@ -0,0 +1,91 @@ +%% Copyright (C) 2011-2012 David Legland <dav...@gr...> +%% 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. +%% +%% 2012 Adapted to Octave by Juan Pablo Carbajal <car...@if...> + +%% -*- texinfo -*- +%% @deftypefn {Function File} {[@var{points} @var{edges}]= } delaunayGraph (@var{points}) +%% Graph associated to Delaunay triangulation of input points +%% +%% Compute the Delaunay triangulation of the set of input points, and +%% convert to a set of edges. The output NODES is the same as the input +%% POINTS. +%% +%% Example +%% @example +%% +%% % Draw a planar graph correpspionding to Delaunay triangulation +%% points = rand(30, 2) * 100; +%% [nodes edges] = delaunayGraph(points); +%% figure; +%% drawGraph(nodes, edges); +%% +%% % Draw a 3Dgraph corresponding to Delaunay tetrahedrisation +%% points = rand(20, 3) * 100; +%% [nodes edges] = delaunayGraph(points); +%% figure; +%% drawGraph(nodes, edges); +%% view(3); +%% +%% @end example +%% +%% @seealso{delaunay, delaunayn} +%% @end deftypefn + +function [points edges] = delaunayGraph(points, varargin) + % compute triangulation + tri = delaunayn(points, varargin{:}); + + % number of simplices (triangles), and of vertices by simplex (3 in 2D) + nt = size(tri, 1); + nv = size(tri, 2); + + % allocate memory + edges = zeros(nt * nv, 2); + + % compute edges of each simplex + for i = 1:nv-1 + edges((1:nt) + (i-1)*nt, :) = sort([tri(:, i) tri(:, i+1)], 2); + end + edges((1:nt) + (nv-1)*nt, :) = sort([tri(:, end) tri(:, 1)], 2); + + % remove multiple edges + edges = unique(edges, 'rows'); + +endfunction + +%!demo +%! % Draw a planar graph correpspionding to Delaunay triangulation +%! points = rand(30, 2) * 100; +%! [nodes edges] = delaunayGraph(points); +%! figure; +%! drawGraph(nodes, edges); + +%!demo +%! % WARNING 3d pltottig works correctly in Octave >= 3.6 +%! % Draw a 3Dgraph corresponding to Delaunay tetrahedrisation +%! points = rand(20, 3) * 100; +%! [nodes edges] = delaunayGraph(points); +%! figure; +%! drawGraph(nodes, edges); +%! view(3); Added: trunk/octave-forge/main/geometry/inst/graphs/drawGraph.m =================================================================== --- trunk/octave-forge/main/geometry/inst/graphs/drawGraph.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/graphs/drawGraph.m 2012-01-25 10:33:20 UTC (rev 9564) @@ -0,0 +1,290 @@ +%% Copyright (C) 2004-2012 David Legland <dav...@gr...> +%% 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. +%% +%% 2012 Adapted to Octave by Juan Pablo Carbajal <car...@if...> + +%% -*- texinfo -*- +%% @deftypefn {Function File} drawGraph (@var{nodes}, @var{edges}) +%% @deftypefnx {Function File} drawGraph (@var{nodes}, @var{edges}, @var{faces}) +%% @deftypefnx {Function File} drawGraph (@var{graph}) +%% @deftypefnx {Function File} drawGraph (@dots{}, @var{snodes}) +%% @deftypefnx {Function File} drawGraph (@dots{}, @var{snodes}, @var{sedges}) +%% @deftypefnx {Function File} drawGraph (@dots{}, @var{snodes}, @var{sedges}, @var{sfaces}) +%% @deftypefnx {Function File} {@var{h} = } drawGraph (@dots{}) +%% @deftypefnx {Function File} {[@var{h} @var{he}] = } drawGraph (@dots{}) +%% @deftypefnx {Function File} {[@var{h} @var{he} @var{hf}] = } drawGraph (@dots{}) +%% Draw a graph, given as a set of vertices and edges +%% +%% DRAWGRAPH(NODES, EDGES) +%% draw a graph specified by a set of nodes (array N*2 or N*3, +%% corresponding to coordinate of each node), and a set of edges (an array +%% Ne*2, containing for each edge the first and the second node). +%% Default drawing is a red circle for nodes and a blue line for edges. +%% +%% DRAWGRAPH(NODES, EDGES, FACES) +%% also draw faces of the graph as patches. +%% +%% DRAWGRAPH(GRAPH) +%% passes argument in a srtucture with at least 2 fields named 'nodes' and +%% 'edges', and possibly one field 'faces', corresponding to previously +%% described parameters. +%% GRAPH can also be a cell array, whose first element is node array, +%% second element is edges array, and third element, if present, is faces +%% array. +%% +%% +%% DRAWGRAPH(..., SNODES) +%% DRAWGRAPH(..., SNODES, SEDGES) +%% DRAWGRAPH(..., SNODES, SEDGES, SFACES) +%% specify the draw mode for each element, as in the classical 'plot' +%% function. To not display some elements, uses 'none'. +%% +%% +%% H = DRAWGRAPH(...) +%% return handle to the set of edges. +%% +%% [HN, HE] = DRAWGRAPH(...) +%% return handle to the set of nodes and to the set of edges. +%% +%% [HN, HE, HF] = DRAWGRAPH(...) +%% Also return handle to the set of faces. +%% +%% @end deftypefn +function varargout = drawGraph(varargin) + + %% initialisations + + % uses empty arrays by default for edges and faces + e = []; + f = []; + + % default styles for nodes, edges, and faces + + % nodes are drawn as red circles + sn = {'linestyle', 'none', 'color', 'r', 'marker', 'o'}; + + % edges are drawn as blue lines + se = {'linestyle', '-', 'color', 'b'}; + + % faces are cyan, their edges are not drawn + sf = {'EdgeColor', 'none', 'Facecolor', 'c'}; + + + %% Process input arguments + + % case of a call without arguments + if nargin==0 + help drawGraph; + return; + end + + % --------------------------------------------------------------- + % First extract the graph structure + + var = varargin{1}; + if iscell(var) + % graph is stored as a cell array: first cell is nodes, second one is + % edges, and third is faces + n = var{1}; + if length(var)>1 + e = var{2}; + end + if length(var)>2 + f = var{3}; + end + varargin(1) = []; + elseif isstruct(var) + % graph is stored as a structure, with fields 'nodes', 'edges', and + % eventually 'faces'. + n = var.nodes; + e = var.edges; + if isfield(var, 'faces') + f = var.faces; + end + varargin(1) = []; + else + % graph is stored as set of variables: nodes, edges, and eventually + % faces + n = varargin{1}; + e = varargin{2}; + varargin(1:2) = []; + + if ~isempty(varargin) + var = varargin{1}; + if isnumeric(var) + % faces are stored in a numeric array of indices + f = var; + varargin(1) = []; + elseif iscell(var) + if ~ischar(var{1}) + % faces are stored in a cell array, each cell containing a + % row vector of indices + f = var; + varargin(1) = []; + end + end + end + end + + % extract drawing style + + if ~isempty(varargin) + sn = concatArguments(sn, varargin{1}); + end + + if length(varargin)>1 + se = concatArguments(se, varargin{2}); + end + + if length(varargin)>2 + sf = concatArguments(sf, varargin{3}); + end + + + + %% main drawing processing + + hold on; + + if size(n, 2)==2 + % Draw a 2 dimensional graph ---------------------- + + % Draw faces of the graph ------------ + if ~strcmp(sf{1}, 'none') && ~isempty(f) + if iscell(f) + % each face is contained in a cell. + hf = zeros(size(f)); + for fi=1:length(f) + hf(fi) = patch('Faces', f{fi}, 'Vertices', n, sf{:}); + end + else + % process faces as an Nf*N array. Nf is the number of faces, + % and all faces have the same number of vertices (nodes). + hf = patch('Faces', f, 'Vertices', n, sf{:}); + end + end + + % Draw 2D Edges ---------------------- + if ~strcmp(se{1}, 'none') && size(e, 1)>0 + he = plot([n(e(:,1),1) n(e(:,2),1)]', [n(e(:,1),2) n(e(:,2),2)]', se{:}); + end + + % Draw 2D nodes ---------------------- + if ~strcmp(sn{1}, 'none') + hn = plot(n(:,1), n(:,2), sn{:}); + end + + + elseif size(n, 2)==3 + % Draw a 3 dimensional graph ---------------------- + + % use a zbuffer to avoid display pbms. + set(gcf, 'renderer', 'zbuffer'); + + % Draw 3D Faces ---------------------- + if ~strcmp(sf{1}, 'none') + if iscell(f) + % each face is contained in a cell. + hf = zeros(size(f)); + for fi=1:length(f) + hf(fi) = patch('Faces', f{fi}, 'Vertices', n, sf{:}); + end + else + % process faces as an Nf*N array. Nf i the number of faces, + % and all faces have the same number of vertices (nodes). + hf = patch('Faces', f, 'Vertices', n, sf{:}); + end + end + + % Draw 3D edges ---------------------- + if ~strcmp(se{1}, 'none') && size(e, 1)>0 + % he = plot3(... + % [n(e(:,1),1) n(e(:,2),1)]', ... + % [n(e(:,1),2) n(e(:,2),2)]', ... + % [n(e(:,1),3) n(e(:,2),3)]', ... + % se{:}); + he = line(... + [n(e(:,1),1) n(e(:,2),1)]', ... + [n(e(:,1),2) n(e(:,2),2)]', ... + [n(e(:,1),3) n(e(:,2),3)]', ... + se{:}); + end + + % Draw 3D nodes ---------------------- + if ~strcmp(sn{1}, 'none'); + hn = plot3(n(:,1), n(:,2), n(:,3), sn{:}); + end + + end + + + %% Format output arguments + + % return handle to edges + if nargout==1 + varargout{1} = he; + end + + % return handle to nodes and edges + if nargout==2 + varargout{1} = hn; + varargout{2} = he; + end + + % return handle to nodes, edges and faces + if nargout==3 + varargout{1} = hn; + varargout{2} = he; + varargout{3} = hf; + end + + + +endfunction + +function res = concatArguments(in1, in2) + % in1 is a cell array already initialized + % in2 is an argument that can be: + % - empty + % - the string 'none' + % - another cell array + + if isempty(in2) + res = in1; + return; + end + + if ischar(in2) + if strcmp('none', in2) + res = {'none'}; + return; + end + end + + if iscell(in1) + res = [in1(:)' in2(:)']; + else + res = [{in1} in2(:)]; + end + +endfunction Added: trunk/octave-forge/main/geometry/inst/graphs/knnGraph.m =================================================================== --- trunk/octave-forge/main/geometry/inst/graphs/knnGraph.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/graphs/knnGraph.m 2012-01-25 10:33:20 UTC (rev 9564) @@ -0,0 +1,73 @@ +%% Copyright (C) 2008-2012 David Legland <dav...@gr...> +%% 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. +%% +%% 2012 Adapted to Octave by Juan Pablo Carbajal <car...@if...> + +%% -*- texinfo -*- +%% @deftypefn {Function File} {@var{edges} = } knnGrpah (@var{nodes}) +%% Create the k-nearest neighbors graph of a set of points +%% +%% EDGES = knnGraph(NODES) +%% +%% Example +%% @example +%% +%% nodes = rand(10, 2); +%% edges = knnGraph(nodes); +%% drawGraph(nodes, edges); +%% +%% @end example +%% +%% @end deftypefn + +function edges = knnGraph(nodes, varargin) + + % get number of neighbors for each node + k = 2; + if ~isempty(varargin) + k = varargin{1}; + end + + % init size of arrays + n = size(nodes, 1); + edges = zeros(k*n, 2); + + % iterate on nodes + for i = 1:n + dists = distancePoints(nodes(i,:), nodes); + [dists inds] = sort(dists); %#ok<ASGLU> + for j = 1:k + edges(k*(i-1)+j, :) = [i inds(j+1)]; + end + end + + % remove double edges + edges = unique(sort(edges, 2), 'rows'); + +endfunction + +%!demo +%! nodes = rand(10, 2); +%! edges = knnGraph(nodes); +%! drawGraph(nodes, edges); + Added: trunk/octave-forge/main/geometry/inst/graphs/voronoi2d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/graphs/voronoi2d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/graphs/voronoi2d.m 2012-01-25 10:33:20 UTC (rev 9564) @@ -0,0 +1,68 @@ +%% Copyright (C) 2007-2012 David Legland <dav...@gr...> +%% 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. +%% +%% 2012 Adapted to Octave by Juan Pablo Carbajal <car...@if...> + +%% -*- texinfo -*- +%% @deftypefn {Function File} {[@var{nodes} @var{edges} @var{faces}] = } voronoi2d (@var{germs}) +%% Compute a voronoi diagram as a graph structure +%% +%% [NODES EDGES FACES] = voronoi2d(GERMS) +%% GERMS an array of points with dimension 2 +%% NODES, EDGES, FACES: usual graph representation, FACES as cell array +%% +%% Example +%% @example +%% +%% [n e f] = voronoi2d(rand(100, 2)*100); +%% drawGraph(n, e); +%% +%% @end example +%% +%% @end deftypefn + +function [nodes edges faces] = voronoi2d(germs) + [V C] = voronoin(germs); + + nodes = V(2:end, :); + edges = zeros(0, 2); + faces = {}; + + for i=1:length(C) + cell = C{i}; + if ismember(1, cell) + continue; + end + + cell = cell-1; + edges = [edges; sort([cell' cell([2:end 1])'], 2)]; %#ok<AGROW> + faces{length(faces)+1} = cell; %#ok<AGROW> + end + + edges = unique(edges, 'rows'); + +endfunction + +%!demo +%! [n e f] = voronoi2d(rand(100, 2)*100); +%! drawGraph(n, e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-01-25 10:35:42
|
Revision: 9565 http://octave.svn.sourceforge.net/octave/?rev=9565&view=rev Author: jpicarbajal Date: 2012-01-25 10:35:32 +0000 (Wed, 25 Jan 2012) Log Message: ----------- geometry: Bumping version Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION trunk/octave-forge/main/geometry/INDEX Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2012-01-25 10:33:20 UTC (rev 9564) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2012-01-25 10:35:32 UTC (rev 9565) @@ -1,5 +1,5 @@ Name: Geometry -Version: 1.3.0 +Version: 1.4.0 Date: 2012-01-25 Author: David Legland <dav...@gr...>, José Luis García Pallero <jgp...@gm...>, Juan Pablo Carbajal <car...@if...> Maintainer: Juan Pablo Carbajal <car...@if...> Modified: trunk/octave-forge/main/geometry/INDEX =================================================================== --- trunk/octave-forge/main/geometry/INDEX 2012-01-25 10:33:20 UTC (rev 9564) +++ trunk/octave-forge/main/geometry/INDEX 2012-01-25 10:35:32 UTC (rev 9565) @@ -136,8 +136,13 @@ isCounterClockwise squareGrid triangleGrid -Geometric graphs - +Geometric graphs creation + delaunayGraph.m + knnGraph.m + voronoi2d.m +Geometric graphs visualization + drawGraph.m +Geometric graphs manipulation Input svgload svgnormalize This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <jpi...@us...> - 2012-02-10 14:13:07
|
Revision: 9614 http://octave.svn.sourceforge.net/octave/?rev=9614&view=rev Author: jpicarbajal Date: 2012-02-10 14:12:56 +0000 (Fri, 10 Feb 2012) Log Message: ----------- geometry: improved tests Modified Paths: -------------- trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-02-10 13:22:25 UTC (rev 9613) +++ trunk/octave-forge/main/geometry/NEWS 2012-02-10 14:12:56 UTC (rev 9614) @@ -10,6 +10,7 @@ * Known issues - simplifypolygon.m returns empty polygons when points are repeated, i.e when the polygon is not correctly formed. + - shapecentriod.m gives wierd results for Bezier curves. =============================================================================== geometry-1.4.0 Release Date: 2012-01-25 Release Manager: Juan Pablo Carbajal Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-02-10 13:22:25 UTC (rev 9613) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-02-10 14:12:56 UTC (rev 9614) @@ -47,12 +47,37 @@ endfunction %!demo % non-convex bezier shape -%! weirdhearth ={[-17.6816 -34.3989 7.8580 3.7971; ... -%! 15.4585 -28.3820 -18.7645 9.8519]; ... -%! [-27.7359 18.1039 -34.5718 3.7878; ... -%! -40.7440 49.7999 -25.5011 2.2304]}; +%! weirdhearth ={[34.81947,-63.60585 41.35964,1.61093; ... +%! 73.22086,4.95439 7.1796,-34.7948]; ... +%! [30.26599,-50.0316 77.6279,8.52058; ... +%! -18.66371,58.02699 -168.20415,52.74819]}; %! CoM = shapecentroid (weirdhearth) +%! Gcentriod = centroid(shape2polygon(weirdhearth)) +%! +%! shapeplot(weirdhearth); +%! hold on +%! drawPoint(CoM,'ok'); +%! drawPoint(Gcentriod,'or'); +%! hold off +%! axis equal +%!demo +%! Lshape = {[0.00000 0.76635; -0.67579 -0.24067]; ... +%! [0.77976 0.76635; 0.00000 -0.91646]; ... +%! [0.00000 1.54611; 0.38614 -0.91646]; ... +%! [-0.43813 1.54611; 0.00000 -0.53032]; ... +%! [0.00000 1.10798; 0.28965 -0.53032]; ... +%! [-0.34163 1.10798; 0.00000 -0.24067]};... +%! CoM = shapecentroid (Lshape) +%! Gcentriod = centroid (shape2polygon (Lshape)) +%! +%! shapeplot(Lshape); +%! hold on +%! drawPoint(CoM,'ok'); +%! drawPoint(Gcentriod,'or'); +%! hold off +%! axis equal + %!test %! 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); @@ -73,5 +98,3 @@ %! -1.715729 6.715729 0 -5]}; %! CoM = shapecentroid (circle); %! assert (CoM , [0 0], 5e-3); - -%!test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-17 12:41:20
|
Revision: 9935 http://octave.svn.sourceforge.net/octave/?rev=9935&view=rev Author: jpicarbajal Date: 2012-03-17 12:41:13 +0000 (Sat, 17 Mar 2012) Log Message: ----------- geometry: fixing install Modified Paths: -------------- trunk/octave-forge/main/geometry/PKG_ADD trunk/octave-forge/main/geometry/PKG_DEL trunk/octave-forge/main/geometry/inst/octclip/src/Makefile Modified: trunk/octave-forge/main/geometry/PKG_ADD =================================================================== --- trunk/octave-forge/main/geometry/PKG_ADD 2012-03-17 10:23:00 UTC (rev 9934) +++ trunk/octave-forge/main/geometry/PKG_ADD 2012-03-17 12:41:13 UTC (rev 9935) @@ -1,20 +1,29 @@ %1 dirlist = {"geom2d","io","polygons2d","shape2d","octclip", "graphs"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); +pp = strsplit (dirname,filesep (), true); +%% Check if prefix was used +[pkg_folder dep_folder] = pkg ("prefix"); +pkg_folder = [pkg_folder filesep() strcat(filesep(),{pp{end-1:end}}){:} ]; +dep_folder = [dep_folder filesep() strcat(filesep(),{pp{end-1:end}}){:} ]; + %% If we are in Architecture dependent folder add from outside arch = cstrcat (octave_config_info ("canonical_host_type"), "-", octave_config_info ("api_version")); -pp = strsplit (dirname,filesep (), true); -if strcmp(arch , pp{end}) +if strcmp (arch , pp{end}) dirname = [strcat(filesep(),{pp{1:end-1}}){:}]; + pkg_folder = strsplit (pkg_folder,filesep (), true); + pkg_folder = [strcat(filesep(),{pkg_folder{1:end-1}}){:}]; end if (! exist (fullfile (dirname, "inst"), "dir")) +%% Installing for ii=1:length (dirlist) - addpath ( [ dirname filesep dirlist{ii}],"-end") + addpath ( [ pkg_folder filesep() dirlist{ii}],"-end") endfor else +%% Testing warning("geometry:Devel","Adding path for testing."); for ii=1:length(dirlist) addpath ([ dirname "/inst/" dirlist{ii}]) Modified: trunk/octave-forge/main/geometry/PKG_DEL =================================================================== --- trunk/octave-forge/main/geometry/PKG_DEL 2012-03-17 10:23:00 UTC (rev 9934) +++ trunk/octave-forge/main/geometry/PKG_DEL 2012-03-17 12:41:13 UTC (rev 9935) @@ -1,20 +1,28 @@ %1 dirlist = {"geom2d","io","polygons2d","shape2d","octclip","graphs"}; dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); +pp = strsplit (dirname,filesep (), true); +%% Check if prefix was used +[pkg_folder dep_folder] = pkg ("prefix"); +pkg_folder = [pkg_folder filesep() strcat(filesep(),{pp{end-1:end}}){:} ]; +dep_folder = [dep_folder filesep() strcat(filesep(),{pp{end-1:end}}){:} ]; + %% If we are not in Architecture dependent folder arch = cstrcat (octave_config_info ("canonical_host_type"), "-", octave_config_info ("api_version")); pp = strsplit (dirname,filesep (), true); if strcmp(arch , pp{end}) dirname = [strcat(filesep(),{pp{1:end-1}}){:}]; + pkg_folder = strsplit (pkg_folder,filesep (), true); + pkg_folder = [strcat(filesep(),{pkg_folder{1:end-1}}){:}]; end if (! exist (fullfile (dirname, "inst"), "dir")) +## Run this if the package is installed for ii=1:length (dirlist) - ## Run this if the package is installed - rmpath ( [ dirname filesep dirlist{ii}]) - end + rmpath ( [ pkg_folder filesep() dirlist{ii}]) + endfor else warning("geometry:Devel","Removing path for testing."); for ii=1:length(dirlist) Modified: trunk/octave-forge/main/geometry/inst/octclip/src/Makefile =================================================================== --- trunk/octave-forge/main/geometry/inst/octclip/src/Makefile 2012-03-17 10:23:00 UTC (rev 9934) +++ trunk/octave-forge/main/geometry/inst/octclip/src/Makefile 2012-03-17 12:41:13 UTC (rev 9935) @@ -5,15 +5,15 @@ CLIPOBJECT = compilador.o errores.o eucli.o fgeneral.o greiner.o polig.o \ ptopol.o segmento.o ventorno.o +FLAGS = -Wall -Wextra -all: _oc_polybool.oct - %.o: %.c - $(MKOCTFILE) -I. -c $< + $(MKOCTFILE) $(FLAGS) -I. -c $< %.oct: %.cc $(CLIPOBJECT) - $(MKOCTFILE) -v -I. $(CLIPOBJECT) -s $< + $(MKOCTFILE) $< $(CLIPOBJECT) $(FLAGS) -v -I. +all: _oc_polybool.oct clean: rm -rf *.o *~ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-18 12:33:09
|
Revision: 9941 http://octave.svn.sourceforge.net/octave/?rev=9941&view=rev Author: jpicarbajal Date: 2012-03-18 12:33:00 +0000 (Sun, 18 Mar 2012) Log Message: ----------- geometry: Bump version. Waiting for feedback on installation bug Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION trunk/octave-forge/main/geometry/INDEX trunk/octave-forge/main/geometry/NEWS Added Paths: ----------- trunk/octave-forge/main/geometry/inst/geom2d/geom2d_Contents.m Removed Paths: ------------- trunk/octave-forge/main/geometry/inst/geom2d/geometry_Contents.m Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2012-03-18 12:24:58 UTC (rev 9940) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2012-03-18 12:33:00 UTC (rev 9941) @@ -1,6 +1,6 @@ Name: Geometry -Version: 1.4.0 -Date: 2012-01-25 +Version: 1.4.1 +Date: 2012-03-18 Author: David Legland <dav...@gr...>, José Luis García Pallero <jgp...@gm...>, Juan Pablo Carbajal <car...@if...> Maintainer: Juan Pablo Carbajal <car...@if...> Title: Computational Geometry Modified: trunk/octave-forge/main/geometry/INDEX =================================================================== --- trunk/octave-forge/main/geometry/INDEX 2012-03-18 12:24:58 UTC (rev 9940) +++ trunk/octave-forge/main/geometry/INDEX 2012-03-18 12:33:00 UTC (rev 9941) @@ -1,6 +1,6 @@ geometry >> Computational Geometry 2D Descriptive - geometry_Contents + geom2d_Contents points2d vectors2d angles2d Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-03-18 12:24:58 UTC (rev 9940) +++ trunk/octave-forge/main/geometry/NEWS 2012-03-18 12:33:00 UTC (rev 9941) @@ -1,11 +1,16 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== -geometry-1.4.X Release Date: XX Release Manager: Juan Pablo Carbajal +geometry-1.4.1 Release Date: 2012-03-18 Release Manager: Juan Pablo Carbajal =============================================================================== +* Renamed functions + - Contents.m renamed to geom2d_Contents to avoid clashes. + * Bug fixes - @svg/path2polygon.m + - Fix addpath/rmpath installation warnings + - Fix octclip/src/Makefile * Known issues - simplifypolygon.m returns empty polygons when points are repeated, i.e when Copied: trunk/octave-forge/main/geometry/inst/geom2d/geom2d_Contents.m (from rev 9939, trunk/octave-forge/main/geometry/inst/geom2d/geometry_Contents.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/geom2d_Contents.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom2d/geom2d_Contents.m 2012-03-18 12:33:00 UTC (rev 9941) @@ -0,0 +1,223 @@ +%% Copyright (c) 2011, INRA +%% 2007-2011, David Legland <dav...@gr...> +%% 2011 Adapted to Octave by Juan Pablo Carbajal <car...@if...> +%% +%% All rights reserved. +%% (simplified BSD License) +%% +%% 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 COPYRIGHT HOLDER 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 copyright holder. + +%% -*- texinfo -*- +%% @deftypefn {Function File} geom2d_Contents () +%% Geometry 2D Toolbox +%% Version 1.2.0 21-Oct-2011 . +%% +%% Library to handle and visualize geometric primitives such as points, +%% lines, circles and ellipses, polygons... +%% +%% The goal is to provide a low-level library for manipulating geometrical +%% primitives, making easier the development of more complex geometric +%% algorithms. +%% +%% Most functions works for planar shapes, but some ones have been +%% extended to 3D or to any dimension. +%% +%% Points +%% points2d - Description of functions operating on points +%% clipPoints - Clip a set of points by a box +%% centroid - Compute centroid (center of mass) of a set of points +%% midPoint - Middle point of two points or of an edge +%% isCounterClockwise - Compute relative orientation of 3 points +%% polarPoint - Create a point from polar coordinates (rho + theta) +%% angle2Points - Compute horizontal angle between 2 points +%% angle3Points - Compute oriented angle made by 3 points +%% angleSort - Sort points in the plane according to their angle to origin +%% distancePoints - Compute distance between two points +%% minDistancePoints - Minimal distance between several points +%% transformPoint - Transform a point with an affine transform +%% drawPoint - Draw the point on the axis. +%% +%% Vectors +%% vectors2d - Description of functions operating on plane vectors +%% createVector - Create a vector from two points +%% vectorNorm - Compute norm of a vector, or of a set of vectors +%% vectorAngle - Angle of a vector, or between 2 vectors +%% normalizeVector - Normalize a vector to have norm equal to 1 +%% isPerpendicular - Check orthogonality of two vectors +%% isParallel - Check parallelism of two vectors +%% transformVector - Transform a vector with an affine transform +%% rotateVector - Rotate a vector by a given angle +%% +%% Straight lines +%% lines2d - Description of functions operating on planar lines +%% createLine - Create a straight line from 2 points, or from other inputs +%% medianLine - Create a median line between two points +%% cartesianLine - Create a straight line from cartesian equation coefficients +%% orthogonalLine - Create a line orthogonal to another one. +%% parallelLine - Create a line parallel to another one. +%% intersectLines - Return all intersection points of N lines in 2D +%% lineAngle - Computes angle between two straight lines +%% linePosition - Position of a point on a line +%% lineFit - Fit a straight line to a set of points +%% clipLine - Clip a line with a box +%% reverseLine - Return same line but with opposite orientation +%% transformLine - Transform a line with an affine transform +%% drawLine - Draw the line on the current axis +%% +%% Edges (line segments between 2 points) +%% edges2d - Description of functions operating on planar edges +%% createEdge - Create an edge between two points, or from a line +%% edgeToLine - Convert an edge to a straight line +%% edgeAngle - Return angle of edge +%% edgeLength - Return length of an edge +%% midPoint - Middle point of two points or of an edge +%% edgePosition - Return position of a point on an edge +%% clipEdge - Clip an edge with a rectangular box +%% reverseEdge - Intervert the source and target vertices of edge +%% intersectEdges - Return all intersections between two set of edges +%% intersectLineEdge - Return intersection between a line and an edge +%% transformEdge - Transform an edge with an affine transform +%% drawEdge - Draw an edge given by 2 points +%% drawCenteredEdge - Draw an edge centered on a point +%% +%% Rays +%% rays2d - Description of functions operating on planar rays +%% createRay - Create a ray (half-line), from various inputs +%% bisector - Return the bisector of two lines, or 3 points +%% clipRay - Clip a ray with a box +%% drawRay - Draw a ray on the current axis +%% +%% Relations between points and lines +%% distancePointEdge - Minimum distance between a point and an edge +%% distancePointLine - Minimum distance between a point and a line +%% projPointOnLine - Project of a point orthogonally onto a line +%% pointOnLine - Create a point on a line at a given position on the line +%% isPointOnLine - Test if a point belongs to a line +%% isPointOnEdge - Test if a point belongs to an edge +%% isPointOnRay - Test if a point belongs to a ray +%% isLeftOriented - Test if a point is on the left side of a line +%% +%% Circles +%% circles2d - Description of functions operating on circles +%% createCircle - Create a circle from 2 or 3 points +%% createDirectedCircle - Create a directed circle +%% intersectCircles - Intersection points of two circles +%% intersectLineCircle - Intersection point(s) of a line and a circle +%% circleAsPolygon - Convert a circle into a series of points +%% circleArcAsCurve - Convert a circle arc into a series of points +%% isPointInCircle - Test if a point is located inside a given circle +%% isPointOnCircle - Test if a point is located on a given circle. +%% enclosingCircle - Find the minimum circle enclosing a set of points. +%% radicalAxis - Compute the radical axis (or radical line) of 2 circles +%% drawCircle - Draw a circle on the current axis +%% drawCircleArc - Draw a circle arc on the current axis +%% +%% Ellipses +%% ellipses2d - Description of functions operating on ellipses +%% inertiaEllipse - Inertia ellipse of a set of points +%% isPointInEllipse - Check if a point is located inside a given ellipse +%% ellipseAsPolygon - Convert an ellipse into a series of points +%% drawEllipse - Draw an ellipse on the current axis +%% drawEllipseArc - Draw an ellipse arc on the current axis +%% +%% Geometric transforms +%% transforms2d - Description of functions operating on transforms +%% createTranslation - Create the 3*3 matrix of a translation +%% createRotation - Create the 3*3 matrix of a rotation +%% createScaling - Create the 3*3 matrix of a scaling in 2 dimensions +%% createHomothecy - Create the the 3x3 matrix of an homothetic transform +%% createBasisTransform - Compute matrix for transforming a basis into another basis +%% createLineReflection - Create the the 3x3 matrix of a line reflection +%% fitAffineTransform2d - Fit an affine transform using two point sets +%% +%% Angles +%% angles2d - Description of functions for manipulating angles +%% normalizeAngle - Normalize an angle value within a 2*PI interval +%% angleAbsDiff - Absolute difference between two angles +%% angleDiff - Difference between two angles +%% deg2rad - Convert angle from degrees to radians +%% rad2deg - Convert angle from radians to degrees +%% +%% Boxes +%% boxes2d - Description of functions operating on bounding boxes +%% intersectBoxes - Intersection of two bounding boxes +%% mergeBoxes - Merge two boxes, by computing their greatest extent +%% randomPointInBox - Generate random point within a box +%% drawBox - Draw a box defined by coordinate extents +%% +%% Various drawing functions +%% drawBezierCurve - Draw a cubic bezier curve defined by 4 control points +%% drawParabola - Draw a parabola on the current axis +%% drawOrientedBox - Draw centered oriented rectangle +%% drawRect - Draw rectangle on the current axis +%% drawArrow - Draw an arrow on the current axis +%% drawLabels - Draw labels at specified positions +%% drawShape - Draw various types of shapes (circles, polygons...) +%% +%% Other shapes +%% squareGrid - Generate equally spaces points in plane. +%% hexagonalGrid - Generate hexagonal grid of points in the plane. +%% triangleGrid - Generate triangular grid of points in the plane. +%% crackPattern - Create a (bounded) crack pattern tessellation +%% crackPattern2 - Create a (bounded) crack pattern tessellation +%% +%% +%% Credits: +%% * function 'enclosingCircle' rewritten from a file from Yazan Ahed +%% , available on Matlab File Exchange +%% +%% @end deftypefn + +function geom2d_Contents () + + help('geom2d_Contents'); + + %% Deprecated functions + + % createMedian - create a median line + % minDistance - compute minimum distance between a point and a set of points + % homothecy - create a homothecy as an affine transform + % rotation - return 3*3 matrix of a rotation + % translation - return 3*3 matrix of a translation + % scaling - return 3*3 matrix of a scaling in 2 dimensions + % lineSymmetry - create line symmetry as 2D affine transform + % vecnorm - compute norm of vector or of set of vectors + % normalize - normalize a vector + % onCircle - test if a point is located on a given circle. + % inCircle - test if a point is located inside a given circle. + % onEdge - test if a point belongs to an edge + % onLine - test if a point belongs to a line + % onRay - test if a point belongs to a ray + % invertLine - return same line but with opposite orientation + % clipLineRect - clip a line with a polygon + % formatAngle - Ensure an angle value is comprised between 0 and 2*PI + + + %% Others... + % drawRect2 - Draw centered rectangle on the current axis + +endfunction Deleted: trunk/octave-forge/main/geometry/inst/geom2d/geometry_Contents.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/geometry_Contents.m 2012-03-18 12:24:58 UTC (rev 9940) +++ trunk/octave-forge/main/geometry/inst/geom2d/geometry_Contents.m 2012-03-18 12:33:00 UTC (rev 9941) @@ -1,224 +0,0 @@ -%% Copyright (c) 2011, INRA -%% 2007-2011, David Legland <dav...@gr...> -%% 2011 Adapted to Octave by Juan Pablo Carbajal <car...@if...> -%% -%% All rights reserved. -%% (simplified BSD License) -%% -%% 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 COPYRIGHT HOLDER 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 copyright holder. - -%% -*- texinfo -*- -%% @deftypefn {Function File} geometry_Contents () -%% Geometry 2D Toolbox -%% Version 1.2.0 21-Oct-2011 . -%% -%% Library to handle and visualize geometric primitives such as points, -%% lines, circles and ellipses, polygons... -%% -%% The goal is to provide a low-level library for manipulating geometrical -%% primitives, making easier the development of more complex geometric -%% algorithms. -%% -%% Most functions works for planar shapes, but some ones have been -%% extended to 3D or to any dimension. -%% -%% Points -%% points2d - Description of functions operating on points -%% clipPoints - Clip a set of points by a box -%% centroid - Compute centroid (center of mass) of a set of points -%% midPoint - Middle point of two points or of an edge -%% isCounterClockwise - Compute relative orientation of 3 points -%% polarPoint - Create a point from polar coordinates (rho + theta) -%% angle2Points - Compute horizontal angle between 2 points -%% angle3Points - Compute oriented angle made by 3 points -%% angleSort - Sort points in the plane according to their angle to origin -%% distancePoints - Compute distance between two points -%% minDistancePoints - Minimal distance between several points -%% transformPoint - Transform a point with an affine transform -%% drawPoint - Draw the point on the axis. -%% -%% Vectors -%% vectors2d - Description of functions operating on plane vectors -%% createVector - Create a vector from two points -%% vectorNorm - Compute norm of a vector, or of a set of vectors -%% vectorAngle - Angle of a vector, or between 2 vectors -%% normalizeVector - Normalize a vector to have norm equal to 1 -%% isPerpendicular - Check orthogonality of two vectors -%% isParallel - Check parallelism of two vectors -%% transformVector - Transform a vector with an affine transform -%% rotateVector - Rotate a vector by a given angle -%% -%% Straight lines -%% lines2d - Description of functions operating on planar lines -%% createLine - Create a straight line from 2 points, or from other inputs -%% medianLine - Create a median line between two points -%% cartesianLine - Create a straight line from cartesian equation coefficients -%% orthogonalLine - Create a line orthogonal to another one. -%% parallelLine - Create a line parallel to another one. -%% intersectLines - Return all intersection points of N lines in 2D -%% lineAngle - Computes angle between two straight lines -%% linePosition - Position of a point on a line -%% lineFit - Fit a straight line to a set of points -%% clipLine - Clip a line with a box -%% reverseLine - Return same line but with opposite orientation -%% transformLine - Transform a line with an affine transform -%% drawLine - Draw the line on the current axis -%% -%% Edges (line segments between 2 points) -%% edges2d - Description of functions operating on planar edges -%% createEdge - Create an edge between two points, or from a line -%% edgeToLine - Convert an edge to a straight line -%% edgeAngle - Return angle of edge -%% edgeLength - Return length of an edge -%% midPoint - Middle point of two points or of an edge -%% edgePosition - Return position of a point on an edge -%% clipEdge - Clip an edge with a rectangular box -%% reverseEdge - Intervert the source and target vertices of edge -%% intersectEdges - Return all intersections between two set of edges -%% intersectLineEdge - Return intersection between a line and an edge -%% transformEdge - Transform an edge with an affine transform -%% drawEdge - Draw an edge given by 2 points -%% drawCenteredEdge - Draw an edge centered on a point -%% -%% Rays -%% rays2d - Description of functions operating on planar rays -%% createRay - Create a ray (half-line), from various inputs -%% bisector - Return the bisector of two lines, or 3 points -%% clipRay - Clip a ray with a box -%% drawRay - Draw a ray on the current axis -%% -%% Relations between points and lines -%% distancePointEdge - Minimum distance between a point and an edge -%% distancePointLine - Minimum distance between a point and a line -%% projPointOnLine - Project of a point orthogonally onto a line -%% pointOnLine - Create a point on a line at a given position on the line -%% isPointOnLine - Test if a point belongs to a line -%% isPointOnEdge - Test if a point belongs to an edge -%% isPointOnRay - Test if a point belongs to a ray -%% isLeftOriented - Test if a point is on the left side of a line -%% -%% Circles -%% circles2d - Description of functions operating on circles -%% createCircle - Create a circle from 2 or 3 points -%% createDirectedCircle - Create a directed circle -%% intersectCircles - Intersection points of two circles -%% intersectLineCircle - Intersection point(s) of a line and a circle -%% circleAsPolygon - Convert a circle into a series of points -%% circleArcAsCurve - Convert a circle arc into a series of points -%% isPointInCircle - Test if a point is located inside a given circle -%% isPointOnCircle - Test if a point is located on a given circle. -%% enclosingCircle - Find the minimum circle enclosing a set of points. -%% radicalAxis - Compute the radical axis (or radical line) of 2 circles -%% drawCircle - Draw a circle on the current axis -%% drawCircleArc - Draw a circle arc on the current axis -%% -%% Ellipses -%% ellipses2d - Description of functions operating on ellipses -%% inertiaEllipse - Inertia ellipse of a set of points -%% isPointInEllipse - Check if a point is located inside a given ellipse -%% ellipseAsPolygon - Convert an ellipse into a series of points -%% drawEllipse - Draw an ellipse on the current axis -%% drawEllipseArc - Draw an ellipse arc on the current axis -%% -%% Geometric transforms -%% transforms2d - Description of functions operating on transforms -%% createTranslation - Create the 3*3 matrix of a translation -%% createRotation - Create the 3*3 matrix of a rotation -%% createScaling - Create the 3*3 matrix of a scaling in 2 dimensions -%% createHomothecy - Create the the 3x3 matrix of an homothetic transform -%% createBasisTransform - Compute matrix for transforming a basis into another basis -%% createLineReflection - Create the the 3x3 matrix of a line reflection -%% fitAffineTransform2d - Fit an affine transform using two point sets -%% -%% Angles -%% angles2d - Description of functions for manipulating angles -%% normalizeAngle - Normalize an angle value within a 2*PI interval -%% angleAbsDiff - Absolute difference between two angles -%% angleDiff - Difference between two angles -%% deg2rad - Convert angle from degrees to radians -%% rad2deg - Convert angle from radians to degrees -%% -%% Boxes -%% boxes2d - Description of functions operating on bounding boxes -%% intersectBoxes - Intersection of two bounding boxes -%% mergeBoxes - Merge two boxes, by computing their greatest extent -%% randomPointInBox - Generate random point within a box -%% drawBox - Draw a box defined by coordinate extents -%% -%% Various drawing functions -%% drawBezierCurve - Draw a cubic bezier curve defined by 4 control points -%% drawParabola - Draw a parabola on the current axis -%% drawOrientedBox - Draw centered oriented rectangle -%% drawRect - Draw rectangle on the current axis -%% drawArrow - Draw an arrow on the current axis -%% drawLabels - Draw labels at specified positions -%% drawShape - Draw various types of shapes (circles, polygons...) -%% -%% Other shapes -%% squareGrid - Generate equally spaces points in plane. -%% hexagonalGrid - Generate hexagonal grid of points in the plane. -%% triangleGrid - Generate triangular grid of points in the plane. -%% crackPattern - Create a (bounded) crack pattern tessellation -%% crackPattern2 - Create a (bounded) crack pattern tessellation -%% -%% -%% Credits: -%% * function 'enclosingCircle' rewritten from a file from Yazan Ahed -%% , available on Matlab File Exchange -%% -%% @end deftypefn - -function geometry_Contents () - - help('Contents'); - - %% Deprecated functions - - % createMedian - create a median line - % minDistance - compute minimum distance between a point and a set of points - % homothecy - create a homothecy as an affine transform - % rotation - return 3*3 matrix of a rotation - % translation - return 3*3 matrix of a translation - % scaling - return 3*3 matrix of a scaling in 2 dimensions - % lineSymmetry - create line symmetry as 2D affine transform - % vecnorm - compute norm of vector or of set of vectors - % normalize - normalize a vector - % onCircle - test if a point is located on a given circle. - % inCircle - test if a point is located inside a given circle. - % onEdge - test if a point belongs to an edge - % onLine - test if a point belongs to a line - % onRay - test if a point belongs to a ray - % invertLine - return same line but with opposite orientation - % clipLineRect - clip a line with a polygon - % formatAngle - Ensure an angle value is comprised between 0 and 2*PI - - - %% Others... - % drawRect2 - Draw centered rectangle on the current axis - -endfunction - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-19 09:30:38
|
Revision: 9965 http://octave.svn.sourceforge.net/octave/?rev=9965&view=rev Author: jpicarbajal Date: 2012-03-19 09:30:27 +0000 (Mon, 19 Mar 2012) Log Message: ----------- geometry: removing keyboard from PKG* Modified Paths: -------------- trunk/octave-forge/main/geometry/PKG_ADD trunk/octave-forge/main/geometry/PKG_DEL Modified: trunk/octave-forge/main/geometry/PKG_ADD =================================================================== --- trunk/octave-forge/main/geometry/PKG_ADD 2012-03-19 02:48:56 UTC (rev 9964) +++ trunk/octave-forge/main/geometry/PKG_ADD 2012-03-19 09:30:27 UTC (rev 9965) @@ -1,6 +1,6 @@ %1 dirlist = {"geom2d","io","polygons2d","shape2d","octclip", "graphs"}; -dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); +dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))) pp = strsplit (dirname,filesep (), true); %% Check if prefix was used @@ -12,7 +12,8 @@ arch = cstrcat (octave_config_info ("canonical_host_type"), "-", octave_config_info ("api_version")); if strcmp (arch , pp{end}) - dirname = [strcat(filesep(),{pp{1:end-1}}){:}]; + dirname = [strcat(filesep(),{pp{1:end-1}}){:}] +% dirname = [pkg("prefix") filesep() pp{end-1}] pkg_folder = strsplit (pkg_folder,filesep (), true); pkg_folder = [strcat(filesep(),{pkg_folder{1:end-1}}){:}]; end @@ -22,6 +23,7 @@ for ii=1:length (dirlist) addpath ( [ pkg_folder filesep() dirlist{ii}],"-end") endfor + else %% Testing warning("geometry:Devel","Adding path for testing."); Modified: trunk/octave-forge/main/geometry/PKG_DEL =================================================================== --- trunk/octave-forge/main/geometry/PKG_DEL 2012-03-19 02:48:56 UTC (rev 9964) +++ trunk/octave-forge/main/geometry/PKG_DEL 2012-03-19 09:30:27 UTC (rev 9965) @@ -13,7 +13,8 @@ "-", octave_config_info ("api_version")); pp = strsplit (dirname,filesep (), true); if strcmp(arch , pp{end}) - dirname = [strcat(filesep(),{pp{1:end-1}}){:}]; + %dirname = [strcat(filesep(),{pp{1:end-1}}){:}] + dirname = [pkg("prefix") filesep() pp{end-1}]; pkg_folder = strsplit (pkg_folder,filesep (), true); pkg_folder = [strcat(filesep(),{pkg_folder{1:end-1}}){:}]; end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-19 09:33:44
|
Revision: 9966 http://octave.svn.sourceforge.net/octave/?rev=9966&view=rev Author: jpicarbajal Date: 2012-03-19 09:33:33 +0000 (Mon, 19 Mar 2012) Log Message: ----------- geometry: further cleaning PKG* Modified Paths: -------------- trunk/octave-forge/main/geometry/PKG_ADD trunk/octave-forge/main/geometry/PKG_DEL Modified: trunk/octave-forge/main/geometry/PKG_ADD =================================================================== --- trunk/octave-forge/main/geometry/PKG_ADD 2012-03-19 09:30:27 UTC (rev 9965) +++ trunk/octave-forge/main/geometry/PKG_ADD 2012-03-19 09:33:33 UTC (rev 9966) @@ -1,6 +1,6 @@ %1 dirlist = {"geom2d","io","polygons2d","shape2d","octclip", "graphs"}; -dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))) +dirname = fileparts (canonicalize_file_name (mfilename ("fullpath"))); pp = strsplit (dirname,filesep (), true); %% Check if prefix was used @@ -13,7 +13,6 @@ "-", octave_config_info ("api_version")); if strcmp (arch , pp{end}) dirname = [strcat(filesep(),{pp{1:end-1}}){:}] -% dirname = [pkg("prefix") filesep() pp{end-1}] pkg_folder = strsplit (pkg_folder,filesep (), true); pkg_folder = [strcat(filesep(),{pkg_folder{1:end-1}}){:}]; end Modified: trunk/octave-forge/main/geometry/PKG_DEL =================================================================== --- trunk/octave-forge/main/geometry/PKG_DEL 2012-03-19 09:30:27 UTC (rev 9965) +++ trunk/octave-forge/main/geometry/PKG_DEL 2012-03-19 09:33:33 UTC (rev 9966) @@ -13,7 +13,6 @@ "-", octave_config_info ("api_version")); pp = strsplit (dirname,filesep (), true); if strcmp(arch , pp{end}) - %dirname = [strcat(filesep(),{pp{1:end-1}}){:}] dirname = [pkg("prefix") filesep() pp{end-1}]; pkg_folder = strsplit (pkg_folder,filesep (), true); pkg_folder = [strcat(filesep(),{pkg_folder{1:end-1}}){:}]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-22 17:33:35
|
Revision: 10004 http://octave.svn.sourceforge.net/octave/?rev=10004&view=rev Author: jpicarbajal Date: 2012-03-22 17:33:22 +0000 (Thu, 22 Mar 2012) Log Message: ----------- geometry: deprecating svg functions. Adding license to python scripts Modified Paths: -------------- trunk/octave-forge/main/geometry/INDEX trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/inst/io/@svg/parsePath.py trunk/octave-forge/main/geometry/inst/io/@svg/parseSVGData.py Added Paths: ----------- trunk/octave-forge/main/geometry/inst/io/deprecated/ trunk/octave-forge/main/geometry/inst/io/deprecated/private/ trunk/octave-forge/main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m trunk/octave-forge/main/geometry/inst/io/deprecated/private/formatSVGstr.m trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGPaths_py.m trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGdata.m trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGstrPath.m trunk/octave-forge/main/geometry/inst/io/deprecated/svgload.m trunk/octave-forge/main/geometry/inst/io/deprecated/svgnormalize.m trunk/octave-forge/main/geometry/inst/io/deprecated/svgpath2polygon.m trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py Removed Paths: ------------- trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m trunk/octave-forge/main/geometry/inst/io/private/parsePath.py trunk/octave-forge/main/geometry/inst/io/svgload.m trunk/octave-forge/main/geometry/inst/io/svgnormalize.m trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m Modified: trunk/octave-forge/main/geometry/INDEX =================================================================== --- trunk/octave-forge/main/geometry/INDEX 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/INDEX 2012-03-22 17:33:22 UTC (rev 10004) @@ -144,9 +144,6 @@ drawGraph.m Geometric graphs manipulation Input - svgload - svgnormalize - svgpath2polygon @svg/svg @svg/plot @svg/getpath Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/NEWS 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,12 +1,15 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== -geometry-1.4.1 Release Date: 2012-03-18 Release Manager: Juan Pablo Carbajal +geometry-1.4.1 Release Date: 2012-03-22 Release Manager: Juan Pablo Carbajal =============================================================================== * Renamed functions - Contents.m renamed to geom2d_Contents to avoid clashes. +* Deprecated functions + - svgload, svgnormalize, svgpath2polygon: Use the methods in class svg. + * Bug fixes - @svg/path2polygon.m - Fix addpath/rmpath installation warnings Modified: trunk/octave-forge/main/geometry/inst/io/@svg/parsePath.py =================================================================== --- trunk/octave-forge/main/geometry/inst/io/@svg/parsePath.py 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/@svg/parsePath.py 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,5 +1,20 @@ #!/usr/bin/env python +## Copyright (c) 2012 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 +## any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see <http://www.gnu.org/licenses/>. + import inkex, simplepath import sys #import getopt @@ -8,7 +23,7 @@ svg = inkex.Effect () svg.parse (filen) - + paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) for path in paths: D = simplepath.parsePath (path.attrib['d']) @@ -17,14 +32,14 @@ for cmd,params in D: cmdlst.append(cmd) parlst.append(params) - + print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) print 'svgpathid = "{0}"; $'.format(path.attrib['id']) - - + + # ---------------------------- if __name__=="__main__": @@ -34,7 +49,7 @@ except getopt.GetoptError: usage() sys.exit(2) - + doHelp = 0 c = Context() c.doPrint = 1 Modified: trunk/octave-forge/main/geometry/inst/io/@svg/parseSVGData.py =================================================================== --- trunk/octave-forge/main/geometry/inst/io/@svg/parseSVGData.py 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/@svg/parseSVGData.py 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,5 +1,19 @@ #!/usr/bin/env python +## Copyright (c) 2012 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 +## any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see <http://www.gnu.org/licenses/>. import inkex import sys #import getopt @@ -8,7 +22,7 @@ svg = inkex.Effect () svg.parse (filen) - + root = svg.document.xpath ('//svg:svg', namespaces=inkex.NSS) print 'data = struct("height",{0},"width",{1},"id","{2}");' \ .format(root[0].attrib['height'],root[0].attrib['width'], Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/SVGstrPath2SVGpath.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,103 @@ +%% 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function SVGpath = SVGstrPath2SVGpath (SVGstrPath) + + nPaths = numel (SVGstrPath); + SVGpath = repmat (struct('coord', [], 'closed', [], 'id', []), 1, nPaths); + + for ip = 1:nPaths + path = SVGstrPath{ip}; + + % Match data + [s e te m] = regexpi (path, 'd="(?:(?!").)*'); + data=strtrim (m{1}); + % parse data + d = parsePathData (data); + SVGpath(ip).coord = d.coord; + SVGpath(ip).closed = d.closed; + + % Match id + [s e te m] = regexp (path, 'id="(?:(?!").)*'); + if ~isempty (m) + SVGpath(ip).id = strtrim (m{1}(5:end)); + end + end + +end + +function d = parsePathData (data) + + d = struct ('coord', [], 'closed', []); + + [s e te comm] = regexp (data, '[MmLlHhVvCcSsQqTtAaZz]{1}'); + % TODO + % This info could be used to preallocate d + [zcomm zpos] = ismember ({'Z','z'}, comm); + + if any (zcomm) + d.closed = true; + else + d.closed = false; + s(end+1) = length (data); + end + comm(zpos(zcomm)) = []; + ncomm = size (comm, 2); + for ic = 1:ncomm + + switch comm{ic} + case {'M','L'} + [x y] = strread (data(s(ic) + 1 : s(ic + 1) - 1), ... + '%f%f', 'delimiter', ', '); + coord = [x y]; + + case 'm' + [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... + '%f%f', 'delimiter', ', '); + nc = size (x, 1); + coord = [x y]; + if ic == 1 + % relative moveto at begining of data. + % First coordinates are absolute, the rest are relative. + coord = cumsum (coord); + else + % Relative moveto. + % The coordinates are relative to the last one loaded + coord(1,:) =coord(1,:) + d.coord(end,:); + coord = cumsum(coord); + warning('svg2octWarning',['Relative moveto in path data.'... + ' May mean that the orginal path was not a simple polygon.' ... + ' If that is the case, the path will not display equally.']) + end + + case 'l' + % Relative lineto, coordinates are relative to last point loaded. + [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... + '%f%f', 'delimiter', ', '); + nc = size (x, 1); + coord = [x y] + coord(1,:) =coord(1,:) + d.coord(end,:); + coord = cumsum(coord); + + otherwise + warning('svg2oct:Warning',... + 'Path data command "%s" not implemented yet.',comm{ic}); + end + + nc = size(coord,1); + d.coord(end+1:end+nc,:) = coord; + + end +end Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/formatSVGstr.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/formatSVGstr.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/formatSVGstr.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,24 @@ +%% 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function svgF = formatSVGstr(svg) + + % Remove all newlines and tabs + svgF = strrep(svg,"\n",' '); + svgF = strrep(svgF,"\t",' '); + % Remove consecutive blanks + svgF = regexprep(svgF,' +',' '); + +end Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGPaths_py.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGPaths_py.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGPaths_py.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,113 @@ +%% 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function Paths = getSVGPaths_py (svg, varargin) + + %% Call python script + if exist (svg,'file') + % read from file + [st str]=system (sprintf ('python parsePath.py %s', svg)); + + else + % inline SVG + [st str]=system (sprintf ('python parsePath.py < %s', svg)); + end + + %% Parse ouput + strpath = strsplit (str(1:end-1), '$', true); + + npaths = numel (strpath); + + %% Convert path data to polygons + for ip = 1:npaths + + eval (strpath{ip}); + %% FIXME: intialize struct with cell field + svgpath2.cmd = svgpath(1).cmd; + svgpath2.data = {svgpath.data}; + + nD = length(svgpath2.cmd); + pathdata = cell (nD-1,1); + + point_end=[]; + %% If the path is closed, last command is Z and we set initial point == final + if svgpath2.cmd(end) == 'Z' + nD -= 1; + point_end = svgpath2.data{1}; + end + + %% Initial point + points(1,:) = svgpath2.data{1}; + + for jp = 2:nD + switch svgpath2.cmd(jp) + case 'L' + %% Straigth segment to polygon + points(2,:) = svgpath2.data{jp}; + pp = [(points(2,:)-points(1,:))' points(1,:)']; + clear points + points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; + + case 'C' + %% Cubic bezier to polygon + points(2:4,:) = reshape (svgpath2.data{jp}, 2, 3).'; + pp = cbezier2poly (points); + clear points + points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; + end + + pathdata{jp-1} = pp; + end + + if ~isempty(point_end) + %% Straight segmet to close the path + points(2,:) = point_end; + pp = [(points(2,:)-points(1,:))' points(1,:)']; + + pathdata{end} = pp; + end + + Paths.(svgpathid).data = pathdata; + end +endfunction + +%!test +%! figure(1) +%! hold on +%! paths = getSVGPaths_py ('../drawing.svg'); +%! +%! % Get path ids +%! ids = fieldnames(paths); +%! npath = numel(ids); +%! +%! t = linspace (0, 1, 64); +%! +%! for i = 1:npath +%! x = []; y = []; +%! data = paths.(ids(i)).data; +%! +%! for j = 1:numel(data) +%! x = cat (2, x, polyval (data{j}(1,:),t)); +%! y = cat (2, y, polyval (data{j}(2,:),t)); +%! end +%! +%! plot(x,y,'-'); +%! end +%! axis ij +%! if strcmpi(input('You should see drawing.svg [y/n] ','s'),'n') +%! error ("didn't get what was expected."); +%! end +%! close + Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGdata.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGdata.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGdata.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,33 @@ +%% 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function svgData = getSVGdata(svg) + + svgData = struct('height',[],'width',[]); + attr = fieldnames(svgData); + nattr = numel(attr); + + [s e te data] = regexpi(svg,'<[ ]*svg(?:(?!>).)*>'); + data=strtrim(data{1}); + + for a = 1:nattr + pattr =sprintf('%s="(?:(?!").)*',attr{a}); + [s e te m] = regexpi(data,pattr); + m=strtrim(m{1}); + [dummy value] = strread(m,'%s%f','delimiter','"'); + svgData.(attr{a}) = value; + end + +end Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGstrPath.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGstrPath.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/getSVGstrPath.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,20 @@ +%% 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +function strPath = getSVGstrPath(svg) + + [s e te strPath] = regexpi(svg,'<[ ]*path(?:(?!/>).)*/>'); + +end Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/svgload.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/svgload.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/svgload.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/svgload.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,62 @@ +%% 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} @var{SVG} = loadSVG (@var{filename}) +%% Reads the plain SVG file @var{filename} and returns an SVG structure. +%% +%% In the current version only SVG path elements are parsed and stored in the field +%% path of the @var{SVG} structure. +%% The coordinates of the path are not modified in anyway. This produces the path +%% to be ploted vertically reflected. +%% +%% @seealso{svgnormalize, svgpath2polygon} +%% @end deftypefn + + +function SVG = svgload (filename) + + SVG = struct ('height', [], 'width', [], 'path', [], 'normalized', []); + + SVG.normalized = false; + + fid = fopen (filename); + svg = char (fread (fid, "uchar")'); + fclose (fid); + svgF = formatSVGstr (svg); + + % Get SVG Data + data = getSVGdata (svgF); + SVG.height = data.height; + SVG.width = data.width; + + % Get SVG Paths + SVGstrPath = getSVGstrPath (svgF); + SVGpath = SVGstrPath2SVGpath (SVGstrPath); + SVG.path = SVGpath; + +end + +%!demo +%! file = 'tmp__.svg'; +%! fid = fopen (file,'w'); +%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; +%! fprintf (fid,"%s\n",svgfile); +%! fclose (fid); +%! SVG = svgload (file); +%! SVG +%! plot([SVG.path.coord(:,1); SVG.path.coord(1,1)], ... +%! [SVG.path.coord(:,2); SVG.path.coord(1,2)]); +%! delete (file); Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/svgnormalize.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/svgnormalize.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/svgnormalize.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/svgnormalize.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,68 @@ +%% 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} @var{SVGn} = loadSVG (@var{SVG}) +%% Scales and reflects the @var{SVG} structure and returns a modified @var{SVGn} +%% structure. +%% +%% The height and width of the SVG are scaled such that the diagonal of the +%% bounding box has length 1. Coordinates are trasnfomed such that a plot of the +%% paths coincides with the visualization of the original SVG. +%% +%% @seealso{svgload, svgpath2polygon} +%% @end deftypefn + +function SVGn = svgnormalize (SVG) + + SVGn = SVG; + if ~SVG.normalized + % Translate + TransV = [0, SVG.height/2]; + % Scale + Dnorm = sqrt (SVG.width ^ 2 + SVG.height ^ 2); + S = (1 / Dnorm) * eye (2); + for i = 1:numel (SVG.path) + nc = size (SVG.path(i).coord, 1); + % Translate to middle + T = repmat (TransV,nc, 1); + SVGn.path(i).coord = SVG.path(i).coord - T; + % Reflect + SVGn.path(i).coord(:, 2) = -SVGn.path(i).coord(:,2); + T(:,2) = -T(:,2); + % Translate to bottom + SVGn.path(i).coord = SVGn.path(i).coord - T; + %Scale + SVGn.path(i).coord = SVGn.path(i).coord * S; + end + SVGn.height = SVG.height / Dnorm; + SVGn.width = SVG.width / Dnorm; + SVGn.normalized = true; + end + +end + +%!demo +%! file = 'tmp__.svg'; +%! fid = fopen (file,'w'); +%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; +%! fprintf (fid,"%s\n",svgfile); +%! fclose (fid); +%! SVG = svgload (file); +%! SVGn = svgnormalize (SVG); +%! SVGn +%! plot([SVGn.path.coord(:,1); SVGn.path.coord(1,1)], ... +%! [SVGn.path.coord(:,2); SVGn.path.coord(1,2)]); +%! delete (file); Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/svgpath2polygon.m (from rev 10003, trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/svgpath2polygon.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/svgpath2polygon.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,60 @@ +%% 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} @var{P} = svgpath2polygon (@var{SVGpath}) +%% Converts the SVG path structure @var{SVGpath} to an array of polygons +%% compatible with the geometry package and matGeom (@url{http://matgeom.sf.net}). +%% +%% @var{SVGpath} is a substructure of the SVG structure output by loadSVG. This +%% function extracts the field named "coord" if there is only one path. If there +%% are more than oe path it puts the "coord" field of each path in the same +%% array, separated by nans. +%% +%% @seealso{svgnormalize, svgload} +%% @end deftypefn + +function P = svgpath2polygon (SVGpath) + + P = SVGpath(1).coord; + for ip = 2:numel (SVGpath) + P = [P; nan(1,2); SVGpath(ip).coord]; + end + +end + +%!demo +%! file = 'tmp__.svg'; +%! fid = fopen (file,'w'); +%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; +%! fprintf (fid,"%s\n",svgfile); +%! fclose (fid); +%! SVG = svgload (file); +%! SVG = svgnormalize (SVG); +%! P = svgpath2polygon (SVG.path); +%! plot (P(:,1),P(:,2)); +%! delete (file); + +%!demo +%! file = 'tmp__.svg'; +%! fid = fopen (file,'w'); +%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /><path d="M0,0 100,0 100,100 0,100 Z" /></svg></body></html>'; +%! fprintf (fid,"%s\n",svgfile); +%! fclose (fid); +%! SVG = svgload (file); +%! SVG = svgnormalize (SVG); +%! P = svgpath2polygon (SVG.path); +%! plot (P(:,1),P(:,2)); +%! delete (file); Deleted: trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/SVGstrPath2SVGpath.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,103 +0,0 @@ -%% 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 -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function SVGpath = SVGstrPath2SVGpath (SVGstrPath) - - nPaths = numel (SVGstrPath); - SVGpath = repmat (struct('coord', [], 'closed', [], 'id', []), 1, nPaths); - - for ip = 1:nPaths - path = SVGstrPath{ip}; - - % Match data - [s e te m] = regexpi (path, 'd="(?:(?!").)*'); - data=strtrim (m{1}); - % parse data - d = parsePathData (data); - SVGpath(ip).coord = d.coord; - SVGpath(ip).closed = d.closed; - - % Match id - [s e te m] = regexp (path, 'id="(?:(?!").)*'); - if ~isempty (m) - SVGpath(ip).id = strtrim (m{1}(5:end)); - end - end - -end - -function d = parsePathData (data) - - d = struct ('coord', [], 'closed', []); - - [s e te comm] = regexp (data, '[MmLlHhVvCcSsQqTtAaZz]{1}'); - % TODO - % This info could be used to preallocate d - [zcomm zpos] = ismember ({'Z','z'}, comm); - - if any (zcomm) - d.closed = true; - else - d.closed = false; - s(end+1) = length (data); - end - comm(zpos(zcomm)) = []; - ncomm = size (comm, 2); - for ic = 1:ncomm - - switch comm{ic} - case {'M','L'} - [x y] = strread (data(s(ic) + 1 : s(ic + 1) - 1), ... - '%f%f', 'delimiter', ', '); - coord = [x y]; - - case 'm' - [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... - '%f%f', 'delimiter', ', '); - nc = size (x, 1); - coord = [x y]; - if ic == 1 - % relative moveto at begining of data. - % First coordinates are absolute, the rest are relative. - coord = cumsum (coord); - else - % Relative moveto. - % The coordinates are relative to the last one loaded - coord(1,:) =coord(1,:) + d.coord(end,:); - coord = cumsum(coord); - warning('svg2octWarning',['Relative moveto in path data.'... - ' May mean that the orginal path was not a simple polygon.' ... - ' If that is the case, the path will not display equally.']) - end - - case 'l' - % Relative lineto, coordinates are relative to last point loaded. - [x y] = strread( data(s(ic) + 1 : s(ic + 1) - 1), ... - '%f%f', 'delimiter', ', '); - nc = size (x, 1); - coord = [x y] - coord(1,:) =coord(1,:) + d.coord(end,:); - coord = cumsum(coord); - - otherwise - warning('svg2oct:Warning',... - 'Path data command "%s" not implemented yet.',comm{ic}); - end - - nc = size(coord,1); - d.coord(end+1:end+nc,:) = coord; - - end -end Copied: trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py (from rev 10003, trunk/octave-forge/main/geometry/inst/io/private/parsePath.py) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py 2012-03-22 17:33:22 UTC (rev 10004) @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import inkex, simplepath +import sys +#import getopt + +def parsePaths (filen=None): + + svg = inkex.Effect () + svg.parse (filen) + + paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) + for path in paths: + D = simplepath.parsePath (path.attrib['d']) + cmdlst = []; + parlst = []; + for cmd,params in D: + cmdlst.append(cmd) + parlst.append(params) + + print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ + .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) + + print 'svgpathid = "{0}"; $'.format(path.attrib['id']) + + + +# ---------------------------- + +if __name__=="__main__": + ''' + try: + optlist,args = getopt.getopt(sys.argv[1:],"thdp") + except getopt.GetoptError: + usage() + sys.exit(2) + + doHelp = 0 + c = Context() + c.doPrint = 1 + for opt in optlist: + if opt[0] == "-d": c.debug = 1 + if opt[0] == "-p": c.plot = 1 + if opt[0] == "-t": c.triangulate = 1 + if opt[0] == "-h": doHelp = 1 + + if not doHelp: + pts = [] + fp = sys.stdin + if len(args) > 0: + fp = open(args[0],'r') + for line in fp: + fld = line.split() + x = float(fld[0]) + y = float(fld[1]) + pts.append(Site(x,y)) + if len(args) > 0: fp.close() + + if doHelp or len(pts) == 0: + usage() + sys.exit(2) + ''' + svg = sys.argv[1] + parsePaths(svg) Deleted: trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/formatSVGstr.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,24 +0,0 @@ -%% 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 -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function svgF = formatSVGstr(svg) - - % Remove all newlines and tabs - svgF = strrep(svg,"\n",' '); - svgF = strrep(svgF,"\t",' '); - % Remove consecutive blanks - svgF = regexprep(svgF,' +',' '); - -end Deleted: trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/getSVGPaths_py.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,113 +0,0 @@ -%% 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 -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function Paths = getSVGPaths_py (svg, varargin) - - %% Call python script - if exist (svg,'file') - % read from file - [st str]=system (sprintf ('python parsePath.py %s', svg)); - - else - % inline SVG - [st str]=system (sprintf ('python parsePath.py < %s', svg)); - end - - %% Parse ouput - strpath = strsplit (str(1:end-1), '$', true); - - npaths = numel (strpath); - - %% Convert path data to polygons - for ip = 1:npaths - - eval (strpath{ip}); - %% FIXME: intialize struct with cell field - svgpath2.cmd = svgpath(1).cmd; - svgpath2.data = {svgpath.data}; - - nD = length(svgpath2.cmd); - pathdata = cell (nD-1,1); - - point_end=[]; - %% If the path is closed, last command is Z and we set initial point == final - if svgpath2.cmd(end) == 'Z' - nD -= 1; - point_end = svgpath2.data{1}; - end - - %% Initial point - points(1,:) = svgpath2.data{1}; - - for jp = 2:nD - switch svgpath2.cmd(jp) - case 'L' - %% Straigth segment to polygon - points(2,:) = svgpath2.data{jp}; - pp = [(points(2,:)-points(1,:))' points(1,:)']; - clear points - points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; - - case 'C' - %% Cubic bezier to polygon - points(2:4,:) = reshape (svgpath2.data{jp}, 2, 3).'; - pp = cbezier2poly (points); - clear points - points(1,:) = [polyval(pp(1,:),1) polyval(pp(2,:),1)]; - end - - pathdata{jp-1} = pp; - end - - if ~isempty(point_end) - %% Straight segmet to close the path - points(2,:) = point_end; - pp = [(points(2,:)-points(1,:))' points(1,:)']; - - pathdata{end} = pp; - end - - Paths.(svgpathid).data = pathdata; - end -endfunction - -%!test -%! figure(1) -%! hold on -%! paths = getSVGPaths_py ('../drawing.svg'); -%! -%! % Get path ids -%! ids = fieldnames(paths); -%! npath = numel(ids); -%! -%! t = linspace (0, 1, 64); -%! -%! for i = 1:npath -%! x = []; y = []; -%! data = paths.(ids(i)).data; -%! -%! for j = 1:numel(data) -%! x = cat (2, x, polyval (data{j}(1,:),t)); -%! y = cat (2, y, polyval (data{j}(2,:),t)); -%! end -%! -%! plot(x,y,'-'); -%! end -%! axis ij -%! if strcmpi(input('You should see drawing.svg [y/n] ','s'),'n') -%! error ("didn't get what was expected."); -%! end -%! close - Deleted: trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/getSVGdata.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,33 +0,0 @@ -%% 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 -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function svgData = getSVGdata(svg) - - svgData = struct('height',[],'width',[]); - attr = fieldnames(svgData); - nattr = numel(attr); - - [s e te data] = regexpi(svg,'<[ ]*svg(?:(?!>).)*>'); - data=strtrim(data{1}); - - for a = 1:nattr - pattr =sprintf('%s="(?:(?!").)*',attr{a}); - [s e te m] = regexpi(data,pattr); - m=strtrim(m{1}); - [dummy value] = strread(m,'%s%f','delimiter','"'); - svgData.(attr{a}) = value; - end - -end Deleted: trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/getSVGstrPath.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,20 +0,0 @@ -%% 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 -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -function strPath = getSVGstrPath(svg) - - [s e te strPath] = regexpi(svg,'<[ ]*path(?:(?!/>).)*/>'); - -end Deleted: trunk/octave-forge/main/geometry/inst/io/private/parsePath.py =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/parsePath.py 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/private/parsePath.py 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,64 +0,0 @@ -#!/usr/bin/env python - -import inkex, simplepath -import sys -#import getopt - -def parsePaths (filen=None): - - svg = inkex.Effect () - svg.parse (filen) - - paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) - for path in paths: - D = simplepath.parsePath (path.attrib['d']) - cmdlst = []; - parlst = []; - for cmd,params in D: - cmdlst.append(cmd) - parlst.append(params) - - print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ - .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) - - print 'svgpathid = "{0}"; $'.format(path.attrib['id']) - - - -# ---------------------------- - -if __name__=="__main__": - ''' - try: - optlist,args = getopt.getopt(sys.argv[1:],"thdp") - except getopt.GetoptError: - usage() - sys.exit(2) - - doHelp = 0 - c = Context() - c.doPrint = 1 - for opt in optlist: - if opt[0] == "-d": c.debug = 1 - if opt[0] == "-p": c.plot = 1 - if opt[0] == "-t": c.triangulate = 1 - if opt[0] == "-h": doHelp = 1 - - if not doHelp: - pts = [] - fp = sys.stdin - if len(args) > 0: - fp = open(args[0],'r') - for line in fp: - fld = line.split() - x = float(fld[0]) - y = float(fld[1]) - pts.append(Site(x,y)) - if len(args) > 0: fp.close() - - if doHelp or len(pts) == 0: - usage() - sys.exit(2) - ''' - svg = sys.argv[1] - parsePaths(svg) Deleted: trunk/octave-forge/main/geometry/inst/io/svgload.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/svgload.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/svgload.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,62 +0,0 @@ -%% 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 -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} @var{SVG} = loadSVG (@var{filename}) -%% Reads the plain SVG file @var{filename} and returns an SVG structure. -%% -%% In the current version only SVG path elements are parsed and stored in the field -%% path of the @var{SVG} structure. -%% The coordinates of the path are not modified in anyway. This produces the path -%% to be ploted vertically reflected. -%% -%% @seealso{svgnormalize, svgpath2polygon} -%% @end deftypefn - - -function SVG = svgload (filename) - - SVG = struct ('height', [], 'width', [], 'path', [], 'normalized', []); - - SVG.normalized = false; - - fid = fopen (filename); - svg = char (fread (fid, "uchar")'); - fclose (fid); - svgF = formatSVGstr (svg); - - % Get SVG Data - data = getSVGdata (svgF); - SVG.height = data.height; - SVG.width = data.width; - - % Get SVG Paths - SVGstrPath = getSVGstrPath (svgF); - SVGpath = SVGstrPath2SVGpath (SVGstrPath); - SVG.path = SVGpath; - -end - -%!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); -%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; -%! fprintf (fid,"%s\n",svgfile); -%! fclose (fid); -%! SVG = svgload (file); -%! SVG -%! plot([SVG.path.coord(:,1); SVG.path.coord(1,1)], ... -%! [SVG.path.coord(:,2); SVG.path.coord(1,2)]); -%! delete (file); Deleted: trunk/octave-forge/main/geometry/inst/io/svgnormalize.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/svgnormalize.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/svgnormalize.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,68 +0,0 @@ -%% 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 -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} @var{SVGn} = loadSVG (@var{SVG}) -%% Scales and reflects the @var{SVG} structure and returns a modified @var{SVGn} -%% structure. -%% -%% The height and width of the SVG are scaled such that the diagonal of the -%% bounding box has length 1. Coordinates are trasnfomed such that a plot of the -%% paths coincides with the visualization of the original SVG. -%% -%% @seealso{svgload, svgpath2polygon} -%% @end deftypefn - -function SVGn = svgnormalize (SVG) - - SVGn = SVG; - if ~SVG.normalized - % Translate - TransV = [0, SVG.height/2]; - % Scale - Dnorm = sqrt (SVG.width ^ 2 + SVG.height ^ 2); - S = (1 / Dnorm) * eye (2); - for i = 1:numel (SVG.path) - nc = size (SVG.path(i).coord, 1); - % Translate to middle - T = repmat (TransV,nc, 1); - SVGn.path(i).coord = SVG.path(i).coord - T; - % Reflect - SVGn.path(i).coord(:, 2) = -SVGn.path(i).coord(:,2); - T(:,2) = -T(:,2); - % Translate to bottom - SVGn.path(i).coord = SVGn.path(i).coord - T; - %Scale - SVGn.path(i).coord = SVGn.path(i).coord * S; - end - SVGn.height = SVG.height / Dnorm; - SVGn.width = SVG.width / Dnorm; - SVGn.normalized = true; - end - -end - -%!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); -%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; -%! fprintf (fid,"%s\n",svgfile); -%! fclose (fid); -%! SVG = svgload (file); -%! SVGn = svgnormalize (SVG); -%! SVGn -%! plot([SVGn.path.coord(:,1); SVGn.path.coord(1,1)], ... -%! [SVGn.path.coord(:,2); SVGn.path.coord(1,2)]); -%! delete (file); Deleted: trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m 2012-03-22 15:08:33 UTC (rev 10003) +++ trunk/octave-forge/main/geometry/inst/io/svgpath2polygon.m 2012-03-22 17:33:22 UTC (rev 10004) @@ -1,60 +0,0 @@ -%% 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 -%% any later version. -%% -%% This program is distributed in the hope that it will be useful, -%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%% GNU General Public License for more details. -%% -%% You should have received a copy of the GNU General Public License -%% along with this program. If not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} @var{P} = svgpath2polygon (@var{SVGpath}) -%% Converts the SVG path structure @var{SVGpath} to an array of polygons -%% compatible with the geometry package and matGeom (@url{http://matgeom.sf.net}). -%% -%% @var{SVGpath} is a substructure of the SVG structure output by loadSVG. This -%% function extracts the field named "coord" if there is only one path. If there -%% are more than oe path it puts the "coord" field of each path in the same -%% array, separated by nans. -%% -%% @seealso{svgnormalize, svgload} -%% @end deftypefn - -function P = svgpath2polygon (SVGpath) - - P = SVGpath(1).coord; - for ip = 2:numel (SVGpath) - P = [P; nan(1,2); SVGpath(ip).coord]; - end - -end - -%!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); -%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /></svg></body></html>'; -%! fprintf (fid,"%s\n",svgfile); -%! fclose (fid); -%! SVG = svgload (file); -%! SVG = svgnormalize (SVG); -%! P = svgpath2polygon (SVG.path); -%! plot (P(:,1),P(:,2)); -%! delete (file); - -%!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); -%! svgfile = '<html><body><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="250" width="250"><path d="M150,0 75,200 225,200 Z" /><path d="M0,0 100,0 100,100 0,100 Z" /></svg></body></html>'; -%! fprintf (fid,"%s\n",svgfile); -%! fclose (fid); -%! SVG = svgload (file); -%! SVG = svgnormalize (SVG); -%! P = svgpath2polygon (SVG.path); -%! plot (P(:,1),P(:,2)); -%! delete (file); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-22 22:05:12
|
Revision: 10006 http://octave.svn.sourceforge.net/octave/?rev=10006&view=rev Author: jpicarbajal Date: 2012-03-22 22:05:06 +0000 (Thu, 22 Mar 2012) Log Message: ----------- geometry: Fixed bugs detected by Rafael (dev packager). Improved docstring of cbezier2poly. Verified all other shape2d functions. Moved test form shapetransfrom to shapecentriod Modified Paths: -------------- trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/NEWS 2012-03-22 22:05:06 UTC (rev 10006) @@ -14,12 +14,13 @@ - @svg/path2polygon.m - Fix addpath/rmpath installation warnings - Fix octclip/src/Makefile + - Fix shapecentriod.m for piece-wise polynomial shapes. * Known issues - simplifypolygon.m returns empty polygons when points are repeated, i.e when the polygon is not correctly formed. - - shapecentriod.m gives wierd results for Bezier curves. + =============================================================================== geometry-1.4.0 Release Date: 2012-01-25 Release Manager: Juan Pablo Carbajal =============================================================================== Modified: trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/geom2d/cbezier2poly.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -39,8 +39,8 @@ %% With only one input argument, calculates the polynomial @var{pp} of the cubic %% Bezier curve defined by the 4 control points stored in @var{points}. The first %% point is the inital point of the curve. The segment joining the first point -%% with the second point defines the tangent of the curve at the initial point. -%% The segment that joints the third point with the fourth defines the tanget at +%% with the second point (first center) defines the tangent of the curve at the initial point. +%% The segment that joints the third point (second center) with the fourth defines the tanget at %% the end-point of the curve, which is defined in the fourth point. %% @var{points} is either a 4-by-2 array (vertical concatenation of point %% coordinates), or a 1-by-8 array (horizotnal concatenation of point Modified: trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -29,21 +29,24 @@ function polygon = shape2polygon (shape, N=16) polygon = cell2mat ( ... - cellfun(@(x) func (x,N), shape,'UniformOutput',false) ); + cellfun (@(x) func (x,N), shape,'UniformOutput',false) ); - if size(polygon, 1) == 1 - polygon(2,1) = polyval(shape{1}(1,:),1); - polygon(2,2) = polyval(shape{1}(2,:),1); + %% TODO simply the polygon based on curvature +% polygon = unique (polygon, 'rows'); + + if size (polygon, 1) == 1 + polygon(2,1) = polyval (shape{1}(1,:), 1); + polygon(2,2) = polyval (shape{1}(2,:), 1); end endfunction -function y = func(x,N) +function y = func (x,N) - if size(x,2) > 2 - t = linspace(0,1-1/N,N).'; - y(:,1) = polyval(x(1,:),t); - y(:,2) = polyval(x(2,:),t); + if size (x,2) > 2 + t = linspace (0,1-1/N,N).'; + y(:,1) = polyval (x(1,:), t); + y(:,2) = polyval (x(2,:), t); else y = x(:,2).'; end Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -26,10 +26,12 @@ %% @seealso{shapecentroid, shape2polygon, shapeplot} %% @end deftypefn -function A = shapearea (shape) +function [A ccw] = shapearea (shape) A = sum(cellfun (@Aint, shape)); if A < 0 + warning ('geom2d:shapearea:InvalidResult', ... + 'Shape has negative area. Assuming this is due to a clockwise parametrization of the boundary'); A = -A; end @@ -46,12 +48,16 @@ end -%!demo % non-convex bezier shape -%! weirdhearth ={[-17.6816 -34.3989 7.8580 3.7971; ... -%! 15.4585 -28.3820 -18.7645 9.8519]; ... -%! [-27.7359 18.1039 -34.5718 3.7878; ... -%! -40.7440 49.7999 -25.5011 2.2304]}; -%! A = shapearea (weirdhearth) +%!demo % non-convex piece-wise polynomial shape +%! boomerang = {[ 0 -2 1; ... +%! -4 4 0]; ... +%! [0.25 -1; ... +%! 0 0]; ... +%! [ 0 1.5 -0.75; ... +%! -3 3 0]; +%! [0.25 0.75; ... +%! 0 0]}; +%! A = shapearea (boomerang) %!test %! triangle = {[1 0; 0 0]; [-0.5 1; 1 0]; [-0.5 0.5; -1 1]}; Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -15,30 +15,39 @@ %% -*- texinfo -*- %% @deftypefn {Function File} { @var{cm} =} shapecentroid (@var{pp}) -%% Centroid of a plane shape defined with piecewise smooth polynomials. +%% Centroid of a simple plane shape defined with piecewise smooth polynomials. %% %% The shape is defined with piecewise smooth polynomials. @var{pp} is a %% cell where each elements is a 2-by-(poly_degree+1) matrix containing a pair %% of polynomials. %% @code{px(i,:) = pp@{i@}(1,:)} and @code{py(i,:) = pp@{i@}(2,:)}. %% +%% The edges of the shape should not self-intersect. This function does not check for the +%% sanity of the shape. +%% %% @seealso{shapearea, shape2polygon} %% @end deftypefn function cm = shapecentroid (shape) - cm = sum( cell2mat ( cellfun (@CMint, shape, 'UniformOutput', false))); + cm = sum( cell2mat ( cellfun (@CMint, shape, 'UniformOutput', false)), 1); A = shapearea(shape); cm = cm / A; + [~,id] = lastwarn ('',''); + if strcmp (id ,'geom2d:shapearea:InvalidResult') + lastwarn('Inverting centriod','geom2d:shapecentriod:InvalidResult'); + cm = -cm; + end + endfunction function dcm = CMint (x) px = x(1,:); py = x(2,:); - Px = polyint (conv(conv (px , px)/2 , polyder (py))); - Py = polyint (conv(-conv (py , py)/2 , polyder (px))); + Px = polyint (conv(conv (-px , py) , polyder (px))); + Py = polyint (conv(conv (px , py) , polyder (py))); dcm = zeros (1,2); dcm(1) = diff(polyval(Px,[0 1])); @@ -47,17 +56,22 @@ endfunction %!demo % non-convex bezier shape -%! weirdhearth ={[34.81947,-63.60585 41.35964,1.61093; ... -%! 73.22086,4.95439 7.1796,-34.7948]; ... -%! [30.26599,-50.0316 77.6279,8.52058; ... -%! -18.66371,58.02699 -168.20415,52.74819]}; -%! CoM = shapecentroid (weirdhearth) -%! Gcentriod = centroid(shape2polygon(weirdhearth)) +%! boomerang = {[ 0 -2 1; ... +%! -4 4 0]; ... +%! [0.25 -1; ... +%! 0 0]; ... +%! [ 0 1.5 -0.75; ... +%! -3 3 0]; +%! [0.25 0.75; ... +%! 0 0]}; +%! CoM = shapecentroid (boomerang) +%! Gcentriod = centroid(shape2polygon(boomerang)) %! -%! shapeplot(weirdhearth); +%! figure(1); clf; +%! shapeplot(boomerang,10,'-o'); %! hold on -%! drawPoint(CoM,'ok'); -%! drawPoint(Gcentriod,'or'); +%! drawPoint(CoM,'xk;shape centriod;'); +%! drawPoint(Gcentriod,'xr;point centriod;'); %! hold off %! axis equal @@ -71,10 +85,10 @@ %! CoM = shapecentroid (Lshape) %! Gcentriod = centroid (shape2polygon (Lshape)) %! -%! shapeplot(Lshape); +%! shapeplot(Lshape,10,'-o'); %! hold on -%! drawPoint(CoM,'ok'); -%! drawPoint(Gcentriod,'or'); +%! drawPoint(CoM,'xk;shape centriod;'); +%! drawPoint(Gcentriod,'xr;point centriod;'); %! hold off %! axis equal @@ -82,10 +96,12 @@ %! 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)); + +%!test +%! 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]}; %! square_t = shapetransform (square,[1;1]); -%! CoM_t = shapecentroid (square_t); -%! assert (CoM, [0 0], sqrt(eps)); -%! assert (CoM_t, [1 1], sqrt(eps)); +%! CoM = shapecentroid (square_t); +%! assert (CoM, [1 1], sqrt(eps)); %!test %! circle = {[1.715729 -6.715729 0 5; ... @@ -98,3 +114,37 @@ %! -1.715729 6.715729 0 -5]}; %! CoM = shapecentroid (circle); %! assert (CoM , [0 0], 5e-3); + +%!shared shape +%! shape = {[-93.172 606.368 -476.054 291.429; ... +%! -431.196 637.253 11.085 163.791]; ... +%! [-75.3626 -253.2337 457.1678 328.5714; ... +%! 438.7659 -653.6278 -7.9953 380.9336]; ... +%! [-89.5841 344.9716 -275.3876 457.1429; ... +%! -170.3613 237.8858 1.0469 158.0765];... +%! [32.900 -298.704 145.804 437.143; ... +%! -243.903 369.597 -34.265 226.648]; ... +%! [-99.081 409.127 -352.903 317.143; ... +%! 55.289 -114.223 -26.781 318.076]; ... +%! [-342.231 191.266 168.108 274.286; ... +%! 58.870 -38.083 -89.358 232.362]}; + +%!test % x-Reflection +%! v = shapecentroid (shape)(:); +%! T = createLineReflection([0 0 1 0]); +%! nshape = shapetransform (shape, T); +%! vn = shapecentroid (nshape)(:); +%! assert(vn,T(1:2,1:2)*v); + +%!test % Rotation +%! v = shapecentroid (shape)(:); +%! T = createRotation(v.',pi/2); +%! nshape = shapetransform (shape, T); +%! vn = shapecentroid (nshape)(:); +%! assert(vn,v,1e-2); + +%!test % Translation +%! v = shapecentroid (shape)(:); +%! nshape = shapetransform (shape, -v); +%! vn = shapecentroid (nshape)(:); +%! assert(vn,[0; 0],1e-2); Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2012-03-22 17:54:01 UTC (rev 10005) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2012-03-22 22:05:06 UTC (rev 10006) @@ -109,36 +109,3 @@ %! axis square -%!shared shape -%! shape = {[-93.172 606.368 -476.054 291.429; ... -%! -431.196 637.253 11.085 163.791]; ... -%! [-75.3626 -253.2337 457.1678 328.5714; ... -%! 438.7659 -653.6278 -7.9953 380.9336]; ... -%! [-89.5841 344.9716 -275.3876 457.1429; ... -%! -170.3613 237.8858 1.0469 158.0765];... -%! [32.900 -298.704 145.804 437.143; ... -%! -243.903 369.597 -34.265 226.648]; ... -%! [-99.081 409.127 -352.903 317.143; ... -%! 55.289 -114.223 -26.781 318.076]; ... -%! [-342.231 191.266 168.108 274.286; ... -%! 58.870 -38.083 -89.358 232.362]}; - -%!test -%! v = shapecentroid (shape)(:); -%! nshape = shapetransform (shape, -v); -%! vn = shapecentroid (nshape)(:); -%! assert(vn,[0; 0],1e-2); - -%!test -%! v = shapecentroid (shape)(:); -%! T = createLineReflection([0 0 1 0]); -%! nshape = shapetransform (shape, T); -%! vn = shapecentroid (nshape)(:); -%! assert(vn,T(1:2,1:2)*v); - -%!test -%! v = shapecentroid (shape)(:); -%! T = createRotation(v.',pi/2); -%! nshape = shapetransform (shape, T); -%! vn = shapecentroid (nshape)(:); -%! assert(vn,v,1e-2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-24 10:24:26
|
Revision: 10020 http://octave.svn.sourceforge.net/octave/?rev=10020&view=rev Author: jpicarbajal Date: 2012-03-24 10:24:19 +0000 (Sat, 24 Mar 2012) Log Message: ----------- geometry: Fixing typos. deprecating old functions Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m Added Paths: ----------- trunk/octave-forge/main/geometry/inst/io/deprecated/private/_parsePath.py Removed Paths: ------------- trunk/octave-forge/main/geometry/doc/ trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py Copied: trunk/octave-forge/main/geometry/inst/io/deprecated/private/_parsePath.py (from rev 10004, trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py) =================================================================== --- trunk/octave-forge/main/geometry/inst/io/deprecated/private/_parsePath.py (rev 0) +++ trunk/octave-forge/main/geometry/inst/io/deprecated/private/_parsePath.py 2012-03-24 10:24:19 UTC (rev 10020) @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import inkex, simplepath +import sys +#import getopt + +def parsePaths (filen=None): + + svg = inkex.Effect () + svg.parse (filen) + + paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) + for path in paths: + D = simplepath.parsePath (path.attrib['d']) + cmdlst = []; + parlst = []; + for cmd,params in D: + cmdlst.append(cmd) + parlst.append(params) + + print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ + .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) + + print 'svgpathid = "{0}"; $'.format(path.attrib['id']) + + + +# ---------------------------- + +if __name__=="__main__": + ''' + try: + optlist,args = getopt.getopt(sys.argv[1:],"thdp") + except getopt.GetoptError: + usage() + sys.exit(2) + + doHelp = 0 + c = Context() + c.doPrint = 1 + for opt in optlist: + if opt[0] == "-d": c.debug = 1 + if opt[0] == "-p": c.plot = 1 + if opt[0] == "-t": c.triangulate = 1 + if opt[0] == "-h": doHelp = 1 + + if not doHelp: + pts = [] + fp = sys.stdin + if len(args) > 0: + fp = open(args[0],'r') + for line in fp: + fld = line.split() + x = float(fld[0]) + y = float(fld[1]) + pts.append(Site(x,y)) + if len(args) > 0: fp.close() + + if doHelp or len(pts) == 0: + usage() + sys.exit(2) + ''' + svg = sys.argv[1] + parsePaths(svg) Deleted: trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py =================================================================== --- trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py 2012-03-24 09:46:42 UTC (rev 10019) +++ trunk/octave-forge/main/geometry/inst/io/private/_parsePath.py 2012-03-24 10:24:19 UTC (rev 10020) @@ -1,64 +0,0 @@ -#!/usr/bin/env python - -import inkex, simplepath -import sys -#import getopt - -def parsePaths (filen=None): - - svg = inkex.Effect () - svg.parse (filen) - - paths = svg.document.xpath ('//svg:path', namespaces=inkex.NSS) - for path in paths: - D = simplepath.parsePath (path.attrib['d']) - cmdlst = []; - parlst = []; - for cmd,params in D: - cmdlst.append(cmd) - parlst.append(params) - - print 'svgpath = struct("cmd","{0}","data",{{{1}}});' \ - .format(''.join(cmdlst),str(parlst).replace('[[','[').replace(']]',']')) - - print 'svgpathid = "{0}"; $'.format(path.attrib['id']) - - - -# ---------------------------- - -if __name__=="__main__": - ''' - try: - optlist,args = getopt.getopt(sys.argv[1:],"thdp") - except getopt.GetoptError: - usage() - sys.exit(2) - - doHelp = 0 - c = Context() - c.doPrint = 1 - for opt in optlist: - if opt[0] == "-d": c.debug = 1 - if opt[0] == "-p": c.plot = 1 - if opt[0] == "-t": c.triangulate = 1 - if opt[0] == "-h": doHelp = 1 - - if not doHelp: - pts = [] - fp = sys.stdin - if len(args) > 0: - fp = open(args[0],'r') - for line in fp: - fld = line.split() - x = float(fld[0]) - y = float(fld[1]) - pts.append(Site(x,y)) - if len(args) > 0: fp.close() - - if doHelp or len(pts) == 0: - usage() - sys.exit(2) - ''' - svg = sys.argv[1] - parsePaths(svg) Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-03-24 09:46:42 UTC (rev 10019) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-03-24 10:24:19 UTC (rev 10020) @@ -36,7 +36,7 @@ [~,id] = lastwarn ('',''); if strcmp (id ,'geom2d:shapearea:InvalidResult') - lastwarn('Inverting centriod','geom2d:shapecentriod:InvalidResult'); + lastwarn('Inverting centroid','geom2d:shapecentroid:InvalidResult'); cm = -cm; end @@ -65,13 +65,13 @@ %! [0.25 0.75; ... %! 0 0]}; %! CoM = shapecentroid (boomerang) -%! Gcentriod = centroid(shape2polygon(boomerang)) +%! Gcentroid = centroid(shape2polygon(boomerang)) %! %! figure(1); clf; %! shapeplot(boomerang,10,'-o'); %! hold on -%! drawPoint(CoM,'xk;shape centriod;'); -%! drawPoint(Gcentriod,'xr;point centriod;'); +%! drawPoint(CoM,'xk;shape centroid;'); +%! drawPoint(Gcentroid,'xr;point centroid;'); %! hold off %! axis equal @@ -83,12 +83,12 @@ %! [0.00000 1.10798; 0.28965 -0.53032]; ... %! [-0.34163 1.10798; 0.00000 -0.24067]};... %! CoM = shapecentroid (Lshape) -%! Gcentriod = centroid (shape2polygon (Lshape)) +%! Gcentroid = centroid (shape2polygon (Lshape)) %! %! shapeplot(Lshape,10,'-o'); %! hold on -%! drawPoint(CoM,'xk;shape centriod;'); -%! drawPoint(Gcentriod,'xr;point centriod;'); +%! drawPoint(CoM,'xk;shape centroid;'); +%! drawPoint(Gcentroid,'xr;point centroid;'); %! hold off %! axis equal This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-24 15:54:43
|
Revision: 10023 http://octave.svn.sourceforge.net/octave/?rev=10023&view=rev Author: jpicarbajal Date: 2012-03-24 15:54:32 +0000 (Sat, 24 Mar 2012) Log Message: ----------- geometry: Bumping versin. Releasing Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION trunk/octave-forge/main/geometry/NEWS Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2012-03-24 14:31:07 UTC (rev 10022) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2012-03-24 15:54:32 UTC (rev 10023) @@ -1,6 +1,6 @@ Name: Geometry Version: 1.4.1 -Date: 2012-03-18 +Date: 2012-03-24 Author: David Legland <dav...@gr...>, José Luis García Pallero <jgp...@gm...>, Juan Pablo Carbajal <car...@if...> Maintainer: Juan Pablo Carbajal <car...@if...> Title: Computational Geometry Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-03-24 14:31:07 UTC (rev 10022) +++ trunk/octave-forge/main/geometry/NEWS 2012-03-24 15:54:32 UTC (rev 10023) @@ -1,7 +1,7 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== -geometry-1.4.1 Release Date: 2012-03-22 Release Manager: Juan Pablo Carbajal +geometry-1.4.1 Release Date: 2012-03-24 Release Manager: Juan Pablo Carbajal =============================================================================== * Renamed functions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-25 15:01:56
|
Revision: 10051 http://octave.svn.sourceforge.net/octave/?rev=10051&view=rev Author: jpicarbajal Date: 2012-03-25 15:01:49 +0000 (Sun, 25 Mar 2012) Log Message: ----------- geometry: Fixing installation clean up and improiving docstring of data2geo Modified Paths: -------------- trunk/octave-forge/main/geometry/PKG_ADD trunk/octave-forge/main/geometry/PKG_DEL trunk/octave-forge/main/geometry/inst/io/data2geo.m Modified: trunk/octave-forge/main/geometry/PKG_ADD =================================================================== --- trunk/octave-forge/main/geometry/PKG_ADD 2012-03-25 14:41:48 UTC (rev 10050) +++ trunk/octave-forge/main/geometry/PKG_ADD 2012-03-25 15:01:49 UTC (rev 10051) @@ -32,4 +32,4 @@ endif warning('off', 'Octave:fopen-file-in-path'); -clear dirlist dirname pp +clear dirlist dirname pp arch pkg_folder dep_folder Modified: trunk/octave-forge/main/geometry/PKG_DEL =================================================================== --- trunk/octave-forge/main/geometry/PKG_DEL 2012-03-25 14:41:48 UTC (rev 10050) +++ trunk/octave-forge/main/geometry/PKG_DEL 2012-03-25 15:01:49 UTC (rev 10051) @@ -30,4 +30,4 @@ endfor endif -clear dirlist dirname pp +clear dirlist dirname pp arch pkg_folder dep_folder Modified: trunk/octave-forge/main/geometry/inst/io/data2geo.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/data2geo.m 2012-03-25 14:41:48 UTC (rev 10050) +++ trunk/octave-forge/main/geometry/inst/io/data2geo.m 2012-03-25 15:01:49 UTC (rev 10051) @@ -16,7 +16,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{fileStr} =} data2geo (@var{data}, @var{lc}) %% @deftypefnx {Function File} {@var{fileStr} =} data2geo (@dots{}, @var{param}, @var{value}) -%% Builds a file compatible with gmsh form data. +%% Uses data to build a file compatible with Gmsh. %% %% @var{data} is assumed to describe a polygon in @code{polygon2d} format. %% The argument @var{lc} specifies the edge size. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-04-12 21:22:54
|
Revision: 10204 http://octave.svn.sourceforge.net/octave/?rev=10204&view=rev Author: jpicarbajal Date: 2012-04-12 21:22:47 +0000 (Thu, 12 Apr 2012) Log Message: ----------- geometry: Adding curveval and cuve2polyline. functions to convert form polygonal curves to polylines. Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION trunk/octave-forge/main/geometry/INDEX trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m Added Paths: ----------- trunk/octave-forge/main/geometry/inst/shape2d/curve2polyline.m trunk/octave-forge/main/geometry/inst/shape2d/curveval.m Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2012-04-12 13:47:32 UTC (rev 10203) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2012-04-12 21:22:47 UTC (rev 10204) @@ -1,11 +1,11 @@ Name: Geometry -Version: 1.4.1 -Date: 2012-03-24 +Version: 1.4.2 +Date: 2012-XX-XX Author: David Legland <dav...@gr...>, José Luis García Pallero <jgp...@gm...>, Juan Pablo Carbajal <car...@if...> Maintainer: Juan Pablo Carbajal <car...@if...> Title: Computational Geometry Description: Library for geometric computing extending MatGeom functions. Useful to create, transform, manipulate and display geometric primitives. -Depends: octave (>= 3.4.0) +Depends: octave (>= 3.4.0), general (>= 1.3.0) Autoload: yes License: GPLv3+, FreeBSD Url: http://octave.sf.net, http://matgeom.sf.net, http://davis.wpi.edu/~matt/courses/clipping/, https://bitbucket.org/jgpallero/octclip Modified: trunk/octave-forge/main/geometry/INDEX =================================================================== --- trunk/octave-forge/main/geometry/INDEX 2012-04-12 13:47:32 UTC (rev 10203) +++ trunk/octave-forge/main/geometry/INDEX 2012-04-12 21:22:47 UTC (rev 10204) @@ -124,6 +124,8 @@ shapecentroid shapeplot shapetransform + curvelval + curve2polyline 2D Others bisector crackPattern2 Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-04-12 13:47:32 UTC (rev 10203) +++ trunk/octave-forge/main/geometry/NEWS 2012-04-12 21:22:47 UTC (rev 10204) @@ -1,6 +1,19 @@ Summary of important user-visible changes for releases of the geometry package =============================================================================== +geometry-1.4.2 Release Date: 2012-XX-XX Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Added function + - curveval.m: Evaluates a polynomial curve defined as a 2-by-N matrix. + - curve2polyline.m: Converts a polynomial curve into a polyline by the adaptive + sampling method. + +* Known issues + - simplifypolygon.m returns empty polygons when points are repeated, i.e when + the polygon is not correctly formed. + +=============================================================================== geometry-1.4.1 Release Date: 2012-03-24 Release Manager: Juan Pablo Carbajal =============================================================================== Added: trunk/octave-forge/main/geometry/inst/shape2d/curve2polyline.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/curve2polyline.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/shape2d/curve2polyline.m 2012-04-12 21:22:47 UTC (rev 10204) @@ -0,0 +1,139 @@ +%% Copyright (c) 2012 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} {@var{polyline} = } curve2polyline (@var{curve}) +%% @deftypefnx {Function File} {@var{polyline} = } curve2polyline (@dots,@var{property},@var{value},@dots) +%% Adaptive sampling of a parametric curve. +%% +%% The @var{curve} is described as a 2-by-N matrix. Rows correspond to the +%% polynomial (compatible with @code{polyval}) describing the respective component +%% of the curve. The curve must be parametrized in the interval [0,1]. +%% The vertices of the polyline are accumulated in regions of the curve where +%% the curvature is higher. +%% +%% @strong{Parameters} +%% @table @samp +%% @item 'Nmax' +%% Maximum number of vertices. Not used. +%% @item 'Tol' +%% Tolerance for the error criteria. Default value @code{1e-4}. +%% @item 'MaxIter' +%% Maximum number of iterations. Default value @code{10}. +%% @item 'Method' +%% Not implemented. +%% @end table +%% +%% @seealso{shape2polygon, curveval} +%% @end deftypefn + +%% This function is based on the algorithm described in +%% L. H. de Figueiredo (1993). "Adaptive Sampling of Parametric Curves". Graphic Gems III. +%% I had to remove the recursion so this version could be improved. +%% Thursday, April 12 2012 -- JuanPi + +function [polyline t bump]= curve2polyline (curve, varargin) + + # --- Parse arguments --- # + parser = inputParser (); + parser.FunctionName = "curve2polyline"; + parser = addParamValue (parser,'Nmax', 32, @(x)x>0); + parser = addParamValue (parser,'Tol', 1e-4, @(x)x>0); + parser = addParamValue (parser,'MaxIter', 10, @(x)x>0); + parser = parse(parser,varargin{:}); + + Nmax = parser.Results.Nmax; + tol = parser.Results.Tol; + MaxIter = parser.Results.MaxIter; + + clear parser + # ------ # + + t = [0; 1]; + tf = 1; + points = 1; + for iter = 1:MaxIter + % Add parameter values where error is still bigger than tol. + t = interleave(t, tf); + nt = length(t); + + % Update error + polyline = curveval (curve,t); + bump = bumpyness(polyline); + + % Check which intervals must be subdivided + idx = find(bump > tol); + % The position of the bumps mpas into intervals + % 1 -> 1 2 + % 2 -> 3 4 + % 3 -> 5 6 + % and so on + idx = [2*(idx-1)+1; 2*idx](:); + tf = false (nt-1,1); + tf(idx) = true; + + if all (!tf) + break; + end + + end + +endfunction + +function f = bumpyness (p) +%% Check for co-linearity +%% TODO implement various method for this +%% -- Area of the triangle close to zero (used currently). +%% -- Angle close to pi. +%% -- abs(p0-pt) + abs(pt-p1) - abs(p0-p1) almost zero. +%% -- Curve's tange at 0,t,1 are almost parallel. +%% -- pt is in chord p0 -> p1. + + PL = p(1:2:end-2,:); + PC = p(2:2:end-1,:); + PR = p(3:2:end,:); + + a = PL - PC; + b = PR - PC; + + f = (a(:,1).*b(:,2) - a(:,2).*b(:,1)).^2; + +endfunction + +function tt = interleave (t,varargin) + + nt = length(t); + ntt = 2 * nt -1; + tt = zeros(ntt,1); + tt(1:2:ntt) = t; + beta = 0.4 + 0.2*rand(nt-1, 1); + tt(2:2:ntt) = t(1:end-1) + beta.*(t(2:end)-t(1:end-1)); + + if nargin > 1 + tf = true (ntt,1); + tf(2:2:ntt) = varargin{1}; + tt(!tf) = []; + end + +endfunction + +%!demo +%! curve = [0 0 1 0;1 -0.3-1 0.3 0]; +%! polyline = curve2polyline(curve,'tol',1e-8); +%! +%! t = linspace(0,1,100)'; +%! pc = curveval(curve,t); +%! +%! plot(p(:,1),p(:,2),'-o',pc(:,1),pc(:,2),'-r') Added: trunk/octave-forge/main/geometry/inst/shape2d/curveval.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/curveval.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/shape2d/curveval.m 2012-04-12 21:22:47 UTC (rev 10204) @@ -0,0 +1,30 @@ +%% Copyright (c) 2012 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} {@var{p} = } curveval (@var{curve}, @var{t}) +%% Evaluates parametric @var{curve} at @var{t}. +%% +%% @end deftypefn +function p = curveval (curve, t) + + dim = size (curve,1); + p = zeros (length(t), dim); + + for i = 1:dim + p(:,i) = polyval (curve(i,:), t); + end + +endfunction Modified: trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-04-12 13:47:32 UTC (rev 10203) +++ trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-04-12 21:22:47 UTC (rev 10204) @@ -21,7 +21,7 @@ %% @var{shape} is a n-by-1 cell where each element is a pair of polynomials %% compatible with polyval. %% @var{polygon} is a k-by-2 matrix, where each row represents a vertex. -%% @var{N} defines the number of points to be used in non-straigth edges. +%% @var{N} defines the number of points to be used in non-straight edges. %% %% @seealso{polygon2shape, drawPolygon} %% @end deftypefn This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-04-15 12:53:47
|
Revision: 10227 http://octave.svn.sourceforge.net/octave/?rev=10227&view=rev Author: jpicarbajal Date: 2012-04-15 11:23:54 +0000 (Sun, 15 Apr 2012) Log Message: ----------- geometry: Ramer-Douglas-Peucker algorithm to simplify polylines. Modified Paths: -------------- trunk/octave-forge/main/geometry/NEWS Added Paths: ----------- trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-04-15 11:00:12 UTC (rev 10226) +++ trunk/octave-forge/main/geometry/NEWS 2012-04-15 11:23:54 UTC (rev 10227) @@ -9,6 +9,11 @@ - curve2polyline.m: Converts a polynomial curve into a polyline by the adaptive sampling method. +* Changed functions + - distancePointEdge.m: Now the function computes the distance between all points + and all edges. A third optional argument provides + backward compatibility. + * Known issues - simplifypolygon.m returns empty polygons when points are repeated, i.e when the polygon is not correctly formed. Added: trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m 2012-04-15 11:23:54 UTC (rev 10227) @@ -0,0 +1,129 @@ +%% Copyright (c) 2012 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 +%% any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} {[@var{pline2} @var{idx}] = } simplifypolyline (@var{pline}) +%% @deftypefnx {Function File} {@dots{} = } simplifypolyline (@dots{},@var{property},@var{value},@dots{}) +%% Simplify or subsample a polyline using the Ramer-Douglas-Peucker algorithm, +%% a.k.a. the iterative end-point fit algorithm or the split-and-merge algorithm. +%% +%% The @var{pline} as a N-by-2 matrix. Rows correspond to the +%% verices (compatible with @code{polygons2d}). The vector @var{idx} constains +%% the indexes on vetices in @var{pline} that generates @var{pline2}, i.e. +%% @code{pline2 = pline(idx,:)}. +%% +%% @strong{Parameters} +%% @table @samp +%% @item 'Nmax' +%% Maximum number of vertices. Default value @code{100}. +%% @item 'Tol' +%% Tolerance for the error criteria. Default value @code{1e-4}. +%% @item 'MaxIter' +%% Maximum number of iterations. Default value @code{10}. +%% @item 'Method' +%% Not implemented. +%% @end table +%% +%% Run @code{demo simplifypolyline} to see an example. +%% +%% @seealso{curve2polyline, curveval} +%% @end deftypefn + +function [pline idx] = simplifypolyline (pline_o, varargin) + + # --- Parse arguments --- # + parser = inputParser (); + parser.FunctionName = "simplifypolyline"; + parser = addParamValue (parser,'Nmax', 100, @(x)x>0); + parser = addParamValue (parser,'Tol', 1e-4, @(x)x>0); + parser = addParamValue (parser,'MaxIter', 100, @(x)x>0); + parser = parse(parser,varargin{:}); + + Nmax = parser.Results.Nmax; + tol = parser.Results.Tol; + MaxIter = parser.Results.MaxIter; + + clear parser + msg = ["Maximum number of points reached with maximal error %g." ... + " Increase '%s' if the result is not satisfactory."]; + # ------ # + + [N dim] = size(pline_o); + idx = [1 N]; + + for iter = 1:MaxIter + % Find the point with the maximum distance. + [dist ii] = maxdistance (pline_o, idx); + + if dist < tol; + break; + end + + idx(end+1) = ii; + idx = sort(idx); + + if length(idx) >= Nmax + warning('geometry:MayBeWrongOutput', sprintf(msg,dist,'Nmax')); + break; + end + + end + if iter == MaxIter + warning('geometry:MayBeWrongOutput', sprintf(msg,dist,'MaxIter')); + end + + pline = pline_o(idx,:); +endfunction + +function [dist ii] = maxdistance (p,idx) + + edges = [p(idx(1:end-1),:) p(idx(2:end),:)]; + %% Calculate distance between all points and edges + %% What is better? this or a only comparing the points that are between the extrema + %% of each edge. + [d pos] = distancePointEdge (p, edges); + + %% Filter out all points outside the edges + tf = pos == 0 | pos == 1; + d(tf) = -1; + + [dist j] = max(d(:)); + ii = ind2sub (size(d),j); + +end + +%!demo +%! t = linspace(0,1,100).'; +%! y = polyval([1 -1.5 0.5 0],t); +%! pline = [t y]; +%! +%! figure(1) +%! clf +%! plot (t,y,'-r;Original;','linewidth',2); +%! hold on +%! +%! tol = [8 2 1 0.5]*1e-2; +%! colors = jet(4); +%! +%! for i=1:4 +%! pline_ = simplifypolyline(pline,'tol',tol(i)); +%! msg = sprintf('-;%g;',tol(i)); +%! h = plot (pline_(:,1),pline_(:,2),msg); +%! set(h,'color',colors(i,:),'linewidth',2,'markersize',4); +%! end +%! hold off +%! +%! % --------------------------------------------------------- +%! % Four approximations of the initial polyline with decreasing tolerances. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-04-15 14:30:01
|
Revision: 10228 http://octave.svn.sourceforge.net/octave/?rev=10228&view=rev Author: jpicarbajal Date: 2012-04-15 14:29:54 +0000 (Sun, 15 Apr 2012) Log Message: ----------- geometry: Ramer-Douglas-Peucker algorithm to simplify polylines and polygons. Modified Paths: -------------- trunk/octave-forge/main/geometry/NEWS trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m Modified: trunk/octave-forge/main/geometry/NEWS =================================================================== --- trunk/octave-forge/main/geometry/NEWS 2012-04-15 11:23:54 UTC (rev 10227) +++ trunk/octave-forge/main/geometry/NEWS 2012-04-15 14:29:54 UTC (rev 10228) @@ -4,12 +4,13 @@ geometry-1.4.2 Release Date: 2012-XX-XX Release Manager: Juan Pablo Carbajal =============================================================================== -* Added function +* Added functions: - curveval.m: Evaluates a polynomial curve defined as a 2-by-N matrix. - curve2polyline.m: Converts a polynomial curve into a polyline by the adaptive sampling method. + - simplifypolyline.m: Ramer-Douglas-Peucker algorithm to simplify polylines. -* Changed functions +* Changed functions: - distancePointEdge.m: Now the function computes the distance between all points and all edges. A third optional argument provides backward compatibility. Modified: trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m 2012-04-15 11:23:54 UTC (rev 10227) +++ trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m 2012-04-15 14:29:54 UTC (rev 10228) @@ -42,6 +42,7 @@ %% @end deftypefn function [pline idx] = simplifypolyline (pline_o, varargin) +%% TODO do not print warnings if user provided Nmax or MaxIter. # --- Parse arguments --- # parser = inputParser (); @@ -67,11 +68,13 @@ % Find the point with the maximum distance. [dist ii] = maxdistance (pline_o, idx); - if dist < tol; + tf = dist > tol; + n = sum(tf); + if all(!tf); break; end - idx(end+1) = ii; + idx(end+1:end+n) = ii(tf); idx = sort(idx); if length(idx) >= Nmax @@ -87,22 +90,29 @@ pline = pline_o(idx,:); endfunction -function [dist ii] = maxdistance (p,idx) +function [dist ii] = maxdistance (p, idx) + %% Separate the groups of points according to the edge they can divide. + func = @(x,y) x:y; + idxc = arrayfun (func, idx(1:end-1), idx(2:end), "UniformOutput",false); + points = cellfun (@(x)p(x,:), idxc, "UniformOutput",false); + + %% Build the edges edges = [p(idx(1:end-1),:) p(idx(2:end),:)]; - %% Calculate distance between all points and edges - %% What is better? this or a only comparing the points that are between the extrema - %% of each edge. - [d pos] = distancePointEdge (p, edges); + edges = mat2cell (edges, ones(1,size(edges,1)), 4)'; - %% Filter out all points outside the edges - tf = pos == 0 | pos == 1; - d(tf) = -1; + %% Calculate distance between the points and the corresponding edge + [dist ii] = cellfun(@dd, points,edges,idxc); - [dist j] = max(d(:)); - ii = ind2sub (size(d),j); +endfunction -end +function [dist ii] = dd (p,e,idx) + [d pos] = distancePointEdge(p,e); + tf = abs(pos) <= abs(pos*eps) | abs(pos-1) <= abs((pos-1)*eps); + d(tf) = -1; + [dist ii] = max(d); + ii = idx(ii); +endfunction %!demo %! t = linspace(0,1,100).'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |