Mercurial > forge
changeset 8638:4fc1ed468c8a octave-forge
geometry. 27 functions to go!
author | jpicarbajal |
---|---|
date | Fri, 21 Oct 2011 18:58:15 +0000 |
parents | 136af6d81666 |
children | 461b092948bd |
files | main/geometry/doc/NEWS main/geometry/geom2d/inst/changelog.txt main/geometry/geom2d/inst/inertiaEllipse.m main/geometry/geom2d/inst/readme.txt main/geometry/matGeom_raw/geom2d/changelog.txt main/geometry/matGeom_raw/geom2d/inertiaEllipse.m main/geometry/matGeom_raw/geom2d/invertLine.m main/geometry/matGeom_raw/geom2d/readme.txt |
diffstat | 8 files changed, 360 insertions(+), 431 deletions(-) [+] |
line wrap: on
line diff
--- a/main/geometry/doc/NEWS Fri Oct 21 18:51:49 2011 +0000 +++ b/main/geometry/doc/NEWS Fri Oct 21 18:58:15 2011 +0000 @@ -127,6 +127,10 @@ drawShape.m circles2d.m ellipses2d.m + createVector.m + inertiaEllipse.m + changelog.txt + readme.txt ===============================================================================
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/geometry/geom2d/inst/changelog.txt Fri Oct 21 18:58:15 2011 +0000 @@ -0,0 +1,192 @@ +%% Copyright (c) 2011, INRA +%% 2007-2011, David Legland <david.legland@grignon.inra.fr> +%% 2011 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch> +%% +%% 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. + + +change log for geom2d + +geom2d, release 2011.??.?? +========================== + +New functions +- added angleDiff and angleAbsDiff + +various doc updates + + +geom2d, release 2011.06.30 +========================== + +New functions +- added function rotateVector +- added function randomPointInBox + +Changes +- Shape orientation is now represented using degrees +- function vectorAngle can now compute the angle between two vectors + +Bug fixes +- enhanced function distancePointEdge +- enhanced function isPointOnEdge +- enhanced function isParallel +- fixed bugs intersectLineCircle + + +geom2d, release 2011.03.21 +========================== + +New functions +- added functions intersectLineCircle and intersectCircles +- added functions inertiaEllipse, isPointInEllipse +- added function drawBezierCurve +- added functions intersectBoxes and mergeBoxes + +Changes +- re-organized the library in three sub-directories: geom2d, polygons2d, and + polynomialCurves2d +- cleanup of code and doc + +Bug fixes +- several bugs fixed in clipEdge, isPointOnEdge + + +geom2d, release 2010.08.06 +========================== + +New functions +- polygonToRow and rowToPolygon, to convert polygon to a row vector +- midPoint, to compute middle points of either 2 points or an edge +- added rad2deg and deg2rad, for angle conversions + +Changes +- createCircle and createdirectedCircle are now vectorized, and use different + convention for 2 input variables (center + point and circle) +- median line has been vectorized + +Bug fixes +- fix bugs in intersectEdges +- fix bugs in clipLine +- rewrite drawLine using clipLine + + +geom2d, release 2010.07.19 +========================== + +new functions + +- isCounterClockwise +- intersectRayPolygon +- clipRay +- reverseEdge +- drawBox +- fitAffineTransform2d + +Changes + +- updated inertiaEllipse +- fixed bugs in intersectEdges.m, isParallel.m and isPerpendicular.m +- vectorized intersectLinePolygon +- fixed precision bug in isPointOnEdge +- renamed formatAngle to normalizeAngle +- created help file 'angles2d' +- fixed bug in weighted centroid computation + +various bug fixes, and doc updates. + + + +geom2d, release 2009.07.22 +========================== + +new features + +- new functions for polygons: + polygonPoint, polygonSubcurve, polygonLoops, distancePointPolygon, + distancePolygons, expandPolygon, polygonSelfIntersections, + projPointOnPolygon, isPointInPolygon, reveresPolygon + +- new functions for polylines: + intersectPolylines, polylineSelfIntersections, distancePolylines, + isPointOnPolyline, reveresPolyline + +- projPointOnPolyline can also return the distance of the point to the polyline + +- function 'edgeToLine' converts an edge to its supporting line + + +Changes + +- Renamed functions + + subcurve -> polylineSubCurve + + curveCentroid -> polylineCentroid + + invertLine -> reverseLine + +- Compatibility considerations + + parallelLine: changed convention for signed distance + +various bug fixes, and doc updates. + + +geom2d, release 2009.06.15 +========================== + +* new features + +- radicalAxis from 2 circles: +- moment of a curve (polyline): curveMoment, curveCMoment, curveCSMoment +- new functions for polylines + distancePointPolyline, drawPolyline, polylineLength, polylinePoint, + polylineSubcurve, projPointOnPolyline + +* changes + +- changed some function names to avoid potential name conflicts, and to make + function names more explicit: + + rotation -> createRotation + + scaling -> createScaling + + translation -> createRotation + + homothecy -> createHomothecy + + lineSymmetry -> createLineReflection + + inCircle -> isPointInCircle + + onCircle -> isPointOnCircle + + onEdge -> isPointOnEdge + + onLine -> isPointOnLine + + onRay -> isPointOnRay + + normalize -> normalizeVector + + +* bug fixes + +- fixed bug in intersectEdges + +many updates in doc. +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/geometry/geom2d/inst/inertiaEllipse.m Fri Oct 21 18:58:15 2011 +0000 @@ -0,0 +1,96 @@ +%% Copyright (c) 2011, INRA +%% 2008-2011, David Legland <david.legland@grignon.inra.fr> +%% 2011 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch> +%% +%% 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{ell} = } inertiaEllipse (@var{pts}) +%% Inertia ellipse of a set of points +%% +%% ELL = inertiaEllipse(PTS); +%% where PTS is a N*2 array containing coordinates of N points, computes +%% the inertia ellispe of the set of points. +%% +%% The result has the form: +%% ELL = [XC YC A B THETA], +%% with XC and YC being the center of mass of the point set, A and B are +%% the lengths of the inertia ellipse (see below), and THETA is the angle +%% of the main inertia axis with the horizontal (counted in degrees +%% between 0 and 180). +%% A and B are the standard deviations of the point coordinates when +%% ellipse is aligned with the inertia axes. +%% +%% @example +%% pts = randn(100, 2); +%% pts = transformPoint(pts, createScaling(5, 2)); +%% pts = transformPoint(pts, createRotation(pi/6)); +%% pts = transformPoint(pts, createTranslation(3, 4)); +%% ell = inertiaEllipse(pts); +%% figure(1); clf; hold on; +%% drawPoint(pts); +%% drawEllipse(ell, 'linewidth', 2, 'color', 'r'); +%% @end example +%% +%% @seealso{ellipses2d, drawEllipse} +%% @end deftypefn + +function ell = inertiaEllipse(points) + + % ellipse center + xc = mean(points(:,1)); + yc = mean(points(:,2)); + + % recenter points + x = points(:,1) - xc; + y = points(:,2) - yc; + + % number of points + n = size(points, 1); + + % inertia parameters + Ixx = sum(x.^2) / n; + Iyy = sum(y.^2) / n; + Ixy = sum(x.*y) / n; + + % compute ellipse semi-axis lengths + common = sqrt( (Ixx - Iyy)^2 + 4 * Ixy^2); + ra = sqrt(2) * sqrt(Ixx + Iyy + common); + rb = sqrt(2) * sqrt(Ixx + Iyy - common); + + % compute ellipse angle in degrees + theta = atan2(2 * Ixy, Ixx - Iyy) / 2; + theta = rad2deg(theta); + + % create the resulting inertia ellipse + ell = [xc yc ra rb theta]; + +endfunction +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/geometry/geom2d/inst/readme.txt Fri Oct 21 18:58:15 2011 +0000 @@ -0,0 +1,68 @@ +%% Copyright (c) 2011, INRA +%% 2007-2011, David Legland <david.legland@grignon.inra.fr> +%% 2011 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch> +%% +%% 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. + + +Description of the geom2d library. + +The aim of geom2d library is to handle and visualize geometric primitives such +as points, lines, circles and ellipses, polylines and polygons... It provides +low-level functions for manipulating geometrical primitives, making easier the +development of more complex geometric algorithms. + +Some features of the library are: + +- creation of various shapes (points, circles, lines, ellipses, polylines, + polygons...) through an intuitive syntax. + Ex: createCircle(p1, p2, p3) to create a circle through 3 points. + +- derivation of new shapes: intersection between 2 lines, between line and + circle, between polylines... or point on a curve from its parametrisation + +- functions for polylines and polygons: compute centroid and area, expand, + self-intersections, clipping with half-plane... + +- manipulation of planar transformation. Ex.: + ROT = createRotation(CENTER, THETA); + P2 = transformPoint(P1, ROT); + +- direct drawing of shapes with specialized functions. Clipping is performed + automatically for infinite shapes such as lines or rays. Ex: + drawCircle([50 50 25]); % draw circle with radius 25 and center [50 50] + drawLine([X0 Y0 DX DY]); % clip and draw straight line + +- measure distances (between points, a point and a line, a point and a group + of points), angle (of a line, between 3 points), or test geometry (point + on a line, on a circle). + +Additional help is provided in geom/Contents.m file, as well as summary files + like 'points2d.m' or 'lines2d.m'.
--- a/main/geometry/matGeom_raw/geom2d/changelog.txt Fri Oct 21 18:51:49 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ -%% Copyright (c) 2011, INRA -%% 2007-2011, David Legland <david.legland@grignon.inra.fr> -%% 2011 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch> -%% -%% 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. - - -change log for geom2d - -geom2d, release 2011.??.?? -========================== - -New functions -- added angleDiff and angleAbsDiff - -various doc updates - - -geom2d, release 2011.06.30 -========================== - -New functions -- added function rotateVector -- added function randomPointInBox - -Changes -- Shape orientation is now represented using degrees -- function vectorAngle can now compute the angle between two vectors - -Bug fixes -- enhanced function distancePointEdge -- enhanced function isPointOnEdge -- enhanced function isParallel -- fixed bugs intersectLineCircle - - -geom2d, release 2011.03.21 -========================== - -New functions -- added functions intersectLineCircle and intersectCircles -- added functions inertiaEllipse, isPointInEllipse -- added function drawBezierCurve -- added functions intersectBoxes and mergeBoxes - -Changes -- re-organized the library in three sub-directories: geom2d, polygons2d, and - polynomialCurves2d -- cleanup of code and doc - -Bug fixes -- several bugs fixed in clipEdge, isPointOnEdge - - -geom2d, release 2010.08.06 -========================== - -New functions -- polygonToRow and rowToPolygon, to convert polygon to a row vector -- midPoint, to compute middle points of either 2 points or an edge -- added rad2deg and deg2rad, for angle conversions - -Changes -- createCircle and createdirectedCircle are now vectorized, and use different - convention for 2 input variables (center + point and circle) -- median line has been vectorized - -Bug fixes -- fix bugs in intersectEdges -- fix bugs in clipLine -- rewrite drawLine using clipLine - - -geom2d, release 2010.07.19 -========================== - -new functions - -- isCounterClockwise -- intersectRayPolygon -- clipRay -- reverseEdge -- drawBox -- fitAffineTransform2d - -Changes - -- updated inertiaEllipse -- fixed bugs in intersectEdges.m, isParallel.m and isPerpendicular.m -- vectorized intersectLinePolygon -- fixed precision bug in isPointOnEdge -- renamed formatAngle to normalizeAngle -- created help file 'angles2d' -- fixed bug in weighted centroid computation - -various bug fixes, and doc updates. - - - -geom2d, release 2009.07.22 -========================== - -new features - -- new functions for polygons: - polygonPoint, polygonSubcurve, polygonLoops, distancePointPolygon, - distancePolygons, expandPolygon, polygonSelfIntersections, - projPointOnPolygon, isPointInPolygon, reveresPolygon - -- new functions for polylines: - intersectPolylines, polylineSelfIntersections, distancePolylines, - isPointOnPolyline, reveresPolyline - -- projPointOnPolyline can also return the distance of the point to the polyline - -- function 'edgeToLine' converts an edge to its supporting line - - -Changes - -- Renamed functions - + subcurve -> polylineSubCurve - + curveCentroid -> polylineCentroid - + invertLine -> reverseLine - -- Compatibility considerations - + parallelLine: changed convention for signed distance - -various bug fixes, and doc updates. - - -geom2d, release 2009.06.15 -========================== - -* new features - -- radicalAxis from 2 circles: -- moment of a curve (polyline): curveMoment, curveCMoment, curveCSMoment -- new functions for polylines - distancePointPolyline, drawPolyline, polylineLength, polylinePoint, - polylineSubcurve, projPointOnPolyline - -* changes - -- changed some function names to avoid potential name conflicts, and to make - function names more explicit: - + rotation -> createRotation - + scaling -> createScaling - + translation -> createRotation - + homothecy -> createHomothecy - + lineSymmetry -> createLineReflection - + inCircle -> isPointInCircle - + onCircle -> isPointOnCircle - + onEdge -> isPointOnEdge - + onLine -> isPointOnLine - + onRay -> isPointOnRay - + normalize -> normalizeVector - - -* bug fixes - -- fixed bug in intersectEdges - -many updates in doc. -
--- a/main/geometry/matGeom_raw/geom2d/inertiaEllipse.m Fri Oct 21 18:51:49 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -%% Copyright (c) 2011, INRA -%% 2007-2011, David Legland <david.legland@grignon.inra.fr> -%% 2011 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch> -%% -%% 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. - - -function ell = inertiaEllipse(points) -%INERTIAELLIPSE Inertia ellipse of a set of points -% -% ELL = inertiaEllipse(PTS); -% where PTS is a N*2 array containing coordinates of N points, computes -% the inertia ellispe of the set of points. -% -% The result has the form: -% ELL = [XC YC A B THETA], -% with XC and YC being the center of mass of the point set, A and B are -% the lengths of the inertia ellipse (see below), and THETA is the angle -% of the main inertia axis with the horizontal (counted in degrees -% between 0 and 180). -% A and B are the standard deviations of the point coordinates when -% ellipse is aligned with the inertia axes. -% -% Example -% pts = randn(100, 2); -% pts = transformPoint(pts, createScaling(5, 2)); -% pts = transformPoint(pts, createRotation(pi/6)); -% pts = transformPoint(pts, createTranslation(3, 4)); -% ell = inertiaEllipse(pts); -% figure(1); clf; hold on; -% drawPoint(pts); -% drawEllipse(ell, 'linewidth', 2, 'color', 'r'); -% -% See also -% ellipses2d, drawEllipse -% -% ------ -% Author: David Legland -% e-mail: david.legland@grignon.inra.fr -% Created: 2008-02-21, using Matlab 7.4.0.287 (R2007a) -% Copyright 2008 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas. - -% HISTORY -% 2009-07-29 take into account ellipse orientation -% 2011-03-12 rewrite using inertia moments - -% ellipse center -xc = mean(points(:,1)); -yc = mean(points(:,2)); - -% recenter points -x = points(:,1) - xc; -y = points(:,2) - yc; - -% number of points -n = size(points, 1); - -% inertia parameters -Ixx = sum(x.^2) / n; -Iyy = sum(y.^2) / n; -Ixy = sum(x.*y) / n; - -% compute ellipse semi-axis lengths -common = sqrt( (Ixx - Iyy)^2 + 4 * Ixy^2); -ra = sqrt(2) * sqrt(Ixx + Iyy + common); -rb = sqrt(2) * sqrt(Ixx + Iyy - common); - -% compute ellipse angle in degrees -theta = atan2(2 * Ixy, Ixx - Iyy) / 2; -theta = rad2deg(theta); - -% create the resulting inertia ellipse -ell = [xc yc ra rb theta];
--- a/main/geometry/matGeom_raw/geom2d/invertLine.m Fri Oct 21 18:51:49 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -%% Copyright (c) 2011, INRA -%% 2007-2011, David Legland <david.legland@grignon.inra.fr> -%% 2011 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch> -%% -%% 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. - - -function line = invertLine(var) -%INVERTLINE return same line but with opposite orientation -% -% INVLINE = invertLine(LINE); -% Returns the opposite line of LINE. -% LINE has the format [x0 y0 dx dy], then INVLINE will have following -% parameters: [x0 y0 -dx -dy]. -% -% See also: -% lines2d, createLine -% -% --------- -% author : David Legland -% INRA - TPV URPOI - BIA IMASTE -% created the 20/01/2004. -% - -% HISTORY -% 30/06/2009 deprecate and replace by 'reverseLine'. - -% deprecation warning -warning('geom2d:deprecated', ... - '''invertLine'' is deprecated, use ''reverseLine'' instead'); - -line = 0; - -if size(var, 1)==1 - % only one line in a single array - line = [var(1) var(2) -var(3) -var(4)]; -else - % several lines in a single array - n = size(var, 1); - line(1:n, 1) = var(1:n, 1); - line(1:n, 2) = var(1:n, 2); - line(1:n, 3) = -var(1:n, 3); - line(1:n, 4) = -var(1:n, 4); -end
--- a/main/geometry/matGeom_raw/geom2d/readme.txt Fri Oct 21 18:51:49 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -%% Copyright (c) 2011, INRA -%% 2007-2011, David Legland <david.legland@grignon.inra.fr> -%% 2011 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch> -%% -%% 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. - - -Description of the geom2d library. - -The aim of geom2d library is to handle and visualize geometric primitives such -as points, lines, circles and ellipses, polylines and polygons... It provides -low-level functions for manipulating geometrical primitives, making easier the -development of more complex geometric algorithms. - -Some features of the library are: - -- creation of various shapes (points, circles, lines, ellipses, polylines, - polygons...) through an intuitive syntax. - Ex: createCircle(p1, p2, p3) to create a circle through 3 points. - -- derivation of new shapes: intersection between 2 lines, between line and - circle, between polylines... or point on a curve from its parametrisation - -- functions for polylines and polygons: compute centroid and area, expand, - self-intersections, clipping with half-plane... - -- manipulation of planar transformation. Ex.: - ROT = createRotation(CENTER, THETA); - P2 = transformPoint(P1, ROT); - -- direct drawing of shapes with specialized functions. Clipping is performed - automatically for infinite shapes such as lines or rays. Ex: - drawCircle([50 50 25]); % draw circle with radius 25 and center [50 50] - drawLine([X0 Y0 DX DY]); % clip and draw straight line - -- measure distances (between points, a point and a line, a point and a group - of points), angle (of a line, between 3 points), or test geometry (point - on a line, on a circle). - -Additional help is provided in geom/Contents.m file, as well as summary files - like 'points2d.m' or 'lines2d.m'.