From: <car...@us...> - 2011-09-27 12:37:40
|
Revision: 8612 http://octave.svn.sourceforge.net/octave/?rev=8612&view=rev Author: carandraug Date: 2011-09-27 12:37:29 +0000 (Tue, 27 Sep 2011) Log Message: ----------- geometry: small fixes on TexInfo documentation Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/data2geo.m trunk/octave-forge/main/geometry/inst/svgnormalize.m Modified: trunk/octave-forge/main/geometry/inst/data2geo.m =================================================================== --- trunk/octave-forge/main/geometry/inst/data2geo.m 2011-09-27 12:34:58 UTC (rev 8611) +++ trunk/octave-forge/main/geometry/inst/data2geo.m 2011-09-27 12:37:29 UTC (rev 8612) @@ -14,7 +14,7 @@ %% along with this program. If not, see <http://www.gnu.org/licenses/>. %% -*- texinfo -*- -%% @deftypefn {Function File} @var{fileStr} = data2geo (@var{data}, @var{lc},@{opt}) +%% @deftypefn {Function File} {@var{fileStr} =} data2geo (@var{data}, @var{lc},@var{opt}) %% Takes data assuming certain order and builds a .geo file compatible with gmsh. %% %% @end deftypefn Modified: trunk/octave-forge/main/geometry/inst/svgnormalize.m =================================================================== --- trunk/octave-forge/main/geometry/inst/svgnormalize.m 2011-09-27 12:34:58 UTC (rev 8611) +++ trunk/octave-forge/main/geometry/inst/svgnormalize.m 2011-09-27 12:37:29 UTC (rev 8612) @@ -15,7 +15,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} @var{SVGn} = loadSVG (@var{SVG}) -%% Scales and reflects the @var{SVG} structure and returns a modified \var{SVGn} +%% 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2011-09-27 14:13:16
|
Revision: 8617 http://octave.svn.sourceforge.net/octave/?rev=8617&view=rev Author: carandraug Date: 2011-09-27 14:13:05 +0000 (Tue, 27 Sep 2011) Log Message: ----------- geometry package: demo indetation fix to look nice on html Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/data2geo.m trunk/octave-forge/main/geometry/inst/svgload.m trunk/octave-forge/main/geometry/inst/svgnormalize.m Modified: trunk/octave-forge/main/geometry/inst/data2geo.m =================================================================== --- trunk/octave-forge/main/geometry/inst/data2geo.m 2011-09-27 14:02:10 UTC (rev 8616) +++ trunk/octave-forge/main/geometry/inst/data2geo.m 2011-09-27 14:13:05 UTC (rev 8617) @@ -79,6 +79,6 @@ end %!demo -%! points = [0 0 0; 0.1 0 0; 0.1 .3 0; 0 0.3 0]; +%! points = [0 0 0; 0.1 0 0; 0.1 .3 0; 0 0.3 0]; %! strFile = data2geo(points,0.009); %! disp(strFile) Modified: trunk/octave-forge/main/geometry/inst/svgload.m =================================================================== --- trunk/octave-forge/main/geometry/inst/svgload.m 2011-09-27 14:02:10 UTC (rev 8616) +++ trunk/octave-forge/main/geometry/inst/svgload.m 2011-09-27 14:13:05 UTC (rev 8617) @@ -50,12 +50,12 @@ end %!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); +%! 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 = svgload (file); %! SVG %! plot([SVG.path.coord(:,1); SVG.path.coord(1,1)], ... %! [SVG.path.coord(:,2); SVG.path.coord(1,2)]); Modified: trunk/octave-forge/main/geometry/inst/svgnormalize.m =================================================================== --- trunk/octave-forge/main/geometry/inst/svgnormalize.m 2011-09-27 14:02:10 UTC (rev 8616) +++ trunk/octave-forge/main/geometry/inst/svgnormalize.m 2011-09-27 14:13:05 UTC (rev 8617) @@ -55,13 +55,13 @@ end %!demo -%! file = 'tmp__.svg'; -%! fid = fopen (file,'w'); +%! 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); +%! 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)]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-10-07 16:09:42
|
Revision: 8710 http://octave.svn.sourceforge.net/octave/?rev=8710&view=rev Author: jpicarbajal Date: 2011-10-07 16:09:34 +0000 (Fri, 07 Oct 2011) Log Message: ----------- geomtry. adding more examples Added Paths: ----------- trunk/octave-forge/main/geometry/inst/drawing4.svg trunk/octave-forge/main/geometry/inst/drawing5.svg Added: trunk/octave-forge/main/geometry/inst/drawing4.svg =================================================================== --- trunk/octave-forge/main/geometry/inst/drawing4.svg (rev 0) +++ trunk/octave-forge/main/geometry/inst/drawing4.svg 2011-10-07 16:09:34 UTC (rev 8710) @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.1" + width="10.093468" + height="10.077768" + id="svg2" + inkscape:version="0.48.1 r9760" + sodipodi:docname="drawing4.svg"> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1051" + id="namedview7" + showgrid="false" + fit-margin-top="0" + fit-margin-left="0" + fit-margin-right="0" + fit-margin-bottom="0" + inkscape:zoom="18.637828" + inkscape:cx="12.671325" + inkscape:cy="-0.4886908" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1" + inkscape:current-layer="svg2" /> + <defs + id="defs4" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + transform="matrix(0.05339844,0,0,0.04372301,-14.737707,-8.0221913)" + id="layer1"> + <path + d="M 347.10409,408.80282 C 488.15538,326.906 506.47395,89.791201 346.92957,234.49032 c -123.81192,-133.25454 -42.61413,174.3125 0.17452,174.3125 z" + id="path2991" + style="fill:none;stroke:#000000;stroke-width:10.3478632;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + inkscape:connector-curvature="0" /> + </g> +</svg> Added: trunk/octave-forge/main/geometry/inst/drawing5.svg =================================================================== --- trunk/octave-forge/main/geometry/inst/drawing5.svg (rev 0) +++ trunk/octave-forge/main/geometry/inst/drawing5.svg 2011-10-07 16:09:34 UTC (rev 8710) @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="100.5" + height="100.5" + id="svg2" + version="1.1" + inkscape:version="0.48.1 r9760" + sodipodi:docname="New document 1"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.35" + inkscape:cx="952.39286" + inkscape:cy="-482.11218" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + fit-margin-top="0" + fit-margin-left="0" + fit-margin-right="0" + fit-margin-bottom="0" + inkscape:window-width="1440" + inkscape:window-height="844" + inkscape:window-x="0" + inkscape:window-y="1080" + inkscape:window-maximized="1" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(50.25,50.25)"> + <path + style="fill:none;stroke:#000000;stroke-width:0.5;stroke-linecap:square;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1" + d="M 50,0 C 50,27.614237 27.614237,50 0,50 -27.614237,50 -50,27.614237 -50,0 c 0,-27.614237 22.385763,-50 50,-50 27.614237,0 50,22.385763 50,50 z" + id="path3756" /> + </g> +</svg> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-09-19 21:18:36
|
Revision: 11054 http://octave.svn.sourceforge.net/octave/?rev=11054&view=rev Author: jpicarbajal Date: 2012-09-19 21:18:26 +0000 (Wed, 19 Sep 2012) Log Message: ----------- geometry: Starting port of geom3d Added Paths: ----------- trunk/octave-forge/main/geometry/inst/geom3d/ trunk/octave-forge/main/geometry/inst/geom3d/anglePoints3d.m trunk/octave-forge/main/geometry/inst/geom3d/angles3d.m trunk/octave-forge/main/geometry/inst/geom3d/boxes3d.m trunk/octave-forge/main/geometry/inst/geom3d/circles3d.m trunk/octave-forge/main/geometry/inst/geom3d/geom3d_Contents.m Added: trunk/octave-forge/main/geometry/inst/geom3d/anglePoints3d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/anglePoints3d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/anglePoints3d.m 2012-09-19 21:18:26 UTC (rev 11054) @@ -0,0 +1,106 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} {@var{alpha} =} anglePoints3d (@var{p1}, @var{p2}) +## @deftypefnx {Function File} {@var{alpha} =} anglePoints3d (@var{p1}, @var{p2},@var{p3}) +## @deftypefnx {Function File} {@var{alpha} =} anglePoints3d (@var{pts}) +## Compute angle between three 3D points +## +## @var{alpha} = anglePoints3d(P1, P2) +## Computes angle (P1, O, P2), in radians, between 0 and PI. +## +## @var{alpha} = anglePoints3d(P1, P2, P3) +## Computes angle (P1, P2, P3), in radians, between 0 and PI. +## +## @var{alpha} = anglePoints3d(PTS) +## PTS is a 3x3 or 2x3 array containing coordinate of points. +## +## @seealso{points3d, angles3d} +## @end deftypefn + +function alpha = anglePoints3d(varargin) + + p2 = [0 0 0]; + if length(varargin)==1 + pts = varargin{1}; + if size(pts, 1)==2 + p1 = pts(1,:); + p0 = [0 0 0]; + p2 = pts(2,:); + else + p1 = pts(1,:); + p0 = pts(2,:); + p2 = pts(3,:); + end + elseif length(varargin)==2 + p1 = varargin{1}; + p0 = [0 0 0]; + p2 = varargin{2}; + elseif length(varargin)==3 + p1 = varargin{1}; + p0 = varargin{2}; + p2 = varargin{3}; + end + + # ensure all data have same size + n1 = size(p1, 1); + n2 = size(p2, 1); + n0 = size(p0, 1); + if n1~=n2 + if n1==1 + p1 = repmat(p1, [n2 1]); + elseif n2==1 + p2 = repmat(p2, [n1 1]); + else + error('Arguments P1 and P2 must have the same size'); + end + end + if n1~=n0 + if n1==1 + p1 = repmat(p1, [n0 1]); + elseif n0==1 + p0 = repmat(p0, [n1 1]); + else + error('Arguments P1 and P0 must have the same size'); + end + end + + # normalized vectors + p1 = normalizeVector(p1-p0); + p2 = normalizeVector(p2-p0); + + # compute angle + alpha = acos(dot(p1, p2, 2)); + +endfunction Added: trunk/octave-forge/main/geometry/inst/geom3d/angles3d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/angles3d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/angles3d.m 2012-09-19 21:18:26 UTC (rev 11054) @@ -0,0 +1,75 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} angles3d () +##ANGLES3D Conventions for manipulating angles in 3D +## +## Contrary to the plane, there are no oriented angles in 3D. Angles +## between lines or between planes are comprised between 0 and PI. +## +## Spherical angles +## Spherical angles are defined by 2 angles: +## * THETA, the colatitude, representing angle with Oz axis (between 0 and +## PI) +## * PHI, the azimut, representing angle with Ox axis of horizontal +## projection of the direction (between 0 and 2*PI) +## +## Spherical coordinates can be represented by THETA, PHI, and the +## distance RHO to the origin. +## +## Euler angles +## Some functions for creating rotations use Euler angles. They follow the +## ZYX convention in the global reference system, that is eqivalent to the +## XYZ convention ine a local reference system. +## Euler angles are given by a triplet of angles [PHI THETA PSI] that +## represents the succession of 3 rotations: +## * rotation around X by angle PSI ("roll") +## * rotation around Y by angle THETA ("pitch") +## * rotation around Z by angle PHI ("yaw") +## +## In this library, euler angles are given in degrees. The functions that +## use euler angles use the keyword 'Euler' in their name. +## +## +## @seealso{cart2sph2, sph2cart2, cart2sph2d, sph2cart2d +## anglePoints3d, angleSort3d, sphericalAngle, randomAngle3d +## dihedralAngle, polygon3dNormalAngle, eulerAnglesToRotation3d +## rotation3dAxisAndAngle, rotation3dToEulerAngles} +## @end deftypefn + +function angles3d() + + help angles3d + +endfunction Added: trunk/octave-forge/main/geometry/inst/geom3d/boxes3d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/boxes3d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/boxes3d.m 2012-09-19 21:18:26 UTC (rev 11054) @@ -0,0 +1,57 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} boxes3d () +## BOXES3D Description of functions operating on 3D boxes +## +## A box defined by its coordinate extents: +## BOX = [XMIN XMAX YMIN YMAX ZMIN ZMAX]. +## +## Example +## # Draw a polyhedron together with its bounding box +## [n e f]= createIcosahedron; +## drawPolyhedron(n, f); +## hold on; +## drawBox3d(point3dBounds(n)) +## +## +## @seealso{point3dBounds, box3dVolume, drawBox3d +## intersectBoxes3d, mergeBoxes3d, randomPointInBox3d} +## @end deftypefn + +function boxes3d() + + help boxes3d + +endfunction Added: trunk/octave-forge/main/geometry/inst/geom3d/circles3d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/circles3d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/circles3d.m 2012-09-19 21:18:26 UTC (rev 11054) @@ -0,0 +1,54 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} circles3d () +##CIRCLES3D Description of functions operating on 3D circles +## +## Circles are represented by a center, a radius and a 3D angle +## representing the normal of the plane containing the circle. +## C = [xc yc zc R theta phi psi]. +## THETA is the colatitude of the normal, in degrees, between 0 and 180 +## PHI is the azimut of the normal, in degrees, between 0 and 360 +## PSI is the proper rotation of the circle around the normal, between 0 +## and 360 degrees +## The parameter PSI is used to locate a point on the 3D circle. +## +## @seealso{circle3dOrigin, circle3dPosition, circle3dPoint, intersectPlaneSphere +## drawCircle3d, drawCircleArc3d, drawEllipse3d} +## @end deftypefn +function circles3d () + + help circles3d + +endfunction Added: trunk/octave-forge/main/geometry/inst/geom3d/geom3d_Contents.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/geom3d_Contents.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/geom3d_Contents.m 2012-09-19 21:18:26 UTC (rev 11054) @@ -0,0 +1,237 @@ +## 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} geom3d_Contents () +## GEOM3D Geometry 3D Toolbox +## Version 1.0 21-Mar-2011 . +## +## Creation, transformations, algorithms and visualization of geometrical +## 3D primitives, such as points, lines, planes, polyhedra, circles and +## spheres. +## +## Euler Angles are defined as follow: +## PHI is the azimut, i.e. the angle of the projection on horizontal plane +## with the Ox axis, with value beween 0 and 180 degrees. +## THETA is the latitude, i.e. the angle with the Oz axis, with value +## between -90 and +90 degrees. +## PSI is the 'roll', i.e. the rotation around the (PHI, THETA) direction, +## with value in degrees +## See also the 'angles3d' page. +## +## Base format for primitives: +## Point: [x0 y0 z0] +## Vector: [dx dy dz] +## Line: [x0 y0 z0 dx dy dz] +## Edge: [x1 y1 z1 x2 y2 z2] +## Plane: [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2] +## Sphere: [x0 y0 z0 R] +## Circle: [x0 y0 z0 R PHI THETA PSI] (origin+center+normal+'roll'). +## Cylinder: [X1 Y1 Z1 X2 Y2 Z2 R] +## Box: [xmin xmax ymin ymax zmin zmax]. Used for clipping shapes. +## +## Polygons are represented by N-by-3 array of points, the last point is +## not necessarily the same as the first one. Points must be coplanar. +## +## Meshes and Polyhedra are represented by a couple of variables {V, F}: +## V: N-by-3 array of vetrtices: [x1 y1 z1; ... ;xn yn zn]; +## F: is either a [Nf*3] or [Nf*4] array containing reference for vertices +## of each face, or a [Nf*1] cell array, where each cell is an array +## containing a variable number of node indices. +## For some functions, the array E of edges is needed. It consists in a +## Ne-by-2 array containing indices of source and target vertices. +## +## +## 3D Points +## points3d - Description of functions operating on 3D points +## midPoint3d - Middle point of two 3D points or of a 3D edge +## isCoplanar - Tests input points for coplanarity in 3-space. +## transformPoint3d - Transform a point with a 3D affine transform +## distancePoints3d - Compute euclidean distance between pairs of 3D Points +## clipPoints3d - Clip a set of points by a box +## drawPoint3d - Draw 3D point on the current axis. +## +## 3D Vectors +## vectors3d - Description of functions operating on 3D vectors +## transformVector3d - Transform a vector with a 3D affine transform +## normalizeVector3d - Normalize a 3D vector to have norm equal to 1 +## vectorNorm3d - Norm of a 3D vector or of set of 3D vectors +## vectorAngle3d - Angle between two 3D vectors +## isParallel3d - Check parallelism of two 3D vectors +## isPerpendicular3d - Check orthogonality of two 3D vectors +## +## Angles +## angles3d - Conventions for manipulating angles in 3D +## anglePoints3d - Compute angle between three 3D points +## sphericalAngle - Compute angle between points on the sphere +## angleSort3d - Sort 3D coplanar points according to their angles in plane +## randomAngle3d - Return a 3D angle uniformly distributed on unit sphere +## +## Coordinate transforms +## sph2cart2 - Convert spherical coordinates to cartesian coordinates +## cart2sph2 - Convert cartesian coordinates to spherical coordinates +## cart2sph2d - Convert cartesian coordinates to spherical coordinates in degrees +## sph2cart2d - Convert spherical coordinates to cartesian coordinates in degrees +## cart2cyl - Convert cartesian to cylindrical coordinates +## cyl2cart - Convert cylindrical to cartesian coordinates +## +## 3D Lines and Edges +## lines3d - Description of functions operating on 3D lines +## createLine3d - Create a line with various inputs. +## transformLine3d - Transform a 3D line with a 3D affine transform +## clipLine3d - Clip a line with a box and return an edge +## midPoint3d - Middle point of two 3D points or of a 3D edge +## distancePointLine3d - Euclidean distance between 3D point and line +## distanceLines3d - Minimal distance between two 3D lines +## linePosition3d - Return the position of a 3D point on a 3D line +## drawEdge3d - Draw 3D edge in the current Window +## drawLine3d - Draw a 3D line on the current axis +## +## Planes +## planes3d - Description of functions operating on 3D planes +## createPlane - Create a plane in parametrized form +## normalizePlane - Normalize parametric representation of a plane +## intersectPlanes - Return intersection line between 2 planes in space +## intersectLinePlane - Return intersection point between a plane and a line +## intersectEdgePlane - Return intersection point between a plane and a edge +## distancePointPlane - Signed distance betwen 3D point and plane +## projPointOnPlane - Return the orthogonal projection of a point on a plane +## isBelowPlane - Test whether a point is below or above a plane +## medianPlane - Create a plane in the middle of 2 points +## planeNormal - Compute the normal to a plane +## planePosition - Compute position of a point on a plane +## planePoint - Compute 3D position of a point in a plane +## dihedralAngle - Compute dihedral angle between 2 planes +## drawPlane3d - Draw a plane clipped in the current window +## +## 3D Polygons and curves +## polygons3d - Description of functions operating on 3D polygons +## polygonCentroid3d - Centroid (or center of mass) of a polygon +## triangleArea3d - Area of a 3D triangle +## polygon3dNormalAngle - Normal angle at a vertex of the 3D polygon +## intersectLinePolygon3d - Intersection point of a 3D line and a 3D polygon +## intersectLineTriangle3d - Intersection point of a 3D line and a 3D triangle +## intersectRayPolygon3d - Intersection point of a 3D ray and a 3D polygon +## clipConvexPolygon3dHP - Clip a convex 3D polygon with Half-space +## drawPolygon3d - Draw a 3D polygon specified by a list of vertices +## drawPolyline3d - Draw a 3D polyline specified by a list of vertices +## fillPolygon3d - Fill a 3D polygon specified by a list of points +## +## 3D circles and ellipses +## circles3d - Description of functions operating on 3D circles +## circle3dPosition - Return the angular position of a point on a 3D circle +## circle3dPoint - Coordinates of a point on a 3D circle from its position +## circle3dOrigin - Return the first point of a 3D circle +## drawCircle3d - Draw a 3D circle +## drawCircleArc3d - Draw a 3D circle arc +## drawEllipse3d - Draw a 3D ellipse +## +## Spheres +## spheres - Description of functions operating on 3D spheres +## createSphere - Create a sphere containing 4 points +## intersectLineSphere - Return intersection points between a line and a sphere +## intersectPlaneSphere - Return intersection circle between a plane and a sphere +## drawSphere - Draw a sphere as a mesh +## drawSphericalTriangle - Draw a triangle on a sphere +## +## Smooth surfaces +## inertiaEllipsoid - Inertia ellipsoid of a set of 3D points +## intersectLineCylinder - Compute intersection points between a line and a cylinder +## revolutionSurface - Create a surface of revolution from a planar curve +## surfaceCurvature - Curvature on a surface from angle and principal curvatures +## drawEllipsoid - Draw a 3D ellipsoid +## drawTorus - Draw a torus (3D ring) +## drawCylinder - Draw a cylinder +## drawSurfPatch - Draw a 3D surface patch, with 2 parametrized surfaces +## +## Bounding boxes management +## boxes3d - Description of functions operating on 3D boxes +## point3dBounds - Bounding box of a set of 3D points +## intersectBoxes3d - Intersection of two 3D bounding boxes +## mergeBoxes3d - Merge 3D boxes, by computing their greatest extent +## box3dVolume - Volume of a 3-dimensional box +## randomPointInBox3d - Generate random point(s) within a 3D box +## drawBox3d - Draw a 3D box defined by coordinate extents +## +## Geometric transforms +## transforms3d - Conventions for manipulating 3D affine transforms +## createTranslation3d - Create the 4x4 matrix of a 3D translation +## createScaling3d - Create the 4x4 matrix of a 3D scaling +## createRotationOx - Create the 4x4 matrix of a 3D rotation around x-axis +## createRotationOy - Create the 4x4 matrix of a 3D rotation around y-axis +## createRotationOz - Create the 4x4 matrix of a 3D rotation around z-axis +## createBasisTransform3d - Compute matrix for transforming a basis into another basis +## eulerAnglesToRotation3d - Convert 3D Euler angles to 3D rotation matrix +## rotation3dToEulerAngles - Extract Euler angles from a rotation matrix +## createRotation3dLineAngle - Create rotation around a line by an angle theta +## rotation3dAxisAndAngle - Determine axis and angle of a 3D rotation matrix +## recenterTransform3d - Change the fixed point of an affine 3D transform +## composeTransforms3d - Concatenate several space transformations +## +## Various drawing Functions +## drawGrid3d - Draw a 3D grid on the current axis +## drawAxis3d - Draw a coordinate system and an origin +## drawAxisCube - Draw a colored cube representing axis orientation +## drawCube - Draw a 3D centered cube, eventually rotated +## drawCuboid - Draw a 3D cuboid, eventually rotated +## +## +## Credits: +## * function isCoplanar was originally written by Brett Shoelson. +## * Songbai Ji enhanced file intersectPlaneLine (6/23/2006). +## +## @end deftypefn + +function geom3d_Contents () + + help('geom3d_Contents'); + + ## In development: + ## clipPolygon3dHP - clip a 3D polygon with Half-space + ## drawPartialPatch - draw surface patch, with 2 parametrized surfaces + + + ## Deprecated: + ## intersectPlaneLine - return intersection between a plane and a line + ## translation3d - return 4x4 matrix of a 3D translation + ## scale3d - return 4x4 matrix of a 3D scaling + ## rotationOx - return 4x4 matrix of a rotation around x-axis + ## rotationOy - return 4x4 matrix of a rotation around y-axis + ## rotationOz - return 4x4 matrix of a rotation around z-axis + ## scaling3d - return 4x4 matrix of a 3D scaling + ## vecnorm3d - compute norm of vector or of set of 3D vectors + ## normalize3d - normalize a 3D vector + ## drawCurve3d - draw a 3D curve specified by a list of points + ## createEulerAnglesRotation - Create a rotation matrix from 3 euler angles + +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-09-19 22:10:47
|
Revision: 11055 http://octave.svn.sourceforge.net/octave/?rev=11055&view=rev Author: jpicarbajal Date: 2012-09-19 22:10:39 +0000 (Wed, 19 Sep 2012) Log Message: ----------- geometry: Ported all content files Added Paths: ----------- trunk/octave-forge/main/geometry/inst/geom3d/lines3d.m trunk/octave-forge/main/geometry/inst/geom3d/planes3d.m trunk/octave-forge/main/geometry/inst/geom3d/points3d.m trunk/octave-forge/main/geometry/inst/geom3d/polygons3d.m trunk/octave-forge/main/geometry/inst/geom3d/vectors3d.m trunk/octave-forge/main/geometry/inst/graphs/graphs_Contents.m trunk/octave-forge/main/geometry/inst/meshes3d/ trunk/octave-forge/main/geometry/inst/meshes3d/meshes3d_Contents.m Added: trunk/octave-forge/main/geometry/inst/geom3d/lines3d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/lines3d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/lines3d.m 2012-09-19 22:10:39 UTC (rev 11055) @@ -0,0 +1,49 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} lines3d () +##LINES3D Description of functions operating on 3D lines +## +## A 3D Line is represented by a 3D point (its origin) and a 3D vector +## (its direction): +## LINE = [X0 Y0 Z0 DX DY DZ]; +## +## @seealso{createLine3d, transformLine3d, distancePointLine3d, linePosition3d +## intersectLinePlane, distanceLines3d, clipLine3d, drawLine3d} +## @end deftypefn +function lines3d() + + help lines3d + +endfunction Added: trunk/octave-forge/main/geometry/inst/geom3d/planes3d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/planes3d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/planes3d.m 2012-09-19 22:10:39 UTC (rev 11055) @@ -0,0 +1,51 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} planes3d () +##PLANES3D Description of functions operating on 3D planes +## +## Planes are represented by a 3D point (the plane origin) and 2 direction +## vectors, which should not be colinear. +## PLANE = [X0 Y0 Z0 DX1 DY1 DZ1 DX2 DY2 DZ2]; +## +## @seealso{createPlane, medianPlane, normalizePlane, +## planeNormal, planePosition, dihedralAngle, +## intersectPlanes, projPointOnPlane, isBelowPlane, +## intersectLinePlane, intersectEdgePlane, distancePointPlane, drawPlane3d} +## @end deftypefn +function planes3d(varargin) + + help planes3d + +endfunction Added: trunk/octave-forge/main/geometry/inst/geom3d/points3d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/points3d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/points3d.m 2012-09-19 22:10:39 UTC (rev 11055) @@ -0,0 +1,50 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} points3d () +##POINTS3D Description of functions operating on 3D points +## +## Points are represented by their 3 Cartesian coordinates: +## P = [X Y Z]; +## +## Arrays of points consist in N*3 arrays, each row being a point. +## +## @seealso{isCoplanar, distancePoints, anglePoints3d, angleSort3d, sphericalAngle, +## sph2cart2, cart2sph2, cart2cyl, cyl2cart, transformPoint3d, clipPoints3d} +## @end deftypefn +function points3d() + + help points3d + +endfunction Added: trunk/octave-forge/main/geometry/inst/geom3d/polygons3d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/polygons3d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/polygons3d.m 2012-09-19 22:10:39 UTC (rev 11055) @@ -0,0 +1,51 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} polygons3d () +## POLYGONS3D Description of functions operating on 3D polygons +## +## A 3D polygon is simply a set of 3D points (called vertices) which are +## assumed to be located in the same plane. +## Several functions are provided for computing basic geometrical +## parameters (centroid, angles), or intersections with lines or planes. +## +## @seealso{polygon3dNormalAngle, polygonCentroid3d, clipConvexPolygon3dHP +## intersectLinePolygon3d, intersectLineTriangle3d, intersectRayPolygon3d +## drawPolygon3d, drawPolyline3d, fillPolygon3d} +## @end deftypefn +function polygons3d() + + help polygons3d + +endfunction Added: trunk/octave-forge/main/geometry/inst/geom3d/vectors3d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom3d/vectors3d.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom3d/vectors3d.m 2012-09-19 22:10:39 UTC (rev 11055) @@ -0,0 +1,53 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} vectors3d () +##VECTORS3D Description of functions operating on 3D vectors +## +## Vectors are represented by their 3 Cartesian coordinates: +## V = [VX VY VZ]; +## +## List of vectors are represented by N*3 arrays, with the coordinates of +## each vector on a row. +## +## +## @seealso{vectorNorm3d, normalizeVector3d, vectorAngle3d isParallel3d, +## isPerpendicular3d, createTranslation3d} +## @end deftypefn + +function vectors3d(varargin) + + help vectors3d + +endfunction Added: trunk/octave-forge/main/geometry/inst/graphs/graphs_Contents.m =================================================================== --- trunk/octave-forge/main/geometry/inst/graphs/graphs_Contents.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/graphs/graphs_Contents.m 2012-09-19 22:10:39 UTC (rev 11055) @@ -0,0 +1,142 @@ +## Copyright (C) 2011 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. + +## -*- texinfo -*- +## @deftypefn {Function File} graphs_Contents () +## GRAPHS Simple Toolbox for manipulating Geometric Graphs +## Version 0.5 11-Apr-2010 . +## +## The aim of this package is to provides functions to easily create, +## modify and display geometric graphs (geometric in a sense position +## of vertices is kept in memory). +## +## Graph structure is represented by at least two arrays: +## * NODES, which contains coordinates of each vertex +## * EDGES, which contains indices of start and end vertex. +## +## Others arrays may sometimes be used: +## * FACES, which contains indices of vertices of each face (either a +## double array, or a cell array) +## * CELLS, which contains indices of faces of each cell. +## +## An alternative representation is to use a structure, with fields: +## * edges +## * faces +## * cells +## corresponding to the data described above. +## +## Note that topological description of 2D graph is entirely contained in +## EDGES array, and that NODES array is used only to display graph +## +## Caution: this type of data structure is easy to create and to manage, +## but may be very inefficient for some algorithms. +## +## Graphs are usually considered as non-oriented in this package. +## +## +## Graph creation +## knnGraph - Create the k-nearest neighbors graph of a set of points +## delaunayGraph - Graph associated to Delaunay triangulation of input points +## euclideanMST - Build euclidean minimal spanning tree of a set of points +## prim_mst - Minimal spanning tree by Prim's algorithm +## +## Create graph from images +## imageGraph - Create equivalent graph of a binary image +## boundaryGraph - Get boundary of image as a graph +## gcontour2d - Creates contour graph of a 2D binary image. +## gcontour3d - Create contour graph of a 3D binary image. +## vectorize - Transform a binary skeleton into a graph (nodes and edges) +## +## Graph information +## grNodeDegree - Degree of a node in a (undirected) graph +## grNodeInnerDegree - Inner degree of a node in a graph +## grNodeOuterDegree - Outer degree of a node in a graph +## grNeighborNodes - Find adjacent nodes of a given node +## grNeighborEdges - Find adjacent edges of a given node +## grOppositeNode - Return opposite node in an edge +## grLabel - Associate a label to each connected component of the graph +## +## Graph management (low level operations) +## grRemoveNode - Remove a node in a graph +## grRemoveNodes - Remove several nodes in a graph +## grRemoveEdge - Remove an edge in a graph. +## grRemoveEdges - Remove several edges from a graph +## +## Graph processing (general applications) +## mergeGraphs - Merge two graphs, by adding nodes, edges and faces lists. +## grMergeNodes - Merge two (or more) nodes in a graph. +## grMergeMultipleNodes - Simplify a graph by merging multiple nodes +## grMergeMultipleEdges - Remove all edges sharing the same extremities +## grSimplifyBranches - Replace branches of a graph by single edges +## +## Filtering operations on Graph +## grMean - Compute mean from neihgbours +## grMedian - Compute median from neihgbours +## grDilate - Morphological dilation on graph +## grErode - Morphological erosion on graph +## grClose - Morphological closing on graph +## grOpen - Morphological opening on graph +## +## Geodesic operations +## grPropagateDistance - Propagates distances from a vertex to other vertices +## grVertexEccentricity - Eccentricity of vertices in the graph +## graphDiameter - Diameter of a graph +## graphPeripheralVertices - Peripheral vertices of a graph +## graphCenter - Center of a graph +## graphRadius - Radius of a graph +## grFindGeodesicPath - Find a geodesic path between two nodes in the graph +## grFindMaximalLengthPath - Find a path that maximizes sum of edge weights +## +## Operations for geometric graphs +## grMergeNodeClusters - Merge cluster of connected nodes in a graph +## grMergeNodesMedian - Replace several nodes by their median coordinate +## clipGraph - Clip a graph with a rectangular area +## addSquareFace - Add a (square) face defined from its vertices to a graph +## grFaceToPolygon - Compute the polygon corresponding to a graph face +## graph2Contours - Convert a graph to a set of contour curves +## +## Voronoi Graphs +## voronoi2d - Compute a voronoi diagram as a graph structure +## boundedVoronoi2d - Return a bounded voronoi diagram as a graph structure +## centroidalVoronoi2d - Create a 2D Centroidal Voronoi Tesselation +## cvtUpdate - Update germs of a CVT with given points +## cvtIterate - Update germs of a CVT using random points with given density +## +## Graph display +## drawGraph - Draw a graph, given as a set of vertices and edges +## drawGraphEdges - Draw edges of a graph +## drawGraphFaces - Draw faces of a graph +## drawDigraph - Draw a directed graph, given as a set of vertices and edges +## drawDirectedEdges - Draw edges with arrow indicating direction +## drawEdgeLabels - Draw values associated to graph edges +## drawNodeLabels - Draw values associated to graph nodes +## drawSquareMesh - Draw a 3D square mesh given as a graph +## patchGraph - Transform 3D graph (mesh) into a patch handle +## +## @end deftypefn + +function graphs_Contents() + + help graphs_Contents + +endfunction Added: trunk/octave-forge/main/geometry/inst/meshes3d/meshes3d_Contents.m =================================================================== --- trunk/octave-forge/main/geometry/inst/meshes3d/meshes3d_Contents.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/meshes3d/meshes3d_Contents.m 2012-09-19 22:10:39 UTC (rev 11055) @@ -0,0 +1,115 @@ +## Copyright (c) 2011, INRA +## 2004-2011, David Legland <dav...@gr...> +## 2012 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} meshes3d_Contents () +## MESHES3D 3D Surface Meshes +## Version 1.0 21-Mar-2011 . +## +## Creation, vizualization, and manipulation of 3D surface meshes or +## polyhedra. +## +## Meshes and Polyhedra are represented by a couple of variables {V, F}: +## V: Nv-by-3 array of vertices: [x1 y1 z1; ... ; xn yn zn]; +## F: is either a NF-by-3 or NF-by-4 array containing reference for +## vertices of each face, or a NF-by-1 cell array, where each cell is an +## array containing a variable number of node indices. +## For some functions, the array E of edges is needed. It consists in a +## NE-by-2 array containing indices of source and target vertices. +## +## The library provides function to create basic polyhedric meshes (the 5 +## platonic solids, plus few others), as well as functions to perform +## basic computations (surface area, normal angles, face centroids...). +## The 'MengerSponge' structure is an example of mesh that is not simply +## connected (multiple tunnels in the structure). +## +## The drawMesh function is mainly a wrapper to the Matlab 'patch' +## function, allowing passing arguments more quickly. +## +## Example +## % create a soccer ball mesh and display it +## [n e f] = createSoccerBall; +## drawMesh(n, f, 'faceColor', 'g', 'linewidth', 2); +## axis equal; +## +## +## General functions +## meshFace - Return the vertex indices of a face in a mesh +## computeMeshEdges - Computes edges array from face array +## meshEdgeFaces - Compute index of faces adjacent to each edge of a mesh +## faceCentroids - Compute centroids of a mesh faces +## faceNormal - Compute normal vector of faces in a 3D mesh +## +## Measures on meshes +## meshSurfaceArea - Surface area of a polyhedral mesh +## trimeshSurfaceArea - Surface area of a triangular mesh +## meshEdgeLength - Lengths of edges of a polygonal or polyhedral mesh +## meshDihedralAngles - Dihedral at edges of a polyhedal mesh +## polyhedronNormalAngle - Compute normal angle at a vertex of a 3D polyhedron +## polyhedronMeanBreadth - Mean breadth of a convex polyhedron +## +## Basic processing +## triangulateFaces - Convert face array to an array of triangular faces +## meshReduce - Merge coplanar faces of a polyhedral mesh +## minConvexHull - Return the unique minimal convex hull of a set of 3D points +## polyhedronSlice - Intersect a convex polyhedron with a plane. +## checkMeshAdjacentFaces - Check if adjacent faces of a mesh have similar orientation +## clipMeshVertices - Clip vertices of a surfacic mesh and remove outer faces +## clipConvexPolyhedronHP - Clip a convex polyhedron by a plane +## +## Typical polyhedra +## polyhedra - Index of classical polyhedral meshes +## createCube - Create a 3D mesh representing the unit cube +## createOctahedron - Create a 3D mesh representing an octahedron +## createCubeOctahedron - Create a 3D mesh representing a cube-octahedron +## createIcosahedron - Create a 3D mesh representing an Icosahedron. +## createDodecahedron - Create a 3D mesh representing a dodecahedron +## createTetrahedron - Create a 3D mesh representing a tetrahedron +## createRhombododecahedron - Create a 3D mesh representing a rhombododecahedron +## createTetrakaidecahedron - Create a 3D mesh representing a tetrakaidecahedron +## +## Less typical polyhedra +## createSoccerBall - Create a 3D mesh representing a soccer ball +## createMengerSponge - Create a cube with an inside cross removed +## steinerPolytope - Create a steiner polytope from a set of vectors +## +## Drawing functions +## drawFaceNormals - Draw normal vector of each face in a mesh +## drawMesh - Draw a 3D mesh defined by vertices and faces +## @end deftypefn + +function meshes3d_Contents () + + help meshes3d_Contents + +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-02 16:48:24
|
Revision: 8935 http://octave.svn.sourceforge.net/octave/?rev=8935&view=rev Author: jpicarbajal Date: 2011-11-02 16:48:16 +0000 (Wed, 02 Nov 2011) Log Message: ----------- geoemtry. Normalize SVG Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/io/@svg/normalize.m trunk/octave-forge/main/geometry/inst/io/@svg/plot.m trunk/octave-forge/main/geometry/inst/io/@svg/subsref.m trunk/octave-forge/main/geometry/inst/polygons2d/polygons2d.m Modified: trunk/octave-forge/main/geometry/inst/io/@svg/normalize.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/@svg/normalize.m 2011-11-02 16:38:56 UTC (rev 8934) +++ trunk/octave-forge/main/geometry/inst/io/@svg/normalize.m 2011-11-02 16:48:16 UTC (rev 8935) @@ -18,42 +18,79 @@ %% TODO: normalizes and SVG. %% @end deftypefn -function SVGn = normalize (obj) +function [SVGn bb] = normalize (obj) warning("svg:Devel","This function is under development and is not working correctly."); SVGn = obj; - if ~obj.Data.normalized - % Translate - TransV = [0; obj.Data.height/2]; - % Scale - Dnorm = sqrt (obj.Data.width ^ 2 + obj.Data.height ^ 2); - S = (1 / Dnorm) * eye (2); + bb = []; + if ! obj.Data.normalized ids = fieldnames (obj.Path); npath = numel(ids); - for i = 1:npath - nc = numel (obj.Path.(ids{i}).data); - - for j=1:nc - % Translate to middle - SVGn.Path.(ids{i}).data{j}(:,end) = ... - obj.Path.(ids{i}).data{j}(:,end) - TransV; - - % Reflect respect to x-axis - SVGn.Path.(ids{i}).data{j}(2, :) = -SVGn.Path.(ids{i}).data{j}(2, :); - TransV(2) = -TransV(2); - - % Translate to bottom - SVGn.Path.(ids{i}).data{j}(:,end) = ... - SVGn.Path.(ids{i}).data{j}(:,end) - TransV; - - %Scale - SVGn.Path.(ids{i}).data{j} = S * SVGn.Path.(ids{i}).data{j}; - end + v = zeros(npath,2); + bb = zeros(1,4); + + for ip = 1:npath + v(ip,:) = shapecentroid(obj.Path.(ids{ip}).data); + p = shape2polygon(obj.Path.(ids{ip}).data); + bb = mergeBoxes(bb, [min(p) max(p)]([1 3 2 4])); end - SVGn.Data.height = SVGn.Data.height / Dnorm; - SVGn.Data.width = SVGn.Data.width / Dnorm; + + 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); + + if obj.Data.height != bbHeight + warning("svg:normalize:Sanitycheck",... + ["Height of SVG %g and height boundingbox %g don't match.\n" ... + "Using bounding box.\n"],obj.Data.height,bbHeight) + end + + if obj.Data.width != bbWidth + warning("svg:normalize:Sanitycheck",... + ["Width of SVG %g and width boundingbox %g don't match.\n" ... + "Using bounding box.\n"],obj.Data.width,bbWidth) + end + + %% Move paths such that center of SVG is at 0,0 + %% Put coordinates in the usual frame + %% Scale such that diagonal of bounding box is 1 + Dnorm = sqrt (bbWidth ^ 2 + bbHeight ^ 2); + S = (1 / Dnorm) * eye (2); + bb = zeros(1,4); + + 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]); + % Reflect y + SVGn.Path.(ids{ip}).data = ... + shapetransform(SVGn.Path.(ids{ip}).data,[1 0;0 -1]); + % 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 Modified: trunk/octave-forge/main/geometry/inst/io/@svg/plot.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/@svg/plot.m 2011-11-02 16:38:56 UTC (rev 8934) +++ trunk/octave-forge/main/geometry/inst/io/@svg/plot.m 2011-11-02 16:48:16 UTC (rev 8935) @@ -43,7 +43,6 @@ end end hold off - axis ij axis equal endfunction Modified: trunk/octave-forge/main/geometry/inst/io/@svg/subsref.m =================================================================== --- trunk/octave-forge/main/geometry/inst/io/@svg/subsref.m 2011-11-02 16:38:56 UTC (rev 8934) +++ trunk/octave-forge/main/geometry/inst/io/@svg/subsref.m 2011-11-02 16:48:16 UTC (rev 8935) @@ -18,7 +18,7 @@ ## @deftypefn {Function File} {} function_name () ## @end deftypefn -function out = subsref (obj, idx) +function varargout = subsref (obj, idx) if ( !strcmp (class (obj), 'svg') ) error ("object must be of the svg class but '%s' was used", class (obj) ); elseif ( idx(1).type != '.' ) @@ -42,6 +42,9 @@ error (method4field, class (obj), method, method); elseif strcmp (idx(2).type, '()') out = plot (obj, idx(2).subs); + if nargout >= 1 + varargout{1} = out; + end else error (typeNotImplemented,[method idx(2).type], class (obj)); end @@ -52,18 +55,28 @@ error (method4field, class (obj), method, method); elseif strcmp (idx(2).type, '()') out = getpath (obj, idx(2).subs); + if nargout >= 1 + varargout{1} = out; + end else error (typeNotImplemented,[method idx(2).type], class (obj)); end case 'pathid' out = fieldnames(obj.Path); + if nargout >= 1 + varargout{1} = out; + end case 'path2polygon' if numel (idx) == 1 % obj.path2polygon doesn't exists error (method4field, class (obj), method, method); elseif strcmp (idx(2).type, '()') out = path2polygon (obj, idx(2).subs); + if nargout >= 1 + varargout{1} = out; + end + else error (typeNotImplemented,[method idx(2).type], class (obj)); end @@ -72,7 +85,15 @@ if numel (idx) == 1 % obj.path2polygon doesn't exists error (method4field, class (obj), method, method); elseif strcmp (idx(2).type, '()') - out = normalize (obj, idx(2).subs); + [out out2] = normalize (obj, idx(2).subs); + pause + if nargout >= 1 + varargout{1} = out; + if nargout >= 2 + varargout{2} = out2; + end + end + varargout else error (typeNotImplemented,[method idx(2).type], class (obj)); end Modified: trunk/octave-forge/main/geometry/inst/polygons2d/polygons2d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/polygons2d.m 2011-11-02 16:38:56 UTC (rev 8934) +++ trunk/octave-forge/main/geometry/inst/polygons2d/polygons2d.m 2011-11-02 16:48:16 UTC (rev 8935) @@ -165,13 +165,13 @@ %% %% ----- %% Author: David Legland -%% e-mail: dav...@gr... +%% e-mail: david.legland@@grignon.inra.fr %% created the 07/11/2005. -%% Homepage: http://matgeom.sourceforge.net/ -%% http://www.pfl-cepia.inra.fr/index.php?page=geom2d +%% Homepage: @url{http://matgeom.sourceforge.net/} +%% @url{http://www.pfl-cepia.inra.fr/index.php?page=geom2d} %% Copyright INRA - Cepia Software Platform. %% -%% @end deftypefn% +%% @end deftypefn function polygons2d () This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2011-11-03 23:40:33
|
Revision: 8971 http://octave.svn.sourceforge.net/octave/?rev=8971&view=rev Author: jpicarbajal Date: 2011-11-03 23:40:25 +0000 (Thu, 03 Nov 2011) Log Message: ----------- geometry. Adding new functions, improving docstring Added Paths: ----------- trunk/octave-forge/main/geometry/inst/polygons2d/polygon2shape.m trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m trunk/octave-forge/main/geometry/inst/shape2d/ 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/shapeplot.m trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m Removed Paths: ------------- trunk/octave-forge/main/geometry/inst/polygon2shape.m trunk/octave-forge/main/geometry/inst/shape2polygon.m trunk/octave-forge/main/geometry/inst/shapearea.m trunk/octave-forge/main/geometry/inst/shapecentroid.m trunk/octave-forge/main/geometry/inst/shapeplot.m trunk/octave-forge/main/geometry/inst/shapetransform.m trunk/octave-forge/main/geometry/inst/simplifypolygon.m Deleted: trunk/octave-forge/main/geometry/inst/polygon2shape.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygon2shape.m 2011-11-03 22:45:47 UTC (rev 8970) +++ trunk/octave-forge/main/geometry/inst/polygon2shape.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -1,34 +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 -## (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 program; if not, see <http://www.gnu.org/licenses/>. - -function shape = polygon2shape (polygon) - - # Filter colinear points - polygon = simplifypolygon (polygon); - - np = size(polygon,1); - # polygonal shapes are memory inefficient!! - # TODO filter the regions where edge angles are canging slowly and fit - # polynomial of degree 3; - pp = nan (2*np,2); - - # Transform edges into polynomials of degree 1; - # pp = [(p1-p0) p0]; - pp(:,1) = diff(polygon([1:end 1],:)).'(:); - pp(:,2) = polygon.'(:); - - shape = mat2cell(pp, 2*ones (1,np), 2); - -endfunction Added: trunk/octave-forge/main/geometry/inst/polygons2d/polygon2shape.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/polygon2shape.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/polygons2d/polygon2shape.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -0,0 +1,54 @@ +## 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 +## (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 program; if not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} {@var{shape} = } polygon2shape (@var{polygon}) +%% Converts a polygon to a shape with edges defined by smooth polynomials. +%% +%% @var{polygon} is a N-by-2 matrix, each row representing a vertex. +%% @var{shape} is a N-by-1 cell, where each element is a pair of polynomials +%% compatible with polyval. +%% +%% In its current state, the shape is formed by polynomials of degree 1. Therefore +%% the shape representation costs more memory except for colinear points in the +%% polygon. +%% +%% @seealso{shape2polygon, simplifypolygon, polyval} +%% @end deftypefn + +function shape = polygon2shape (polygon) + + # Filter colinear points + polygon = simplifypolygon (polygon); + + np = size(polygon,1); + # polygonal shapes are memory inefficient!! + # TODO filter the regions where edge angles are canging slowly and fit + # polynomial of degree 3; + pp = nan (2*np,2); + + # Transform edges into polynomials of degree 1; + # pp = [(p1-p0) p0]; + pp(:,1) = diff(polygon([1:end 1],:)).'(:); + pp(:,2) = polygon.'(:); + + shape = mat2cell(pp, 2*ones (1,np), 2); + +endfunction + +%!test +%! pp = [0 0; 1 0; 1 1; 0 1]; +%! s = polygon2shape (pp); + Added: trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -0,0 +1,59 @@ +## 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 +## (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 program; if not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} {@var{spoly} = } simplifypolygon (@var{poly}) +%% Filter colinear vertex from a 2D polygon. +%% +%% @var{poly} is a N-by-2 matrix, each row representing a vertex. +%% +%% @seealso{shape2polygon} +%% @end deftypefn +function polygonsimp = simplifypolygon (polygon) + + # Filter colinear points + edges = diff(polygon([1:end 1],:)); + ned = size(edges,1); + nxt = [2:ned 1]; + + # check if consecutive edges are parallel + para = edges(:,1).*edges(nxt,2) - edges(:,2).*edges(nxt,1); + ind = abs(para) > sqrt(eps); + + polygonsimp = polygon(circshift (ind,1),:); + +endfunction + +%!test +%! P = [0 0; 1 0; 0 1]; +%! P2 = [0 0; 0.1 0; 0.2 0; 0.25 0; 1 0; 0 1; 0 0.7; 0 0.6; 0 0.3; 0 0.1]; +%! assert(P,simplifypolygon (P2)) + +%!demo +%! +%! P = [0 0; 1 0; 0 1]; +%! P2 = [0 0; 0.1 0; 0.2 0; 0.25 0; 1 0; 0 1; 0 0.7; 0 0.6; 0 0.3; 0 0.1]; +%! Pr = simplifypolygon (P2); +%! +%! cla +%! drawPolygon(P,'or;Reference;'); +%! hold on +%! drawPolygon(P2,'x-b;Redundant;'); +%! drawPolygon(Pr,'*g;Simplified;'); +%! hold off +%! +%! % -------------------------------------------------------------------------- +%! % The two polygons describe the same figure, a triangle. Extra points are +%! % removed form the redundant one. Added: trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -0,0 +1,51 @@ +## 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 +## (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 program; if not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} {@var{polygon} = } shape2polygon (@var{shape}) +%% @deftypefnx {Function File} {@var{polygon} = } shape2polygon (@var{shape},@var{N}) +%% Transforms a 2D shape described by piecewise smooth polynomials into a polygon. +%% +%% @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. +%% +%% @seealso{polygon2shape, drawPolygon} +%% @end deftypefn + +function polygon = shape2polygon (shape, N=16) + + polygon = cell2mat ( ... + 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); + end + +endfunction + +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); + else + y = x(:,2).'; + end + +endfunction Added: trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapearea.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -0,0 +1,71 @@ +%% 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 +%% (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 program; if not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} { @var{a} =} shapearea (@var{pp}) +%% Calculate the area of a 2D shape defined with piecewise smooth polynomials. +%% +%% Shape is defined with piecewise smooth polynomials. @var{pp} is a +%% cell where each elements is a 2-by-(poly_degree+1) array containing a pair of +%% polynomials. +%% +%% @code{px(i,:) = pp@{i@}(1,:)} and @code{py(i,:) = pp@{i@}(2,:)}. +%% +%% @seealso{shapecentroid, shape2polygon, shapeplot} +%% @end deftypefn + +function A = shapearea (shape) + + A = sum(cellfun (@Aint, shape)); + if A < 0 + A = -A; + end + +endfunction + +function dA = Aint (x) + + px = x(1,:); + py = x(2,:); + + P = polyint (conv (px, polyderiv(py))); + + dA = diff(polyval(P,[0 1])); + +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) + +%!test +%! triangle = {[1 0; 0 0]; [-0.5 1; 1 0]; [-0.5 0.5; -1 1]}; +%! A = shapearea (triangle); +%! assert (0.5, A); + +%!test +%! circle = {[1.715729 -6.715729 0 5; ... +%! -1.715729 -1.568542 8.284271 0]; ... +%! [1.715729 1.568542 -8.284271 0; ... +%! 1.715729 -6.715729 0 5]; ... +%! [-1.715729 6.715729 0 -5; ... +%! 1.715729 1.568542 -8.284271 0]; ... +%! [-1.715729 -1.568542 8.284271 0; ... +%! -1.715729 6.715729 0 -5]}; +%! A = shapearea (circle); +%! assert (pi*5^2, A, 5e-2); Added: trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -0,0 +1,71 @@ +%% 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 +%% (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 program; if not, see <http://www.gnu.org/licenses/>. + +%% -*- texinfo -*- +%% @deftypefn {Function File} { @var{cm} =} shapecentroid (@var{pp}) +%% Centroid of a 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,:)}. +%% +%% @seealso{shapearea, shape2polygon} +%% @end deftypefn + +function cm = shapecentroid (shape) + + cm = sum( cell2mat ( cellfun (@CMint, shape, 'UniformOutput', false))); + A = shapearea(shape); + cm = cm / A; + +endfunction + +function dcm = CMint (x) + + px = x(1,:); + py = x(2,:); + Px = polyint (conv(conv (px , px)/2 , polyderiv (py))); + Py = polyint (conv(-conv (py , py)/2 , polyderiv (px))); + + dcm = zeros (1,2); + dcm(1) = diff(polyval(Px,[0 1])); + dcm(2) = diff(polyval(Py,[0 1])); + +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]}; +%! CoM = shapecentroid (weirdhearth) + +%!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); +%! assert (CoM, [0 0], sqrt(eps)); + +%!test +%! circle = {[1.715729 -6.715729 0 5; ... +%! -1.715729 -1.568542 8.284271 0]; ... +%! [1.715729 1.568542 -8.284271 0; ... +%! 1.715729 -6.715729 0 5]; ... +%! [-1.715729 6.715729 0 -5; ... +%! 1.715729 1.568542 -8.284271 0]; ... +%! [-1.715729 -1.568542 8.284271 0; ... +%! -1.715729 6.715729 0 -5]}; +%! CoM = shapecentroid (circle); +%! assert (CoM , [0 0], 5e-3); Added: trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -0,0 +1,35 @@ +%% 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{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. +%% +%% @var{pp} is a cell where each elements is a 2-by-(poly_degree+1) matrix +%% containing a pair of polynomials. +%% @var{N} is the number of points to be used in non-straight edges. +%% Additional parameter value pairs are passed to @code{drawPolygon}. +%% +%% @seealso{drawPolygon, shape2polygon} +%% @end deftypefn + +function h = shapeplot(shape, N = 16, varargin) + + p = shape2polygon(shape, N); + h = drawPolygon(p,varargin{:}); + +endfunction Added: trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -0,0 +1,142 @@ +%% 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{nshape} = } shapetransform (@var{shape}, @var{T}) +%% Applies transformation to a shape defined by piecewise smooth polynomials. +%% +%% @var{shape} is a cell where each elements is a 2-by-(poly_degree+1) matrix +%% containing a pair of polynomials. +%% +%% Format of @var{T} can be one of : +%% @group +%% [c] , [a b] , [a b c] or [a b c] +%% [f] [d e] [d e f] [d e f] +%% [0 0 1] +%% @end group +%% +%% @seealso{shape2polygon, shapeplot} +%% @end deftypefn + +function nshape = shapetransform (shape, Trans) + + if size(Trans,1) < 2 + error("geometry:shapetransform:InvalidArgument", ... + "Transformation can be 2x1, 2x2, 2x3 or 3x3. See help."); + end + + if ~iscell(shape) + error("geometry:shapetransform:InvalidArgument", "Shape must be a cell of 2D polynomials."); + end + + A =[]; + v = []; + + switch size(Trans,2) + case 1 + % Just translation + v = Trans; + + case 2 + % Just linear transformation + A = Trans; + + case 3 + % Affine transform + A = Trans(1:2,1:2); + v = Trans(1:2,3); + end + + nshape = cellfun (@(x)polytransform (x,A,v), shape, 'UniformOutput',false); + +endfunction + +function np = polytransform(p,A,v) + + np = p; + if ~isempty (A) + np = A*np; + end + if ~isempty (v) + np(:,end) = np(:,end) + v; + end + +endfunction + +%!demo +%! 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]}; +%! +%! A = shapearea (shape); +%! T = eye(2)/sqrt(A); +%! shape = shapetransform (shape,T); +%! T = shapecentroid (shape)(:); +%! shape = shapetransform (shape,-T + [2; 0]); +%! +%! cla +%! shapeplot (shape,10,'-r','linewidth',2) +%! hold on +%! for i = 1:9 +%! T = createRotation (i*pi/5)(1:2,1:2)/exp(0.3*i); +%! shapeplot (shapetransform(shape, T), 10, 'color',rand(1,3),'linewidth',2); +%! end +%! hold off +%! axis tight +%! 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); Deleted: trunk/octave-forge/main/geometry/inst/shape2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2polygon.m 2011-11-03 22:45:47 UTC (rev 8970) +++ trunk/octave-forge/main/geometry/inst/shape2polygon.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -1,46 +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 -## (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 program; if not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} {@var{polygon} = } shape2polygon (@var{shape}) -%% @deftypefnx {Function File} {@var{polygon} = } shape2polygon (@var{shape},@var{N}) -%% Transforms a 2D shape described by piecewise smooth polynomials into a polygon. -%% -%% @seealso{drawPolygon} -%% @end deftypefn -function polygon = shape2polygon (shape, N=16) - - polygon = cell2mat ( ... - 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); - end - -endfunction - -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); - else - y = x(:,2).'; - end - -endfunction - Deleted: trunk/octave-forge/main/geometry/inst/shapearea.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shapearea.m 2011-11-03 22:45:47 UTC (rev 8970) +++ trunk/octave-forge/main/geometry/inst/shapearea.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -1,67 +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 -%% (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 program; if not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} { @var{a} =} shapearea (@var{pp}) -%% Shape is defined with piecewise smooth polynomials. @var{pp} is a -%% cell where each elements is a 2-by-(poly_degree+1) array containing -%% @code{px(i,:) = pp@{i@}(1,:)} and @code{py(i,:) = pp@{i@}(2,:)}. -%% -%% @end deftypefn - -function A = shapearea (shape) - - A = sum(cellfun (@Aint, shape)); - if A < 0 - A = -A; - end - -endfunction - -function dA = Aint (x) - - px = x(1,:); - py = x(2,:); - - P = polyint (conv (px, polyderiv(py))); - - dA = diff(polyval(P,[0 1])); - -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) - -%!test -%! triangle = {[1 0; 0 0]; [-0.5 1; 1 0]; [-0.5 0.5; -1 1]}; -%! A = shapearea (triangle); -%! assert (0.5, A); - -%!test -%! circle = {[1.715729 -6.715729 0 5; ... -%! -1.715729 -1.568542 8.284271 0]; ... -%! [1.715729 1.568542 -8.284271 0; ... -%! 1.715729 -6.715729 0 5]; ... -%! [-1.715729 6.715729 0 -5; ... -%! 1.715729 1.568542 -8.284271 0]; ... -%! [-1.715729 -1.568542 8.284271 0; ... -%! -1.715729 6.715729 0 -5]}; -%! A = shapearea (circle); -%! assert (pi*5^2, A, 5e-2); - Deleted: trunk/octave-forge/main/geometry/inst/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shapecentroid.m 2011-11-03 22:45:47 UTC (rev 8970) +++ trunk/octave-forge/main/geometry/inst/shapecentroid.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -1,71 +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 -%% (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 program; if not, see <http://www.gnu.org/licenses/>. - -%% -*- texinfo -*- -%% @deftypefn {Function File} { @var{cm} =} shapecentroid (@var{pp}) -%% Centroid of a plane shape. -%% -%% 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 -%% @code{px(i,:) = pp@{i@}(1,:)} and @code{py(i,:) = pp@{i@}(2,:)}. -%% -%% @seealso{shapearea} -%% @end deftypefn - -function cm = shapecentroid (shape) - - cm = sum( cell2mat ( cellfun (@CMint, shape, 'UniformOutput', false))); - A = shapearea(shape); - cm = cm / A; - -endfunction - -function dcm = CMint (x) - - px = x(1,:); - py = x(2,:); - Px = polyint (conv(conv (px , px)/2 , polyderiv (py))); - Py = polyint (conv(-conv (py , py)/2 , polyderiv (px))); - - dcm = zeros (1,2); - dcm(1) = diff(polyval(Px,[0 1])); - dcm(2) = diff(polyval(Py,[0 1])); - -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]}; -%! CoM = shapecentroid (weirdhearth) - -%!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); -%! assert (CoM, [0 0], sqrt(eps)); - -%!test -%! circle = {[1.715729 -6.715729 0 5; ... -%! -1.715729 -1.568542 8.284271 0]; ... -%! [1.715729 1.568542 -8.284271 0; ... -%! 1.715729 -6.715729 0 5]; ... -%! [-1.715729 6.715729 0 -5; ... -%! 1.715729 1.568542 -8.284271 0]; ... -%! [-1.715729 -1.568542 8.284271 0; ... -%! -1.715729 6.715729 0 -5]}; -%! CoM = shapecentroid (circle); -%! assert (CoM , [0 0], 5e-3); - Deleted: trunk/octave-forge/main/geometry/inst/shapeplot.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shapeplot.m 2011-11-03 22:45:47 UTC (rev 8970) +++ trunk/octave-forge/main/geometry/inst/shapeplot.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -1,28 +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{h} = } shapeplot (@var{shape}) -%% @deftypefnx {Function File} {@var{h} = } shapeplot (@var{shape}, @var{N}) -%% Pots a 2D shape defined by piecewise smooth polynomials. -%% -%% @end deftypefn - -function h = shapeplot(shape, N = 16, varargin) - - p = shape2polygon(shape, N); - h = drawPolygon(p,varargin{:}); - -endfunction Deleted: trunk/octave-forge/main/geometry/inst/shapetransform.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shapetransform.m 2011-11-03 22:45:47 UTC (rev 8970) +++ trunk/octave-forge/main/geometry/inst/shapetransform.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -1,137 +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{nshape} = } shapetransform (@var{shape}, @var{T}) -%% Applies transformation to a shape defined by piecewise smooth polynomials. -%% -%% Format of @var{T} can be one of : -%% [c] , [a b] , [a b c] or [a b c] -%% [f] [d e] [d e f] [d e f] -%% [0 0 1] -%% -%% @end deftypefn - -function nshape = shapetransform (shape, Trans) - - if size(Trans,1) < 2 - error("geometry:shapetransform:InvalidArgument", ... - "Transformation can be 2x1, 2x2, 2x3 or 3x3. See help."); - end - - if ~iscell(shape) - error("geometry:shapetransform:InvalidArgument", "Shape must be a cell of 2D polynomials."); - end - - A =[]; - v = []; - - switch size(Trans,2) - case 1 - % Just translation - v = Trans; - - case 2 - % Just linear transformation - A = Trans; - - case 3 - % Affine transform - A = Trans(1:2,1:2); - v = Trans(1:2,3); - end - - nshape = cellfun (@(x)polytransform (x,A,v), shape, 'UniformOutput',false); - -endfunction - -function np = polytransform(p,A,v) - - np = p; - if ~isempty (A) - np = A*np; - end - if ~isempty (v) - np(:,end) = np(:,end) + v; - end - -endfunction - -%!demo -%! 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]}; -%! -%! A = shapearea (shape); -%! T = eye(2)/sqrt(A); -%! shape = shapetransform (shape,T); -%! T = shapecentroid (shape)(:); -%! shape = shapetransform (shape,-T + [2; 0]); -%! -%! cla -%! shapeplot (shape,10,'-r','linewidth',2) -%! hold on -%! for i = 1:9 -%! T = createRotation (i*pi/5)(1:2,1:2)/exp(0.3*i); -%! shapeplot (shapetransform(shape, T), 10, 'color',rand(1,3),'linewidth',2); -%! end -%! hold off -%! axis tight -%! 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); - Deleted: trunk/octave-forge/main/geometry/inst/simplifypolygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/simplifypolygon.m 2011-11-03 22:45:47 UTC (rev 8970) +++ trunk/octave-forge/main/geometry/inst/simplifypolygon.m 2011-11-03 23:40:25 UTC (rev 8971) @@ -1,29 +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 -## (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 program; if not, see <http://www.gnu.org/licenses/>. - -function polygonsimp = simplifypolygon (polygon) - - # Filter colinear points - edges = diff(polygon([1:end 1],:)); - ned = size(edges,1); - nxt = [2:ned 1]; - - # check if consecutive edges are parallel - para = edges(:,1).*edges(nxt,2) - edges(:,2).*edges(nxt,1); - ind = abs(para) > sqrt(eps); - - polygonsimp = polygon(circshift (ind,1),:); - -endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-03-06 08:34:52
|
Revision: 9752 http://octave.svn.sourceforge.net/octave/?rev=9752&view=rev Author: jpicarbajal Date: 2012-03-06 08:34:45 +0000 (Tue, 06 Mar 2012) Log Message: ----------- geometry: fixing docs Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/polygons2d/polygons2d.m Added Paths: ----------- trunk/octave-forge/main/geometry/inst/geom2d/geometry_Contents.m Removed Paths: ------------- trunk/octave-forge/main/geometry/inst/geom2d/Contents.m Deleted: trunk/octave-forge/main/geometry/inst/geom2d/Contents.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/Contents.m 2012-03-05 21:45:14 UTC (rev 9751) +++ trunk/octave-forge/main/geometry/inst/geom2d/Contents.m 2012-03-06 08:34:45 UTC (rev 9752) @@ -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} 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 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 - Copied: trunk/octave-forge/main/geometry/inst/geom2d/geometry_Contents.m (from rev 9751, trunk/octave-forge/main/geometry/inst/geom2d/Contents.m) =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/geometry_Contents.m (rev 0) +++ trunk/octave-forge/main/geometry/inst/geom2d/geometry_Contents.m 2012-03-06 08:34:45 UTC (rev 9752) @@ -0,0 +1,224 @@ +%% 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} 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 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 + Modified: trunk/octave-forge/main/geometry/inst/polygons2d/polygons2d.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/polygons2d.m 2012-03-05 21:45:14 UTC (rev 9751) +++ trunk/octave-forge/main/geometry/inst/polygons2d/polygons2d.m 2012-03-06 08:34:45 UTC (rev 9752) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {} polygons2d () -%% MATGEOM-POLYGONS +%% Description of functions operating on 2D polygons %% %% The 'polygons' module contains functions operating on shapes composed %% of a vertex list, like polygons or polylines. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-04-15 15:23:02
|
Revision: 10230 http://octave.svn.sourceforge.net/octave/?rev=10230&view=rev Author: jpicarbajal Date: 2012-04-15 15:22:55 +0000 (Sun, 15 Apr 2012) Log Message: ----------- geometry: Ramer-Douglas-Peucker algorithm to simplify polylines and polygons. Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m trunk/octave-forge/main/geometry/inst/shape2d/curve2polyline.m Modified: trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m 2012-04-15 15:18:34 UTC (rev 10229) +++ trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolygon.m 2012-04-15 15:22:55 UTC (rev 10230) @@ -15,37 +15,32 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{spoly} = } simplifypolygon (@var{poly}) -%% Filter colinear vertex from a 2D polygon. +%% Simplify a polygon using the Ramer-Douglas-Peucker algorithm. %% %% @var{poly} is a N-by-2 matrix, each row representing a vertex. %% -%% @seealso{shape2polygon} +%% @seealso{simplifypolyline, shape2polygon} %% @end deftypefn -function polygonsimp = simplifypolygon (polygon) +function polygonsimp = simplifypolygon (polygon, varargin) - # Filter colinear points - edges = diff(polygon([1:end 1],:)); - ned = size(edges,1); - nxt = [2:ned 1]; + polygonsimp = simplifypolyline (polygon,varargin{:}); - # check if consecutive edges are parallel - para = edges(:,1).*edges(nxt,2) - edges(:,2).*edges(nxt,1); - ind = abs(para) > sqrt(eps); + # Remove parrallel consecutive edges + PL = polygonsimp(1:end-1,:); + PC = polygonsimp(2:end,:); + PR = polygonsimp([3:end 1],:); + a = PL - PC; + b = PR - PC; + tf = find(isParallel(a,b))+1; + polygonsimp (tf,:) = []; - 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 %! P = [0 0; 1 0; 0 1]; %! P2 = [0 0; 0.1 0; 0.2 0; 0.25 0; 1 0; 0 1; 0 0.7; 0 0.6; 0 0.3; 0 0.1]; -%! assert(P,simplifypolygon (P2)) +%! assert(simplifypolygon (P2),P,min(P2(:))*eps) %!demo %! Modified: trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m =================================================================== --- trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m 2012-04-15 15:18:34 UTC (rev 10229) +++ trunk/octave-forge/main/geometry/inst/polygons2d/simplifypolyline.m 2012-04-15 15:22:55 UTC (rev 10230) @@ -48,7 +48,8 @@ parser = inputParser (); parser.FunctionName = "simplifypolyline"; parser = addParamValue (parser,'Nmax', 100, @(x)x>0); - parser = addParamValue (parser,'Tol', 1e-4, @(x)x>0); + toldef = 1e-4;%max(sumsq(diff(pline_o),2))*2; + parser = addParamValue (parser,'Tol', toldef, @(x)x>0); parser = addParamValue (parser,'MaxIter', 100, @(x)x>0); parser = parse(parser,varargin{:}); @@ -56,7 +57,7 @@ tol = parser.Results.Tol; MaxIter = parser.Results.MaxIter; - clear parser + clear parser toldef msg = ["Maximum number of points reached with maximal error %g." ... " Increase '%s' if the result is not satisfactory."]; # ------ # @@ -108,8 +109,6 @@ 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 @@ -137,3 +136,20 @@ %! %! % --------------------------------------------------------- %! % Four approximations of the initial polyline with decreasing tolerances. + +%!demo +%! P = [0 0; 3 1; 3 4; 1 3; 2 2; 1 1]; +%! func = @(x,y) linspace(x,y,5); +%! P2(:,1) = cell2mat( ... +%! arrayfun (func, P(1:end-1,1),P(2:end,1), ... +%! 'uniformoutput',false))'(:); +%! P2(:,2) = cell2mat( ... +%! arrayfun (func, P(1:end-1,2),P(2:end,2), ... +%! 'uniformoutput',false))'(:); +%! +%! P2s = simplifypolyline (P2); +%! +%! plot(P(:,1),P(:,2),'s',P2(:,1),P2(:,2),'o',P2s(:,1),P2s(:,2),'-ok'); +%! +%! % --------------------------------------------------------- +%! % Simplification of a polyline in the plane. Modified: trunk/octave-forge/main/geometry/inst/shape2d/curve2polyline.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/curve2polyline.m 2012-04-15 15:18:34 UTC (rev 10229) +++ trunk/octave-forge/main/geometry/inst/shape2d/curve2polyline.m 2012-04-15 15:22:55 UTC (rev 10230) @@ -100,6 +100,7 @@ %% -- 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. +%% Do this in isParallel.m and remove this function PL = p(1:2:end-2,:); PC = p(2:2:end-1,:); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-04-16 11:24:35
|
Revision: 10246 http://octave.svn.sourceforge.net/octave/?rev=10246&view=rev Author: jpicarbajal Date: 2012-04-16 11:24:26 +0000 (Mon, 16 Apr 2012) Log Message: ----------- geometry: fixing details Modified Paths: -------------- trunk/octave-forge/main/geometry/inst/geom2d/distancePointEdge.m trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m Modified: trunk/octave-forge/main/geometry/inst/geom2d/distancePointEdge.m =================================================================== --- trunk/octave-forge/main/geometry/inst/geom2d/distancePointEdge.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/geom2d/distancePointEdge.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -76,9 +76,11 @@ % (Size of tp is the max number of edges or points) delta = dx .* dx + dy .* dy; + mask = delta < eps; + delta(mask) = 1; warning ('off', 'Octave:broadcast'); tp = ((point(:, 1) - edge(1, :)) .* dx + (point(:, 2) - edge(2, :)) .* dy) ./ delta; - tp(:,delta < eps) = 0; + tp(:,mask) = 0; % change position to ensure projected point is located on the edge tp(tp < 0) = 0; Modified: trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/shape2d/shape2polygon.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -54,7 +54,7 @@ %! 58.870 -38.083 -89.358 232.362]}; %! %! % Estimate a good tolerance -%! n = cell2mat(cellfun(@(x)curveval(x,[0 1]), shape, 'uniformoutput',false)); +%! n = cell2mat(cellfun(@(x)curveval(x,rand(1,10)), shape, 'uniformoutput',false)); %! dr = (max(n(:,1))-min(n(:,1)))*(max(n(:,2))-min(n(:,2)))*40; %! p = shape2polygon (shape,'tol',dr); %! Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapecentroid.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -66,9 +66,8 @@ %! 0 0]}; %! CoM = shapecentroid (boomerang) %! Gcentroid = centroid(shape2polygon(boomerang)) -%! %! figure(1); clf; -%! shapeplot(boomerang,10,'-o'); +%! shapeplot(boomerang,'-o'); %! hold on %! drawPoint(CoM,'xk;shape centroid;'); %! drawPoint(Gcentroid,'xr;point centroid;'); @@ -85,7 +84,7 @@ %! CoM = shapecentroid (Lshape) %! Gcentroid = centroid (shape2polygon (Lshape)) %! -%! shapeplot(Lshape,10,'-o'); +%! shapeplot(Lshape,'-o'); %! hold on %! drawPoint(CoM,'xk;shape centroid;'); %! drawPoint(Gcentroid,'xr;point centroid;'); Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapeplot.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -29,8 +29,8 @@ function h = shapeplot(shape, varargin) - n = cell2mat(cellfun(@(x)curveval(x,[0 1]), shape, 'uniformoutput',false)); - dr = (max(n(:,1))-min(n(:,1)))*(max(n(:,2))-min(n(:,2)))/10; + n = cell2mat(cellfun(@(x)curveval(x,rand(1,5)), shape, 'uniformoutput',false)); + dr = (max(n(:,1))-min(n(:,1)))*(max(n(:,2))-min(n(:,2)))/100; p = shape2polygon(shape,'tol', dr); h = drawPolygon(p,varargin{:}); Modified: trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m =================================================================== --- trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2012-04-16 10:39:05 UTC (rev 10245) +++ trunk/octave-forge/main/geometry/inst/shape2d/shapetransform.m 2012-04-16 11:24:26 UTC (rev 10246) @@ -98,14 +98,12 @@ %! shape = shapetransform (shape,-T + [2; 0]); %! %! close -%! shapeplot (shape,10,'-r','linewidth',2) +%! shapeplot (shape,'-r','linewidth',2) %! hold on %! for i = 1:9 %! T = createRotation (i*pi/5)(1:2,1:2)/exp(0.3*i); -%! shapeplot (shapetransform(shape, T), 10, 'color',rand(1,3),'linewidth',2); +%! shapeplot (shapetransform(shape, T), 'color',rand(1,3),'linewidth',2); %! end %! hold off %! axis tight %! axis square - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jpi...@us...> - 2012-06-16 23:13:29
|
Revision: 10635 http://octave.svn.sourceforge.net/octave/?rev=10635&view=rev Author: jpicarbajal Date: 2012-06-16 23:13:22 +0000 (Sat, 16 Jun 2012) Log Message: ----------- geometry: removing svn:executable recursively. Property Changed: ---------------- trunk/octave-forge/main/geometry/inst/io/@svg/inkex.py trunk/octave-forge/main/geometry/inst/io/@svg/simplepath.py trunk/octave-forge/main/geometry/inst/io/private/inkex.py trunk/octave-forge/main/geometry/inst/io/private/simplepath.py 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/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/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 trunk/octave-forge/main/geometry/inst/polygons2d/distancePointPolygon.m trunk/octave-forge/main/geometry/inst/polygons2d/distancePointPolyline.m trunk/octave-forge/main/geometry/inst/polygons2d/distancePolygons.m trunk/octave-forge/main/geometry/inst/polygons2d/expandPolygon.m trunk/octave-forge/main/geometry/inst/polygons2d/medialAxisConvex.m trunk/octave-forge/main/geometry/inst/polygons2d/polygonLoops.m trunk/octave-forge/main/geometry/inst/polygons2d/polygonSelfIntersections.m trunk/octave-forge/main/geometry/inst/polygons2d/polylineSelfIntersections.m Property changes on: trunk/octave-forge/main/geometry/inst/io/@svg/inkex.py ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/io/@svg/simplepath.py ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/io/private/inkex.py ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/io/private/simplepath.py ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/compilador.c ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/errores.c ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/eucli.c ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/fgeneral.c ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/greiner.c ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/compilador.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/constantes.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/errores.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/eucli.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/fgeneral.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/general.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/geom.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/greiner.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/polig.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/ptopol.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/segmento.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/libgeoc/ventorno.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/polig.c ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/ptopol.c ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/segmento.c ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/octclip/src/ventorno.c ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/polygons2d/distancePointPolygon.m ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/polygons2d/distancePointPolyline.m ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/polygons2d/distancePolygons.m ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/polygons2d/expandPolygon.m ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/polygons2d/medialAxisConvex.m ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/polygons2d/polygonLoops.m ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/polygons2d/polygonSelfIntersections.m ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/octave-forge/main/geometry/inst/polygons2d/polylineSelfIntersections.m ___________________________________________________________________ Deleted: svn:executable - * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |