From: <jpi...@us...> - 2011-10-21 19:44:36
|
Revision: 8828 http://octave.svn.sourceforge.net/octave/?rev=8828&view=rev Author: jpicarbajal Date: 2011-10-21 19:44:24 +0000 (Fri, 21 Oct 2011) Log Message: ----------- geometry. Geom2d done! Some tests missing and demos Added Paths: ----------- trunk/octave-forge/main/geometry/geom2d/inst/circleArcAsCurve.m trunk/octave-forge/main/geometry/geom2d/inst/circleAsPolygon.m trunk/octave-forge/main/geometry/geom2d/inst/crackPattern.m trunk/octave-forge/main/geometry/geom2d/inst/crackPattern2.m trunk/octave-forge/main/geometry/geom2d/inst/distancePointEdge.m trunk/octave-forge/main/geometry/geom2d/inst/distancePointLine.m trunk/octave-forge/main/geometry/geom2d/inst/ellipseAsPolygon.m trunk/octave-forge/main/geometry/geom2d/inst/enclosingCircle.m trunk/octave-forge/main/geometry/geom2d/inst/radicalAxis.m trunk/octave-forge/main/geometry/geom2d/inst/reverseEdge.m trunk/octave-forge/main/geometry/geom2d/inst/reverseLine.m Removed Paths: ------------- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleArcAsCurve.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleAsPolygon.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/clipLineRect.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/crackPattern.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/crackPattern2.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/distancePointEdge.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/distancePointLine.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/ellipseAsPolygon.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/enclosingCircle.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/radicalAxis.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/reverseEdge.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/reverseLine.m Copied: trunk/octave-forge/main/geometry/geom2d/inst/circleArcAsCurve.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleArcAsCurve.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/circleArcAsCurve.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/circleArcAsCurve.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,79 @@ +%% Copyright (c) 2011, INRA +%% 2006-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} {@var{p} = } circleArcAsCurve (@var{arc}, @var{N}) +%% Convert a circle arc into a series of points +%% +%% P = circleArcAsCurve(ARC, N); +%% convert the circle ARC into a series of N points. +%% ARC is given in the format: [XC YC R THETA1 DTHETA] +%% where XC and YC define the center of the circle, R its radius, THETA1 +%% is the start of the arc and DTHETA is the angle extent of the arc. Both +%% angles are given in degrees. +%% N is the number of vertices of the resulting polyline, default is 65. +%% +%% The result is a N-by-2 array containing coordinates of the N points. +%% +%% [X Y] = circleArcAsCurve(ARC, N); +%% Return the result in two separate arrays with N lines and 1 column. +%% +%% +%% @seealso{circles2d, circleAsPolygon, drawCircle, drawPolygon} +%% @end deftypefn + +function varargout = circleArcAsCurve(arc, N) + + % default value for N + if nargin < 2 + N = 65; + end + + % vector of positions + t0 = deg2rad(arc(4)); + t1 = t0 + deg2rad(arc(5)); + t = linspace(t0, t1, N)'; + + % compute coordinates of vertices + x = arc(1) + arc(3) * cos(t); + y = arc(2) + arc(3) * sin(t); + + % format output + if nargout <= 1 + varargout = {[x y]}; + else + varargout = {x, y}; + end + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/circleAsPolygon.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleAsPolygon.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/circleAsPolygon.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/circleAsPolygon.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,74 @@ +%% Copyright (c) 2011, INRA +%% 2005-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} {@var{P} = } circleAsPolygon (@var{circle}, @var{N}) +%% Convert a circle into a series of points +%% +%% P = circleAsPolygon(CIRCLE, N); +%% convert circle given as [x0 y0 r], where x0 and y0 are coordinate of +%% center, and r is the radius, into an array of [(N+1)x2] double, +%% containing x and y values of points. +%% The polygon is closed +%% +%% P = circleAsPolygon(CIRCLE); +%% uses a default value of N=64 points +%% +%% Example +%% circle = circleAsPolygon([10 0 5], 16); +%% figure; +%% drawPolygon(circle); +%% +%% @seealso{circles2d, polygons2d, createCircle} +%% @end deftypefn + +function varargout = circleAsPolygon(circle, varargin) + % determines number of points + N = 64; + if ~isempty(varargin) + N = varargin{1}; + end + + % create circle + t = linspace(0, 2*pi, N+1)'; + x = circle(1) + circle(3)*cos(t); + y = circle(2) + circle(3)*sin(t); + + if nargout==1 + varargout{1}=[x y]; + elseif nargout==2 + varargout{1}=x; + varargout{2}=y; + end + +endfunction Copied: trunk/octave-forge/main/geometry/geom2d/inst/crackPattern.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/crackPattern.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/crackPattern.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/crackPattern.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,189 @@ +%% 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} {@var{e} = } crackPattern (@var{box}, @var{points}, @var{alpha}) +%% Create a (bounded) crack pattern tessellation +%% +%% E = crackPattern2(BOX, POINTS, ALPHA) +%% create a crack propagation pattern wit following parameters : +%% - pattern is bounded by area BOX which is a polygon. +%% - each crack originates from points given in POINTS +%% - directions of each crack is given by a [NxM] array ALPHA, where M is +%% the number of rays emanating from each seed/ +%% - a crack stop when it reaches another already created crack. +%% - all cracks stop when they reach the border of the frame, given by box +%% (a serie of 4 points). +%% The result is a collection of edges, in the form [x1 y1 x2 y2]. +%% +%% E = crackPattern2(BOX, POINTS, ALPHA, SPEED) +%% Also specify speed of propagation of each crack. +%% +%% +%% See the result with : +%% figure; +%% drawEdge(E); +%% +%% @seealso{drawEdge} +%% @end deftypefn + +function edges = crackPattern(box, points, alpha, varargin) + + if ~isempty(varargin) + speed = varargin{1}; + else + speed = ones(size(points, 1), 1); + end + + % Compute line equations for each initial crack. + % The two 'Inf' at the end correspond to the position of the limit. + % If an intersection point is found with another line, but whose position + % is after this value, this means that another crack stopped it before it + % reach the intersection point. + % There is one 'end position' for each side of the crack. + lines = [points speed.*cos(alpha) speed.*sin(alpha) Inf*ones(size(points, 1), 2)]; + + % initialize lines for borders, but assign a very high speed, to be sure + % borders will stop all cracks. + dx = (box([2 3 4 1],1)-box([1 2 3 4],1))*max(speed)*5; + dy = (box([2 3 4 1],2)-box([1 2 3 4],2))*max(speed)*5; + + % add borders to the lines set + lines = [lines ; createLine(box, dx, dy) Inf*ones(4,2)]; + + edges = zeros(0, 4); + + + while true + modif = 0; + + % try to update each line + for i=1:size(points, 1) + + % compute intersections with all other lines + pi = intersectLines(lines(i,:), lines); + + % compute position of all intersection points on the current line + pos = linePosition(pi, lines(i,:)); + + % consider points to the right (positive position), and sort them + indr = find(pos>=0 & pos~=Inf); + [posr, indr2] = sort(pos(indr)); + + + % look for the closest intersection to the right + for i2=1:length(indr2) + + % index of intersected line + il = indr(indr2(i2)); + + % position of point relative to intersected line + pos2 = linePosition(pi(il, :), lines(il, :)); + + % depending on the sign of position, tests if the line2 can + % stop the current line, or if it was stopped before + if pos2>0 + if pos2<abs(posr(i2)) && pos2<lines(il, 5) + if lines(i, 5) ~= posr(i2) + edges(i, 3:4) = pi(il,:); + lines(i, 5) = posr(i2); + modif = 1; + end + break; + end + else + if abs(pos2)<abs(posr(i2)) && abs(pos2)<lines(il, 6) + if lines(i, 5) ~= posr(i2); + edges(i, 3:4) = pi(il,:); + lines(i, 5) = posr(i2); + modif = 1; + end + break; + end + end + + end % end processing of right points of the line + + + + % consider points to the left (negative position), and sort them + indl = find(pos<=0 && pos~=Inf); + [posl, indl2] = sort(abs(pos(indl))); + + % look for the closest intersection to the right + for i2=1:length(indl2) + % index of intersected line + il = indl(indl2(i2)); + + % position of point relative to intersected line + pos2 = linePosition(pi(il, :), lines(il, :)); + + % depending on the sign of position, tests if the line2 can + % stop the current line, or if it was stopped before + if pos2>0 + if pos2<abs(posl(i2)) && pos2<lines(il, 5) + if lines(i, 6) ~= abs(posl(i2)); + edges(i, 1:2) = pi(il, :); + lines(i, 6) = abs(posl(i2)); + modif = 1; + end + break; + end + else + if abs(pos2)<abs(posl(i2)) && abs(pos2)<lines(il, 6) + if lines(i, 6) ~= abs(posl(i2)); + edges(i, 1:2) = pi(il, :); + lines(i, 6) = abs(posl(i2)); + modif = 1; + end + break; + end + end + + end % end processing of left points of the line + + + end % end processing of all lines + + % break the infinite loop if no more modification was made + if ~modif + break; + end + end + + % add edges of the surronding box. + edges = [edges ; box(1,:) box(2,:) ; box(2,:) box(3,:); ... + box(3,:) box(4,:) ; box(4,:) box(1,:) ]; + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/crackPattern2.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/crackPattern2.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/crackPattern2.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/crackPattern2.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,148 @@ +%% Copyright (c) 2011, INRA +%% 2004-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} {@var{e} = } crackPattern2 (@var{box}, @var{points}, @var{alpha}) +%% Create a (bounded) crack pattern tessellation +%% +%% E = crackPattern2(BOX, POINTS, ALPHA) +%% create a crack propagation pattern wit following parameters : +%% - pattern is bounded by area BOX which is a polygon. +%% - each crack originates from points given in POINTS +%% - directions of each crack is given by a [NxM] array ALPHA, where M is +%% the number of rays emanating from each seed/ +%% - a crack stop when it reaches another already created crack. +%% - all cracks stop when they reach the border of the frame, given by box +%% (a serie of 4 points). +%% The result is a collection of edges, in the form [x1 y1 x2 y2]. +%% +%% E = crackPattern2(BOX, POINTS, ALPHA, SPEED) +%% Also specify speed of propagation of each crack. +%% +%% +%% See the result with : +%% figure; +%% drawEdge(E); +%% +%% @seealso{drawEdge} +%% @end deftypefn + +function edges = crackPattern2(box, points, alpha, varargin) + + if ~isempty(varargin) + speed = varargin{1}; + else + speed = ones(size(points, 1), 1); + end + + % Compute line equations for each initial crack. + % The 'Inf' at the end correspond to the position of the limit. + % If an intersection point is found with another line, but whose position + % is after this value, this means that another crack stopped it before it + % reach the intersection point. + NP = size(points, 1); + lines = zeros(0, 5); + for i=1:size(alpha, 2) + lines = [lines; points speed.*cos(alpha(:,i)) speed.*sin(alpha(:,i)) Inf*ones(NP, 1)]; + end + NL = size(lines, 1); + + % initialize lines for borders, but assign a very high speed, to be sure + % borders will stop all cracks. + dx = (box([2 3 4 1],1)-box([1 2 3 4],1))*max(speed)*5; + dy = (box([2 3 4 1],2)-box([1 2 3 4],2))*max(speed)*5; + + % add borders to the lines set + lines = [lines ; createLine(box, dx, dy) Inf*ones(4,1)]; + + edges = zeros(0, 4); + + + while true + modif = 0; + + % try to update each line + for i=1:NL + + % initialize first point of edge + edges(i, 1:2) = lines(i, 1:2); + + % compute intersections with all other lines + pi = intersectLines(lines(i,:), lines); + + % compute position of all intersection points on the current line + pos = linePosition(pi, lines(i,:)); + + + % consider points to the right (positive position), and sort them + indr = find(pos>1e-12 & pos~=Inf); + [posr, indr2] = sort(pos(indr)); + + + % look for the closest intersection to the right + for i2=1:length(indr2) + + % index of intersected line + il = indr(indr2(i2)); + + % position of point relative to intersected line + pos2 = linePosition(pi(il, :), lines(il, :)); + + % depending on the sign of position, tests if the line2 can + % stop the current line, or if it was stopped before + if pos2>0 + if pos2<abs(posr(i2)) && pos2<lines(il, 5) + if lines(i, 5) ~= posr(i2) + edges(i, 3:4) = pi(il,:); + lines(i, 5) = posr(i2); + modif = 1; + end + break; + end + end + end % end processing of right points of the line + + + end % end processing of all lines + + % break the infinite loop if no more modification was made + if ~modif + break; + end + end + + % add edges of the surronding box. + edges = [edges ; box(1,:) box(2,:) ; box(2,:) box(3,:); ... + box(3,:) box(4,:) ; box(4,:) box(1,:) ]; + +endfunction Copied: trunk/octave-forge/main/geometry/geom2d/inst/distancePointEdge.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/distancePointEdge.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/distancePointEdge.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/distancePointEdge.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,85 @@ +%% 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} {@var{dist} = } distancePointEdge (@var{point}, @var{edge}) +%% Minimum distance between a point and an edge +%% +%% DIST = distancePointEdge(POINT, EDGE); +%% Return the euclidean distance between edge EDGE and point POINT. +%% EDGE has the form: [x1 y1 x2 y2], and POINT is [x y]. +%% +%% If EDGE is N-by-4 array, result is N-by-1 array computed for each edge. +%% If POINT is a N-by-2 array, the result is computed for each point. +%% If both POINT and EDGE are array, they must have the same number of +%% rows, and the result is computed for each couple point(i,:);edge(i,:). +%% +%% [DIST POS] = distancePointEdge(POINT, EDGE); +%% Also returns the position of closest point on the edge. POS is +%% comprised between 0 (first point) and 1 (last point). +%% +%% @seealso{edges2d, points2d, distancePoints, distancePointLine} +%% @end deftypefn + +function varargout = distancePointEdge(point, edge) + % direction vector of each edge + dx = edge(:, 3) - edge(:,1); + dy = edge(:, 4) - edge(:,2); + + % compute position of points projected on the supporting line + % (Size of tp is the max number of edges or points) + delta = dx .* dx + dy .* dy; + tp = ((point(:, 1) - edge(:, 1)) .* dx + (point(:, 2) - edge(:, 2)) .* dy) ./ delta; + + % ensure degenerated edges are correclty processed (consider the first + % vertex is the closest) + tp(delta < eps) = 0; + + % change position to ensure projected point is located on the edge + tp(tp < 0) = 0; + tp(tp > 1) = 1; + + % coordinates of projected point + p0 = [edge(:,1) + tp .* dx, edge(:,2) + tp .* dy]; + + % compute distance between point and its projection on the edge + dist = sqrt((point(:,1) - p0(:,1)) .^ 2 + (point(:,2) - p0(:,2)) .^ 2); + + % process output arguments + varargout{1} = dist; + if nargout > 1 + varargout{2} = tp; + end + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/distancePointLine.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/distancePointLine.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/distancePointLine.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/distancePointLine.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,77 @@ +%% Copyright (c) 2011, INRA +%% 2004-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} {@var{dist} = } distancePointLine (@var{point}, @var{line}) +%% Minimum distance between a point and a line +%% +%% D = distancePointLine(POINT, LINE) +%% Return the euclidean distance between line LINE and point POINT. +%% +%% LINE has the form : [x0 y0 dx dy], and POINT is [x y]. +%% +%% If LINE is N-by-4 array, result is N-by-1 array computes for each line. +%% +%% If POINT is N-by-2, then result is computed for each point. +%% +%% If both POINT and LINE are array, result is N-by-1, computed for each +%% corresponding point and line. +%% +%% +%% @seealso{lines2d, points2d, distancePoints, distancePointEdge} +%% @end deftypefn + +function dist = distancePointLine(point, line) + + if size(line, 1)==1 && size(point, 1)>1 + line = repmat(line, [size(point, 1) 1]); + end + + if size(point, 1)==1 && size(line, 1)>1 + point = repmat(point, [size(line, 1) 1]); + end + + dx = line(:, 3); + dy = line(:, 4); + + % compute position of points projected on line + tp = ((point(:, 2) - line(:, 2)).*dy + (point(:, 1) - line(:, 1)).*dx) ./ (dx.*dx+dy.*dy); + p0 = line(:, 1:2) + [tp tp].*[dx dy]; + + + % compute distances between points and their projections + dx = point - p0; + dist = sqrt(sum(dx.*dx, 2)); + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/ellipseAsPolygon.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/ellipseAsPolygon.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/ellipseAsPolygon.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/ellipseAsPolygon.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,93 @@ +%% Copyright (c) 2011, INRA +%% 2004-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} {@var{p} = } ellipseAsPolygon (@var{ell}, @var{n}) +%% Convert an ellipse into a series of points +%% +%% P = ellipseAsPolygon(ELL, N); +%% converts ELL given as [x0 y0 a b] or [x0 y0 a b theta] into a polygon +%% with N edges. The result P is (N+1)-by-2 array containing coordinates +%% of the N+1 vertices of the polygon. +%% The resulting polygon is closed, i.e. the last point is the same as the +%% first one. +%% +%% P = ellipseAsPolygon(ELL); +%% Use a default number of edges equal to 72. This result in one piont for +%% each 5 degrees. +%% +%% [X Y] = ellipseAsPolygon(...); +%% Return the coordinates o fvertices in two separate arrays. +%% +%% @seealso{ellipses2d, circleAsPolygon, rectAsPolygon, drawEllipse} +%% @end deftypefn + +function varargout = ellipseAsPolygon(ellipse, N) + + % default value for N + if nargin < 2 + N = 72; + end + + % angle of ellipse + theta = 0; + if size(ellipse, 2) > 4 + theta = ellipse(:,5); + end + + % get ellipse parameters + xc = ellipse(:,1); + yc = ellipse(:,2); + a = ellipse(:,3); + b = ellipse(:,4); + + % create time basis + t = linspace(0, 2*pi, N+1)'; + + % pre-compute trig functions (angles is in degrees) + cot = cosd(theta); + sit = sind(theta); + + % position of points + x = xc + a * cos(t) * cot - b * sin(t) * sit; + y = yc + a * cos(t) * sit + b * sin(t) * cot; + + % format output depending on number of a param. + if nargout == 1 + varargout = {[x y]}; + elseif nargout == 2 + varargout = {x, y}; + end + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/enclosingCircle.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/enclosingCircle.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/enclosingCircle.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/enclosingCircle.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,99 @@ +%% 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} {@var{circle} = } enclosingCircle (@var{pts}) +%% Find the minimum circle enclosing a set of points. +%% +%% CIRCLE = enclosingCircle(POINTS); +%% compute cirlce CIRCLE=[xc yc r] which enclose all points POINTS given +%% as an [Nx2] array. +%% +%% +%% Rewritten from a file from +%% Yazan Ahed (ya...@gm...) +%% +%% which was rewritten from a Java applet by Shripad Thite : +%% http://heyoka.cs.uiuc.edu/~thite/mincircle/ +%% +%% @seealso{circles2d, points2d, boxes2d} +%% @end deftypefn + +function circle = enclosingCircle(pts) + + % works on convex hull : it is faster + pts = pts(convhull(pts(:,1), pts(:,2)), :); + + circle = recurseCircle(size(pts, 1), pts, 1, zeros(3, 2)); + +endfunction + +function circ = recurseCircle(n, p, m, b) +% n: number of points given +% m: an argument used by the function. Always use 1 for m. +% bnry: an argument (3x2 array) used by the function to set the points that +% determines the circle boundry. You have to be careful when choosing this +% array's values. I think the values should be somewhere outside your points +% boundary. For my case, for example, I know the (x,y) I have will be something +% in between (-5,-5) and (5,5), so I use bnry as: +% [-10 -10 +% -10 -10 +% -10 -10] + + + if m==4 + circ = createCircle(b(1,:), b(2,:), b(3,:)); + return; + end + + circ = [Inf Inf 0]; + + if m == 2 + circ = [b(1,1:2) 0]; + elseif m == 3 + c = (b(1,:) + b(2,:))/2; + circ = [c distancePoints(b(1,:), c)]; + end + + + for i = 1:n + if distancePoints(p(i,:), circ(1:2)) > circ(3) + if sum(b(:,1)==p(i,1) & b(:,2)==p(i,2)) == 0 + b(m,:) = p(i,:); + circ = recurseCircle(i, p, m+1, b); + end + end + end + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/radicalAxis.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/radicalAxis.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/radicalAxis.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/radicalAxis.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,88 @@ +%% Copyright (c) 2011, INRA +%% 2004-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} {@var{line} = } radicalAxis (@var{circle1}, @var{circle2}) +%% Compute the radical axis (or radical line) of 2 circles +%% +%% L = radicalAxis(C1, C2) +%% Computes the radical axis of 2 circles. +%% +%% Example +%% C1 = [10 10 5]; +%% C2 = [60 50 30]; +%% L = radicalAxis(C1, C2); +%% hold on; axis equal;axis([0 100 0 100]); +%% drawCircle(C1);drawCircle(C2);drawLine(L); +%% +%% Ref: +%% http://mathworld.wolfram.com/RadicalLine.html +%% http://en.wikipedia.org/wiki/Radical_axis +%% +%% @seealso{lines2d, circles2d, createCircle} +%% +%% @end deftypefn + +function line = radicalAxis(circle1, circle2) + + % extract circles parameters + x1 = circle1(:,1); + x2 = circle2(:,1); + y1 = circle1(:,2); + y2 = circle2(:,2); + r1 = circle1(:,3); + r2 = circle2(:,3); + + % distance between each couple of centers + dist = sqrt((x2-x1).^2 + (y2-y1).^2); + + % relative position of intersection point of + % the radical line with the line joining circle centers + d = (dist.^2 + r1.^2 - r2.^2) * .5 ./ dist; + + % compute angle of radical axis + angle = lineAngle(createLine([x1 y1], [x2 y2])); + cot = cos(angle); + sit = sin(angle); + + % parameters of the line + x0 = x1 + d*cot; + y0 = y1 + d*sit; + dx = -sit; + dy = cot; + + % concatenate into one structure + line = [x0 y0 dx dy]; + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/reverseEdge.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/reverseEdge.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/reverseEdge.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/reverseEdge.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,50 @@ +%% Copyright (c) 2011, INRA +%% 2010-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} {@var{res} = } reverseEdge (@var{edge}) +%% Intervert the source and target vertices of edge +%% +%% REV = reverseEdge(EDGE); +%% Returns the opposite edge of EDGE. +%% EDGE has the format [X1 Y1 X2 Y2]. The resulting edge REV has value +%% [X2 Y2 X1 Y1]; +%% +%% @seealso{edges2d, createEdge, reverseLine} +%% @end deftypefn + +function res = reverseEdge(edge) + + res = [edge(:,3:4) edge(:,1:2)]; + +endfunction Copied: trunk/octave-forge/main/geometry/geom2d/inst/reverseLine.m (from rev 8818, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/reverseLine.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/reverseLine.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/reverseLine.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -0,0 +1,52 @@ +%% Copyright (c) 2011, INRA +%% 2004-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} {@var{line} = } reverseLine (@var{line}) +%% Return same line but with opposite orientation +%% +%% INVLINE = reverseLine(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]. +%% +%% @seealso{lines2d, createLine} +%% @end deftypefn + +function line = reverseLine(line) + + line(:, 3:4) = -line(:, 3:4); + +endfunction + + Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleArcAsCurve.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleArcAsCurve.m 2011-10-21 19:22:12 UTC (rev 8827) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleArcAsCurve.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -1,84 +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. - - -function varargout = circleArcAsCurve(arc, N) -%CIRCLEARCASCURVE Convert a circle arc into a series of points -% -% P = circleArcAsCurve(ARC, N); -% convert the circle ARC into a series of N points. -% ARC is given in the format: [XC YC R THETA1 DTHETA] -% where XC and YC define the center of the circle, R its radius, THETA1 -% is the start of the arc and DTHETA is the angle extent of the arc. Both -% angles are given in degrees. -% N is the number of vertices of the resulting polyline, default is 65. -% -% The result is a N-by-2 array containing coordinates of the N points. -% -% [X Y] = circleArcAsCurve(ARC, N); -% Return the result in two separate arrays with N lines and 1 column. -% -% -% See also: -% circles2d, circleAsPolygon, drawCircle, drawPolygon -% -% -% --------- -% author : David Legland -% created the 22/05/2006. -% Copyright 2010 INRA - Cepia Software Platform. -% - -% HISTORY -% 2011-03-30 use angles in degrees, add default value for N - -% default value for N -if nargin < 2 - N = 65; -end - -% vector of positions -t0 = deg2rad(arc(4)); -t1 = t0 + deg2rad(arc(5)); -t = linspace(t0, t1, N)'; - -% compute coordinates of vertices -x = arc(1) + arc(3) * cos(t); -y = arc(2) + arc(3) * sin(t); - -% format output -if nargout <= 1 - varargout = {[x y]}; -else - varargout = {x, y}; -end Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleAsPolygon.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleAsPolygon.m 2011-10-21 19:22:12 UTC (rev 8827) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/circleAsPolygon.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -1,81 +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. - - -function varargout = circleAsPolygon(circle, varargin) -%CIRCLEASPOLYGON Convert a circle into a series of points -% -% P = circleAsPolygon(CIRCLE, N); -% convert circle given as [x0 y0 r], where x0 and y0 are coordinate of -% center, and r is the radius, into an array of [(N+1)x2] double, -% containing x and y values of points. -% The polygon is closed -% -% P = circleAsPolygon(CIRCLE); -% uses a default value of N=64 points -% -% Example -% circle = circleAsPolygon([10 0 5], 16); -% figure; -% drawPolygon(circle); -% -% See also: -% circles2d, polygons2d, createCircle -% -% -% --------- -% author : David Legland -% created the 06/04/2005. -% Copyright 2010 INRA - Cepia Software Platform. -% - -% HISTORY -% 20/04/2007: return a closed polygon with N+1 vertices, use default N=64 - -% determines number of points -N = 64; -if ~isempty(varargin) - N = varargin{1}; -end - -% create circle -t = linspace(0, 2*pi, N+1)'; -x = circle(1) + circle(3)*cos(t); -y = circle(2) + circle(3)*sin(t); - -if nargout==1 - varargout{1}=[x y]; -elseif nargout==2 - varargout{1}=x; - varargout{2}=y; -end Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/clipLineRect.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/clipLineRect.m 2011-10-21 19:22:12 UTC (rev 8827) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/clipLineRect.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -1,85 +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. - - -function edge = clipLineRect(line, rect) -%CLIPLINERECT clip a line with a polygon -% -% EDGE = clipLineRect(LINE, RECT); -% LINE: line in the form [x0 y0 dx dy] -% RECT: a rectangle in the form [xr yr wr hr] (xr and yr: coordinate of -% first point, wr and hr are width and height of rectangle) -% -% Deprecated: use function clipLine instead -% -% --------- -% author : David Legland -% created the 24/07/2006. -% Copyright 2010 INRA - Cepia Software Platform. -% - -% HISTORY - -if size(line, 1)==1 - line = repmat(line, size(rect, 1), 1); -elseif size(rect, 1)==1 - rect = repmat(rect, size(line, 1), 1); -elseif size(line, 1) ~= size(rect, 1) - error('bad sizes for input'); -end - -edge = zeros(size(line, 1), 4); -for i=1:size(line, 1) - x = rect(i, 1); y = rect(i, 2); w = rect(i, 3); h = rect(i, 4); - - % intersection with axis : x=xmin - px1 = intersectLineEdge(line(i,:), [x y x+w y]); - px2 = intersectLineEdge(line(i,:), [x+w y x+w y+h]); - py1 = intersectLineEdge(line(i,:), [x+w y+h x y+h]); - py2 = intersectLineEdge(line(i,:), [x y+h x y]); - - % sort points along the x coordinate, and draw a line between - % the two in the middle - points = sortrows([px1 ; px2 ; py1 ; py2], 1); - if points(2,1)>=x-1e-14 && points(2,1)<=x+w+1e-14 - if isfinite(points(3,1)) - edge(i, 1:4) = [points(2,:) points(3,:)]; - else - edge(i, 1:4) = [points(1,:) points(2,:)]; - end - else - % line outside the rectangle - edge(i, 1:4) = [0 0 0 0]; - end -end - Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/crackPattern.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/crackPattern.m 2011-10-21 19:22:12 UTC (rev 8827) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/crackPattern.m 2011-10-21 19:44:24 UTC (rev 8828) @@ -1,192 +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. - - -function edges = crackPattern(box, points, alpha, varargin) -%CRACKPATTERN C... [truncated message content] |