From: <jpi...@us...> - 2011-10-18 15:24:56
|
Revision: 8780 http://octave.svn.sourceforge.net/octave/?rev=8780&view=rev Author: jpicarbajal Date: 2011-10-18 15:24:44 +0000 (Tue, 18 Oct 2011) Log Message: ----------- geometry. Adding final functions from geom2d. Modified Paths: -------------- trunk/octave-forge/main/geometry/doc/NEWS trunk/octave-forge/main/geometry/matGeom_raw/geom2d/lineFit.m Added Paths: ----------- trunk/octave-forge/main/geometry/geom2d/inst/Contents.m trunk/octave-forge/main/geometry/geom2d/inst/bisector.m trunk/octave-forge/main/geometry/geom2d/inst/cartesianLine.m trunk/octave-forge/main/geometry/geom2d/inst/drawArrow.m trunk/octave-forge/main/geometry/geom2d/inst/edges2d.m trunk/octave-forge/main/geometry/geom2d/inst/lines2d.m trunk/octave-forge/main/geometry/geom2d/inst/orthogonalLine.m trunk/octave-forge/main/geometry/geom2d/inst/parallelLine.m trunk/octave-forge/main/geometry/geom2d/inst/projPointOnLine.m Removed Paths: ------------- trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testBisector.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/Contents.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/bisector.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/cartesianLine.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/drawArrow.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/edges2d.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/lines2d.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/orthogonalLine.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/parallelLine.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/projPointOnLine.m Modified: trunk/octave-forge/main/geometry/doc/NEWS =================================================================== --- trunk/octave-forge/main/geometry/doc/NEWS 2011-10-18 12:34:40 UTC (rev 8779) +++ trunk/octave-forge/main/geometry/doc/NEWS 2011-10-18 15:24:44 UTC (rev 8780) @@ -96,4 +96,16 @@ points2d.m intersectLineEdge.m isPointOnEdge.m + =============================================================================== +geometry-1.2 Release Date: 2011-10-13 Release Manager: Juan Pablo Carbajal +=============================================================================== + +* Continue all geom2d added + createCircle.m + createDirectedCircle.m + createEdge.m + medianLine.m + +=============================================================================== + Copied: trunk/octave-forge/main/geometry/geom2d/inst/Contents.m (from rev 8731, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/Contents.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/Contents.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/Contents.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -0,0 +1,230 @@ +%% 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 () +%% GEOM2D Geometry 2D Toolbox +%% Version 1.0 21-Mar-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 +%% (ya...@gm...), available on Matlab File Exchange +%% +%% ----- +%% Author: David Legland +%% e-mail: dav...@gr... +%% Created: 2005-11-07 +%% Copyright INRA - Cepia Software Platform. +%% Homepage: http://matgeom.sourceforge.net/ +%% http://www.pfl-cepia.inra.fr/index.php?page=geom2d +%% @end deftypefn + + 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/geom2d/inst/bisector.m (from rev 8731, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/bisector.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/bisector.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/bisector.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -0,0 +1,117 @@ +%% 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{ray} = } bisector (@var{line1}, @var{line2}) +%% @deftypefnx {Function File} {@var{ray} = } bisector (@var{p1}, @var{p2}, @var{p3}) +%% Return the bisector of two lines, or 3 points. +%% +%% Creates the bisector of the two lines, given as [x0 y0 dx dy]. +%% +%% create the bisector of lines (@var{p2} @var{p1}) and (@var{p2} @var{p3}). +%% +%% The result has the form [x0 y0 dx dy], with [x0 y0] being the origin +%% point ans [dx dy] being the direction vector, normalized to have unit +%% norm. +%% +%% @seealso{lines2d, rays2d} +%% @end deftypefn + +function ray = bisector(varargin) + + if length(varargin)==2 + % two lines + line1 = varargin{1}; + line2 = varargin{2}; + + point = intersectLines(line1, line2); + + elseif length(varargin)==3 + % three points + p1 = varargin{1}; + p2 = varargin{2}; + p3 = varargin{3}; + + line1 = createLine(p2, p1); + line2 = createLine(p2, p3); + point = p2; + + elseif length(varargin)==1 + % three points, given in one array + var = varargin{1}; + p1 = var(1, :); + p2 = var(2, :); + p3 = var(3, :); + + line1 = createLine(p2, p1); + line2 = createLine(p2, p3); + point = p2; + end + + % compute line angles + a1 = lineAngle(line1); + a2 = lineAngle(line2); + + % compute bisector angle (angle of first line + half angle between lines) + angle = mod(a1 + mod(a2-a1+2*pi, 2*pi)/2, pi*2); + + % create the resulting ray + ray = [point cos(angle) sin(angle)]; + +endfunction + +%!test +%! p0 = [0 0]; +%! p1 = [10 0]; +%! p2 = [0 10]; +%! line1 = createLine(p0, p1); +%! line2 = createLine(p0, p2); +%! ray = bisector(line1, line2); +%! assertElementsAlmostEqual([0 0], ray(1,1:2)); +%! assertAlmostEqual(pi/4, lineAngle(ray)); + +%!test +%! p0 = [0 0]; +%! p1 = [10 0]; +%! p2 = [0 10]; +%! ray = bisector(p1, p0, p2); +%! assertElementsAlmostEqual([0 0], ray(1,1:2)); +%! assertAlmostEqual(pi/4, lineAngle(ray)); + +%!test +%! p0 = [0 0]; +%! p1 = [10 0]; +%! p2 = [0 10]; +%! ray = bisector([p1; p0; p2]); +%! assertElementsAlmostEqual([0 0], ray(1,1:2)); +%! assertAlmostEqual(pi/4, lineAngle(ray)); Copied: trunk/octave-forge/main/geometry/geom2d/inst/cartesianLine.m (from rev 8731, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/cartesianLine.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/cartesianLine.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/cartesianLine.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -0,0 +1,69 @@ +%% 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} = } cartesianLine (@var{A}, @var{B},@var{C}) +%% Create a straight line from cartesian equation coefficients. +%% +%% Create a line verifying the Cartesian equation: +%% @var{A}*x + @var{B}*x + @var{C} = 0; +%% +%% @seealso{lines2d, createLine} +%% @end deftypefn + +function line = cartesianLine(varargin) + + if length(varargin)==1 + var = varargin{1}; + a = var(:,1); + b = var(:,2); + c = var(:,3); + elseif length(varargin)==3 + a = varargin{1}; + b = varargin{2}; + c = varargin{3}; + end + + % normalisation factor + d = a.*a + b.*b; + + x0 = -a.*c./d; + y0 = -b.*c./d; + theta = atan2(-a, b); + dx = cos(theta); + dy = sin(theta); + + line = [x0 y0 dx dy]; + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/drawArrow.m (from rev 8731, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/drawArrow.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/drawArrow.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/drawArrow.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -0,0 +1,142 @@ +%% 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{h} = } drawArrow (@var{x1}, @var{y1}, @var{x2}, @var{y2}) +%% @deftypefnx {Function File} {@var{h} = } drawArrow ([@var{ @var{x1}} @var{ @var{y1}} @var{x2} @var{y2}]) +%% @deftypefnx {Function File} {@var{h} = } drawArrow (@dots{}, @var{L}, @var{W}) +%% @deftypefnx {Function File} {@var{h} = } drawArrow (@dots{}, @var{L}, @var{W},@var{TYPE}) +%% Draw an arrow on the current axis. +%% +%% draw an arrow between the points (@var{x1} @var{y1}) and (@var{x2} @var{y2}). +%% The points can be given as a single array. @var{L}, @var{W} specify length +%% and width of the arrow. +%% +%% Also specify arrow type. @var{TYPE} can be one of the following : +%% 0: draw only two strokes +%% 1: fill a triangle +%% .5: draw a half arrow (try it to see ...) +%% +%% Arguments can be single values or array of size [N*1]. In this case, +%% the function draws multiple arrows. +%% +%% @end deftypefn + +function varargout = drawArrow(varargin) + + if isempty(varargin) + error('should specify at least one argument'); + end + + % parse arrow coordinate + var = varargin{1}; + if size(var, 2)==4 + @var{x1} = var(:,1); + @var{y1} = var(:,2); + x2 = var(:,3); + y2 = var(:,4); + varargin = varargin(2:end); + elseif length(varargin)>3 + @var{x1} = varargin{1}; + @var{y1} = varargin{2}; + x2 = varargin{3}; + y2 = varargin{4}; + varargin = varargin(5:end); + else + error('wrong number of arguments, please read the doc'); + end + + l = 10*size(size( @var{x1})); + w = 5*ones(size( @var{x1})); + h = zeros(size( @var{x1})); + + % exctract length of arrow + if ~isempty(varargin) + l = varargin{1}; + if length( @var{x1})>length(l) + l = l(1)*ones(size( @var{x1})); + end + end + + % extract width of arrow + if length(varargin)>1 + w = varargin{2}; + if length( @var{x1})>length(w) + w = w(1)*ones(size( @var{x1})); + end + end + + % extract 'ratio' of arrow + if length(varargin)>2 + h = varargin{3}; + if length( @var{x1})>length(h) + h = h(1)*ones(size( @var{x1})); + end + end + + hold on; + axis equal; + + % angle of the edge + theta = atan2(y2- @var{y1}, x2- @var{x1}); + + % point on the 'left' + xa1 = x2 - l.*cos(theta) - w.*sin(theta)/2; + ya1 = y2 - l.*sin(theta) + w.*cos(theta)/2; + % point on the 'right' + xa2 = x2 - l.*cos(theta) + w.*sin(theta)/2; + ya2 = y2 - l.*sin(theta) - w.*cos(theta)/2; + % point on the middle of the arrow + xa3 = x2 - l.*cos(theta).*h; + ya3 = y2 - l.*sin(theta).*h; + + % draw main edge + line([ @var{x1}'; x2'], [ @var{y1}'; y2'], 'color', [0 0 1]); + + % draw only 2 wings + ind = find(h==0); + line([xa1(ind)'; x2(ind)'], [ya1(ind)'; y2(ind)'], 'color', [0 0 1]); + line([xa2(ind)'; x2(ind)'], [ya2(ind)'; y2(ind)'], 'color', [0 0 1]); + + % draw a full arrow + ind = find(h~=0); + patch([x2(ind) xa1(ind) xa3(ind) xa2(ind) x2(ind)]', ... + [y2(ind) ya1(ind) ya3(ind) ya2(ind) y2(ind)]', [0 0 1]); + + + if nargout>0 + varargout{1}=h; + end + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/edges2d.m (from rev 8731, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/edges2d.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/edges2d.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/edges2d.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -0,0 +1,56 @@ +%% Copyright (c) 2011, INRA +%% 2008-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} edges2d () +%% Description of functions operating on planar edges +% +% An edge is represented by the corodinate of its end points: +% EDGE = [X1 Y1 X2 Y2]; +% +% A set of edges is represented by a N*4 array, each row representing an +% edge. +% +% +% @seealso{lines2d, rays2d, points2d +% createEdge, edgeAngle, edgeLength, edgeToLine, midPoint +% intersectEdges, intersectLineEdge, isPointOnEdge +% clipEdge, transformEdge +% drawEdge, drawCenteredEdge} +%% @end deftypefn +function edges2d(varargin) + + help('edges2d'); + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/lines2d.m (from rev 8731, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/lines2d.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/lines2d.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/lines2d.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -0,0 +1,66 @@ +%% 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} lines2d () +%% Description of functions operating on planar lines. +% +% The term 'line' refers to a planar straight line, which is an unbounded +% curve. Line segments defined between 2 points, which are bounded, are +% called 'edge', and are presented in file 'edges2d'. +% +% A straight line is defined by a point (its origin), and a vector (its +% direction). The different parameters are bundled into a row vector: +% LINE = [x0 y0 dx dy]; +% +% A line contains all points (x,y) such that: +% x = x0 + t*dx +% y = y0 + t*dy; +% for all t between -infinity and +infinity. +% +% @seealso{points2d, vectors2d, edges2d, rays2d +% createLine, cartesianLine, medianLine, edgeToLine +% orthogonalLine, parallelLine, bisector, radicalAxis +% lineAngle, linePosition, projPointOnLine +% isPointOnLine, distancePointLine, isLeftOriented +% intersectLines, intersectLineEdge, clipLine +% invertLine, transformLine, drawLine +% lineFit} +%% @end deftypefn + +function lines2d(varargin) + + help('lines2d'); + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/orthogonalLine.m (from rev 8731, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/orthogonalLine.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/orthogonalLine.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/orthogonalLine.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -0,0 +1,64 @@ +%% Copyright (c) 2011, INRA +%% 2003-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{perp} = } orthogonalLine (@var{line}, @var{point}) +%% Create a line orthogonal to another one. +% +% Returns the line orthogonal to the line @var{line} and going through the +% point given by @var{point}. Directed angle from @var{line} to @var{perp} is pi/2. +% @var{line} is given as [x0 y0 dx dy] and @var{point} is [xp yp]. +% +% @seealso{lines2d, parallelLine} +%% @end deftypefn + +function res = orthogonalLine(line, point) + + N = max(size(point, 1), size(line, 1)); + + if size(point, 1)>1 + res = point; + else + res = ones(N, 1)*point; + end + + if size(line, 1)>1 + res(:,3) = -line(:,4); + res(:,4) = line(:,3); + else + res(:,3) = -ones(N,1)*line(4); + res(:,4) = ones(N,1)*line(3); + end + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/parallelLine.m (from rev 8731, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/parallelLine.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/parallelLine.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/parallelLine.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -0,0 +1,64 @@ +%% Copyright (c) 2011, INRA +%% 2003-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} = } parallelLine (@var{line}, @var{point}) +%% @deftypefnx {Function File} {@var{res} = } parallelLine (@var{line}, @var{dist}) +%% Create a line parallel to another one. +%% +%% Returns the line with same direction vector than @var{line} and going through +%% the point given by @var{point}. +%% @var{line} is given as [x0 y0 dx dy] and @var{point} is [xp yp]. +%% +%% Uses relative distance to specify position. The new line will be +%% located at distance @var{dist}, counted positive in the right side of @var{line} +%% and negative in the left side. +%% +%% @seealso{lines2d, orthogonalLine, distancePointLine} +%% @end deftypefn + +function res = parallelLine(line, point) + + if size(point, 1)==1 + % use a distance. Compute position of point located at distance DIST on + % the line orthogonal to the first one. + point = pointOnLine([line(:,1) line(:,2) line(:,4) -line(:,3)], point); + end + + % normal case: compute line through a point with given direction + res = zeros(1, 4); + res(1:2) = point; + res(3:4) = line(3:4); + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/projPointOnLine.m (from rev 8731, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/projPointOnLine.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/projPointOnLine.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/projPointOnLine.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -0,0 +1,69 @@ +%% 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{point} = } projPointOnLine (@var{pt1}, @var{line}) +%% Project of a point orthogonally onto a line +%% +%% Computes the (orthogonal) projection of point @var{pt1} onto the line @var{line}. +%% +%% Function works also for multiple points and lines. In this case, it +%% returns multiple points. +%% Point @var{pt1} is a [N*2] array, and @var{line} is a [N*4] array (see createLine +%% for details). Result @var{point} is a [N*2] array, containing coordinates of +%% orthogonal projections of @var{pt1} onto lines @var{line}. +%% +%% @seealso{lines2d, points2d, isPointOnLine, linePosition} +%% @end deftypefn + +function point = projPointOnLine(point, line) + + % ensure input arguments have same size + 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 + + % slope of line + dx = line(:, 3); + dy = line(:, 4); + + % first find relative position of projection on the line, + tp = ((point(:, 2) - line(:, 2)).*dy + (point(:, 1) - line(:, 1)).*dx) ./ (dx.*dx+dy.*dy); + + % convert position on line to cartesian coordinate + point = line(:,1:2) + [tp tp].*[dx dy]; + +endfunction Deleted: trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testBisector.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testBisector.m 2011-10-18 12:34:40 UTC (rev 8779) +++ trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testBisector.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -1,49 +0,0 @@ -function test_suite = testBisector(varargin) -% One-line description here, please. -% output = testBisector(input) -% -% Example -% testBisector -% -% See also -% -% -% ------ -% Author: David Legland -% e-mail: dav...@gr... -% Created: 2009-04-22, using Matlab 7.7.0.471 (R2008b) -% Copyright 2009 INRA - Cepia Software Platform. - -initTestSuite; - -function testTwoLines - -p0 = [0 0]; -p1 = [10 0]; -p2 = [0 10]; -line1 = createLine(p0, p1); -line2 = createLine(p0, p2); - -ray = bisector(line1, line2); -assertElementsAlmostEqual([0 0], ray(1,1:2)); -assertAlmostEqual(pi/4, lineAngle(ray)); - -function testThreePoints - -p0 = [0 0]; -p1 = [10 0]; -p2 = [0 10]; - -ray = bisector(p1, p0, p2); -assertElementsAlmostEqual([0 0], ray(1,1:2)); -assertAlmostEqual(pi/4, lineAngle(ray)); - -function testThreeBundldedPoints - -p0 = [0 0]; -p1 = [10 0]; -p2 = [0 10]; - -ray = bisector([p1; p0; p2]); -assertElementsAlmostEqual([0 0], ray(1,1:2)); -assertAlmostEqual(pi/4, lineAngle(ray)); Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/Contents.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/Contents.m 2011-10-18 12:34:40 UTC (rev 8779) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/Contents.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -1,227 +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. - - -% GEOM2D Geometry 2D Toolbox -% Version 1.0 21-Mar-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 -% (ya...@gm...), available on Matlab File Exchange -% -% ----- -% Author: David Legland -% e-mail: dav...@gr... -% Created: 2005-11-07 -% Copyright INRA - Cepia Software Platform. -% Homepage: http://matgeom.sourceforge.net/ -% http://www.pfl-cepia.inra.fr/index.php?page=geom2d - -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 - - Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/bisector.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/bisector.m 2011-10-18 12:34:40 UTC (rev 8779) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/bisector.m 2011-10-18 15:24:44 UTC (rev 8780) @@ -1,98 +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 ray = bisector(varargin) -%BISECTOR Return the bisector of two lines, or 3 points -% -% RAY = bisector(LINE1, LINE2); -% create the bisector of the two lines, given as [x0 y0 dx dy]. -% -% RAY = bisector(P1, P2, P3); -% create the bisector of lines (P2 P1) and (P2 P3). -% -% The result has the form [x0 y0 dx dy], with [x0 y0] being the origin -% point ans [dx dy] being the direction vector, ... [truncated message content] |