From: <jpi...@us...> - 2011-10-09 16:20:54
|
Revision: 8717 http://octave.svn.sourceforge.net/octave/?rev=8717&view=rev Author: jpicarbajal Date: 2011-10-09 16:20:45 +0000 (Sun, 09 Oct 2011) Log Message: ----------- geometry. Adding transforms Modified Paths: -------------- trunk/octave-forge/main/geometry/DESCRIPTION trunk/octave-forge/main/geometry/INDEX trunk/octave-forge/main/geometry/doc/NEWS trunk/octave-forge/main/geometry/geom2d/inst/angleDiff.m trunk/octave-forge/main/geometry/geom2d/inst/angleSort.m trunk/octave-forge/main/geometry/geom2d/inst/angles2d.m trunk/octave-forge/main/geometry/geom2d/inst/createLine.m trunk/octave-forge/main/geometry/geom2d/inst/deg2rad.m trunk/octave-forge/main/geometry/geom2d/inst/drawEdge.m trunk/octave-forge/main/geometry/geom2d/inst/edgeAngle.m trunk/octave-forge/main/geometry/geom2d/inst/lineAngle.m trunk/octave-forge/main/geometry/geom2d/inst/normalizeAngle.m trunk/octave-forge/main/geometry/geom2d/inst/rad2deg.m trunk/octave-forge/main/geometry/geom2d/inst/vectorAngle.m trunk/octave-forge/main/geometry/geom2d/inst/vectorNorm.m trunk/octave-forge/main/geometry/geom2d/inst/vectors2d.m trunk/octave-forge/main/geometry/inst/data2geo.m Added Paths: ----------- trunk/octave-forge/main/geometry/geom2d/inst/createBasisTransform.m trunk/octave-forge/main/geometry/geom2d/inst/createHomothecy.m trunk/octave-forge/main/geometry/geom2d/inst/createLineReflection.m trunk/octave-forge/main/geometry/geom2d/inst/createRotation.m trunk/octave-forge/main/geometry/geom2d/inst/createScaling.m trunk/octave-forge/main/geometry/geom2d/inst/createTranslation.m trunk/octave-forge/main/geometry/geom2d/inst/transformPoint.m trunk/octave-forge/main/geometry/geom2d/inst/transforms2d.m Removed Paths: ------------- trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateRotation.m trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateScaling.m trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateTranslation.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createBasisTransform.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createHomothecy.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createLineReflection.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createRotation.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createScaling.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createTranslation.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/transformPoint.m trunk/octave-forge/main/geometry/matGeom_raw/geom2d/transforms2d.m Modified: trunk/octave-forge/main/geometry/DESCRIPTION =================================================================== --- trunk/octave-forge/main/geometry/DESCRIPTION 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/DESCRIPTION 2011-10-09 16:20:45 UTC (rev 8717) @@ -1,6 +1,6 @@ Name: Geometry -Version: 1.1.2 -Date: 2011-10-06 +Version: 1.1.3 +Date: 2011-10-10 Author: David Legland <dav...@gr...>, Juan Pablo Carbajal <car...@if...> Maintainer: Juan Pablo Carbajal <car...@if...> Title: Computational Geometry Modified: trunk/octave-forge/main/geometry/INDEX =================================================================== --- trunk/octave-forge/main/geometry/INDEX 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/INDEX 2011-10-09 16:20:45 UTC (rev 8717) @@ -23,15 +23,22 @@ edgeAngle intersectBoxes intersectLines + isParallel + isPerpendicular isPointOnRay lineAngle linePosition mergeBoxes normalizeAngle + normalizeVector rad2deg randomPointInBox rays2d + rotateVector + transformVector vectorAngle + vectorNorm + vectors2d Input svgload svgnormalize @@ -41,3 +48,5 @@ Geometry 3D Graphs + + Modified: trunk/octave-forge/main/geometry/doc/NEWS =================================================================== --- trunk/octave-forge/main/geometry/doc/NEWS 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/doc/NEWS 2011-10-09 16:20:45 UTC (rev 8717) @@ -52,18 +52,21 @@ drawLine.m =============================================================================== -geometry-1.1.2 Release Date: 2011-10-xx Release Manager: Juan Pablo Carbajal +geometry-1.1.2 Release Date: 2011-10-09 Release Manager: Juan Pablo Carbajal =============================================================================== * Continue to add geom2d from matGeom (rays and vectors) - createRay - drawRay - isPointOnRay - drawEdge - rays2d - vectors2d - vectorNorm - isParallel - isPerpendicular - + createRay.m + drawEdge.m + drawRay.m + isParallel.m + isPerpendicular.m + isPointOnRay.m + normalizeVector.m + rays2d.m + rotateVector.m + transformVector.m + vectorNorm.m + vectors2d.m + =============================================================================== Modified: trunk/octave-forge/main/geometry/geom2d/inst/angleDiff.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/angleDiff.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/angleDiff.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{dif} =} angleDiff (@var{angle1}, @var{angle2}) -%% ANGLEDIFF Difference between two angles +%% Difference between two angles %% %% Computes the signed angular difference between two angles in radians. %% The result is comprised between -PI and +PI. Modified: trunk/octave-forge/main/geometry/geom2d/inst/angleSort.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/angleSort.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/angleSort.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {varargout =} angleSort (@var{pts}, varargin) -%% ANGLESORT Sort points in the plane according to their angle to origin +%% Sort points in the plane according to their angle to origin %% %% %% PTS2 = angleSort(PTS); Modified: trunk/octave-forge/main/geometry/geom2d/inst/angles2d.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/angles2d.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/angles2d.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} angles2d () -%% ANGLES2D Description of functions for manipulating angles +%% Description of functions for manipulating angles %% %% Angles are normalized in an interval of width 2*PI. Most geom2d %% functions return results in the [0 2*pi] interval, but it can be Copied: trunk/octave-forge/main/geometry/geom2d/inst/createBasisTransform.m (from rev 8716, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createBasisTransform.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/createBasisTransform.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/createBasisTransform.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -0,0 +1,108 @@ +%% 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 @var{source} and binary forms, with or without +%% modification, are permitted provided that the following conditions are met: +%% +%% 1. Redistributions of @var{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{T} = } createBasisTransfrom (@var{@var{target}}) +%% @deftypefnx {Function File} {@var{T} = } createBasisTransfrom (@var{@var{source}}, @var{@var{target}}) +%% Compute matrix for transforming a basis into another basis +%% +%% With only one input arguemnt, assumes the @var{source} is the standard (Oij) basis, with origin at (0,0), +%% first direction vector equal to (1,0) and second direction vector +%% equal to (0,1). Otherwise @var{@var{source}} specifies the @var{source} basis. +%% +%% Both @var{source} and @var{target} represent basis, in the following form: +%% [x0 y0 ex1 ey1 ex2 ey2] +%% [y0 y0] is the origin of the basis, [ex1 ey1] is the first direction +%% vector, and [ex2 ey2] is the second direction vector. +%% +%% The result @var{T} is a 3-by-3 matrix such that a point expressed with +%% coordinates of the first basis will be represented by new coordinates +%% @code{P2 = transformPoint(P1, @var{T})} in the @var{target} basis. +%% +%% Example +%% @example +%% % standard basis transform +%% src = [0 0 1 0 0 1]; +%% % @var{target} transform, just a rotation by atan(2/3) followed by a scaling +%% tgt = [0 0 .75 .5 -.5 .75]; +%% % compute transform +%% trans = createBasisTransform(src, tgt); +%% % transform the point (.25,1.25) into the point (1,1) +%% p1 = [.25 1.25]; +%% p2 = transformPoint(p1, trans) +%% ans = +%% 1 1 +%% @end example +%% +%% @seealso{transforms2d} +%% @end deftypefn + +function transfo = createBasisTransform(source, target) + + % init basis transform to identity + t1 = eye(3); + t2 = eye(3); + + if nargin==2 + % from source to reference basis + t1(1:2, 1) = source(3:4); + t1(1:2, 2) = source(5:6); + t1(1:2, 3) = source(1:2); + else + % if only one input, use first input as target basis, and leave the + % first matrix to identity + target = source; + end + + % from reference to target basis + t2(1:2, 1) = target(3:4); + t2(1:2, 2) = target(5:6); + t2(1:2, 3) = target(1:2); + + % compute transfo + % same as: transfo = inv(t2)*t1; + transfo = t2\t1; + +endfunction + +%!demo +%! % standard basis transform +%! src = [0 0 1 0 0 1]; +%! % target transform, just a rotation by atan(2/3) followed by a scaling +%! tgt = [0 0 .75 .5 -.5 .75]; +%! % compute transform +%! trans = createBasisTransform(src, tgt); +%! % transform the point (.25,1.25) into the point (1,1) +%! p1 = [.25 1.25]; +%! p2 = transformPoint(p1, trans) + Copied: trunk/octave-forge/main/geometry/geom2d/inst/createHomothecy.m (from rev 8716, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createHomothecy.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/createHomothecy.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/createHomothecy.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -0,0 +1,61 @@ +%% Copyright (c) 2011, INRA +%% 2009-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{T} = } createHomothecy (@var{point}, @var{ratio}) +%% Create the the 3x3 matrix of an homothetic transform. +% +% @var{point} is the center of the homothecy, @var{ratio} is its factor. +% +% @seealso{transforms2d, transformPoint, createTranslation} +%% @end deftypefn + +function trans = createHomothecy(point, ratio) + + % extract coordinate of center + x0 = point(:,1); + y0 = point(:,2); + + % compute coefficients of the matrix + m00 = ratio; + m01 = 0; + m02 = x0*(1-ratio); + m10 = 0; + m11 = ratio; + m12 = y0*(1-ratio); + + % create transformation + trans = [m00 m01 m02; m10 m11 m12; 0 0 1]; + +endfunction + Modified: trunk/octave-forge/main/geometry/geom2d/inst/createLine.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/createLine.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/createLine.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{line} =} createLine(varargin) -%% CREATELINE Create a straight line from 2 points, or from other inputs +%% Create a straight line from 2 points, or from other inputs %% %% Line is represented in a parametric form : [x0 y0 dx dy] %% x = x0 + t*dx Copied: trunk/octave-forge/main/geometry/geom2d/inst/createLineReflection.m (from rev 8716, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createLineReflection.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/createLineReflection.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/createLineReflection.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -0,0 +1,68 @@ +%% Copyright (c) 2011, INRA +%% 2009-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{T} = } function_name (@var{line}) +%% Create the the 3x3 matrix of a line reflection. +%% +%% Where @var{line} is given as [x0 y0 dx dy], return the affine tansform +%% corresponding to the desired line reflection. +%% +%% @seealso{lines2d, transforms2d, transformPoint, +%% createTranslation, createHomothecy, createScaling} +%% @end deftypefn + +function trans = createLineReflection(line) + + % extract line parameters + x0 = line(:,1); + y0 = line(:,2); + dx = line(:,3); + dy = line(:,4); + + % normalisation coefficient of line direction vector + delta = dx*dx + dy*dy; + + % compute coefficients of transform + m00 = (dx*dx - dy*dy)/delta; + m01 = 2*dx*dy/delta; + m02 = 2*dy*(dy*x0 - dx*y0)/delta; + m10 = 2*dx*dy/delta; + m11 = (dy*dy - dx*dx)/delta; + m12 = 2*dx*(dx*y0 - dy*x0)/delta; + + % create transformation + trans = [m00 m01 m02; m10 m11 m12; 0 0 1]; + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/createRotation.m (from rev 8716, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createRotation.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/createRotation.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/createRotation.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -0,0 +1,112 @@ +%% 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{T} = } createRotation (@var{theta}) +%% @deftypefnx {Function File} {@var{T} = } createRotation (@var{point}, @var{theta}) +%% @deftypefnx {Function File} {@var{T} = } createRotation (@var{x0}, @var{y0}, @var{theta}) +%% Create the 3*3 matrix of a rotation. +%% +%% Returns the rotation corresponding to angle @var{theta} (in radians) +%% The returned matrix has the form : +%% [cos(theta) -sin(theta) 0] +%% [sin(theta) cos(theta) 0] +%% [0 0 1] +%% +%% @var{point} or (@var{x0},@var{y0}), specifies origin of rotation. The result is similar as performing +%% translation(-@var{x0},-@var{y0}), rotation(@var{theta}), and translation(@var{x0},@var{y0}). +%% +%% +%% @seealso{transforms2d, transformPoint, createTranslation, createScaling} +%% @end deftypefn + +function trans = createRotation(varargin) + + % default values + cx = 0; + cy = 0; + theta = 0; + + % get input values + if length(varargin)==1 + % only angle + theta = varargin{1}; + elseif length(varargin)==2 + % origin point (as array) and angle + var = varargin{1}; + cx = var(1); + cy = var(2); + theta = varargin{2}; + elseif length(varargin)==3 + % origin (x and y) and angle + cx = varargin{1}; + cy = varargin{2}; + theta = varargin{3}; + end + + % compute coefs + cot = cos(theta); + sit = sin(theta); + tx = cy*sit - cx*cot + cx; + ty = -cy*cot - cx*sit + cy; + + % create transformation matrix + trans = [cot -sit tx; sit cot ty; 0 0 1]; + +endfunction + +%!test +%! trans = createRotation(0); +%! assert (trans, [1 0 0;0 1 0;0 0 1], 1e-6); + +%!test +%! trans = createRotation(pi/2); +%! assert (trans, [0 -1 0; 1 0 0; 0 0 1], 1e-6); + +%!test +%! trans = createRotation(pi); +%! assert (trans, [-1 0 0;0 -1 0;0 0 1], 1e-6); + +%!test +%! trans = createRotation(3*pi/2); +%! assert (trans, [0 1 0; -1 0 0; 0 0 1], 1e-6); + +%!test +%! p0 = [3 5]; +%! theta = pi/3; +%! trans1 = createRotation(p0, theta); +%! t1 = createTranslation(-p0); +%! rot = createRotation(theta); +%! t2 = createTranslation(p0); +%! trans2 = t2*rot*t1; +%! assert (trans1, trans2, 1e-6); Copied: trunk/octave-forge/main/geometry/geom2d/inst/createScaling.m (from rev 8716, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createScaling.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/createScaling.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/createScaling.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -0,0 +1,106 @@ +%% 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{T} = } createScaling (@var{s}) +%% @deftypefnx {Function File} {@var{T} = } createScaling (@var{sx}, @var{sy}) +%% Create the 3x3 matrix of a scaling in 2 dimensions. +% +% Assume scaling @var{s} is equal n all directions unless @var{sx} and @var{sy} are given. +% Returns the matrix corresponding to scaling in the 2 main directions. +% The returned matrix has the form: +% [SX 0 0] +% [0 SY 0] +% [0 0 1] +% +% @seealso{transforms2d, transformPoint, createTranslation, createRotation} +%% @end deftypefn + +function trans = createScaling(varargin) + + % defined default arguments + sx = 1; + sy = 1; + cx = 0; + cy = 0; + + % process input arguments + if length(varargin)==1 + % the argument is either the scaling factor in both direction, + % or a 1x2 array containing scaling factor in each direction + var = varargin{1}; + sx = var(1); + sy = var(1); + if length(var)>1 + sy = var(2); + end + elseif length(varargin)==2 + % the 2 arguments are the scaling factors in each dimension + sx = varargin{1}; + sy = varargin{2}; + elseif length(varargin)==3 + % first argument is center, 2nd and 3d are scaling factors + center = varargin{1}; + cx = center(1); + cy = center(2); + sx = varargin{2}; + sy = varargin{3}; + end + + % create result matrix + trans = [sx 0 cx*(1-sx); 0 sy cy*(1-sy); 0 0 1]; + +endfunction + +%!test +%! trans = createScaling(2); +%! assert (trans, [2 0 0;0 2 0;0 0 1], 1e-6); + +%!test +%! trans = createScaling(2, 3); +%! assert (trans, [2 0 0;0 3 0;0 0 1], 1e-6); + +%!test +%! trans = createScaling([2 3]); +%! assert (trans, [2 0 0;0 3 0;0 0 1], 1e-6); + +%!test +%! sx = 2; +%! sy = 3; +%! p0 = [4 5]; +%! trans1 = createScaling(p0, sx, sy); +%! t1 = createTranslation(-p0); +%! sca = createScaling(sx, sy); +%! t2 = createTranslation(p0); +%! trans2 = t2*sca*t1; +%! assert (trans1, trans2, 1e-6); Copied: trunk/octave-forge/main/geometry/geom2d/inst/createTranslation.m (from rev 8716, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createTranslation.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/createTranslation.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/createTranslation.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -0,0 +1,71 @@ +%% 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{T} = } createTranslation (@var{vector}) +%% @deftypefnx {Function File} {@var{T} = } createTranslation (@var{dx},@var{dy}) +%% Create the 3*3 matrix of a translation. +%% +%% Returns the matrix corresponding to a translation by the vector [@var{dx} @var{dy}]. +%% The components can be given as two arguments. +%% The returned matrix has the form : +%% [1 0 TX] +%% [0 1 TY] +%% [0 0 1] +%% +%% @seealso{transforms2d, transformPoint, createRotation, createScaling} +%% @end deftypefn + +function trans = createTranslation(varargin) + + % process input arguments + if isempty(varargin) + tx = 0; + ty = 0; + elseif length(varargin)==1 + var = varargin{1}; + tx = var(1); + ty = var(2); + else + tx = varargin{1}; + ty = varargin{2}; + end + + % create the matrix representing the translation + trans = [1 0 tx ; 0 1 ty ; 0 0 1]; + +endfunction + +%!test +%! trans = createTranslation(2, 3); +%! assert (trans, [1 0 2;0 1 3;0 0 1], 1e-6); Modified: trunk/octave-forge/main/geometry/geom2d/inst/deg2rad.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/deg2rad.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/deg2rad.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{rad} =} deg2rad(@var{deg}) -%% DEG2RAD Convert angle from degrees to radians +%% Convert angle from degrees to radians %% %% Usage: %% R = deg2rad(D) Modified: trunk/octave-forge/main/geometry/geom2d/inst/drawEdge.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/drawEdge.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/drawEdge.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -38,7 +38,7 @@ %% @deftypefnx {Function File} {@var{h} = } drawEdge (@var{x1}, @var{y1}, @var{z1}, @var{x2}, @var{y2}, @var{z2}) %% @deftypefnx {Function File} {@var{h} = } drawEdge ([@var{x1} @var{y1} @var{z1} @var{x2} @var{y2} @var{z2}]) %% @deftypefnx {Function File} {@var{h} = } drawEdge ([@var{x1} @var{y1} @var{z1}], [@var{x2} @var{y2} @var{z2}]) -%% @deftypefnx {Function File} {@var{h} = } drawEdge (@dots, @var{opt}) +%% @deftypefnx {Function File} {@var{h} = } drawEdge (@dots{}, @var{opt}) %% Draw an edge given by 2 points. %% %% Draw an edge between the points (x1 y1) and (x2 y2). Data can be bundled as an edge. Modified: trunk/octave-forge/main/geometry/geom2d/inst/edgeAngle.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/edgeAngle.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/edgeAngle.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{theta} =} edgeAngle(@var{edge}) -%% EDGEANGLE Return angle of edge +%% Return angle of edge %% %% A = edgeAngle(EDGE) %% Returns the angle between horizontal, right-axis and the edge EDGE. Modified: trunk/octave-forge/main/geometry/geom2d/inst/lineAngle.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/lineAngle.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/lineAngle.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{theta} =} lineAngle(varargin) -%% LINEANGLE Computes angle between two straight lines +%% Computes angle between two straight lines %% %% A = lineAngle(LINE); %% Returns the angle between horizontal, right-axis and the given line. Modified: trunk/octave-forge/main/geometry/geom2d/inst/normalizeAngle.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/normalizeAngle.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/normalizeAngle.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -34,7 +34,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{alpha2} =} normalizeAngle (@var{alpha}) %% @deftypefnx {Function File} {@var{alpha2} =} normalizeAngle (@var{alpha}, @var{center}) -%% NORMALIZEANGLE Normalize an angle value within a 2*PI interval +%% Normalize an angle value within a 2*PI interval %% %% ALPHA2 = normalizeAngle(ALPHA); %% ALPHA2 is the same as ALPHA modulo 2*PI and is positive. Modified: trunk/octave-forge/main/geometry/geom2d/inst/rad2deg.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/rad2deg.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/rad2deg.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{deg} =} rad2deg(@var{rad}) -% RAD2DEG Convert angle from radians to degrees +% Convert angle from radians to degrees % % Usage: % R = rad2deg(D) Copied: trunk/octave-forge/main/geometry/geom2d/inst/transformPoint.m (from rev 8716, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/transformPoint.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/transformPoint.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/transformPoint.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -0,0 +1,92 @@ +%% 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{pt2} = } transformPoint (@var{pt1}, @var{Trans}) +%% @deftypefnx {Function File} {[@var{px2} @var{py2}]= } transformPoint (@var{px1}, @var{py1}, @var{Trans}) +%% Transform a point with an affine transform. +%% +%% where @var{pt1} has the form [xp yp], and @var{Trans} is a [2x2], [2x3] or [3x3] +%% matrix, returns the point transformed with affine transform @var{Trans}. +%% +%% Format of @var{Trans} can be one of : +%% [a b] , [a b c] , or [a b c] +%% [d e] [d e f] [d e f] +%% [0 0 1] +%% +%% Also works when @var{pt1} is a [Nx2] array of double. In this case, @var{pt2} has +%% the same size as @var{pt1}. +%% +%% Also works when @var{px1} and @var{py1} are arrays the same size. The function +%% transform each couple of (@var{px1}, @var{py1}), and return the result in +%% (@var{px2}, @var{py2}), which is the same size as (@var{px1} @var{py1}). +%% +%% @seealso{points2d, transforms2d, createTranslation, createRotation} +%% @end deftypefn + +function varargout = transformPoint(varargin) + + if length(varargin)==2 + var = varargin{1}; + px = var(:,1); + py = var(:,2); + trans = varargin{2}; + elseif length(varargin)==3 + px = varargin{1}; + py = varargin{2}; + trans = varargin{3}; + else + error('wrong number of arguments in "transformPoint"'); + end + + + % compute position + px2 = px*trans(1,1) + py*trans(1,2); + py2 = px*trans(2,1) + py*trans(2,2); + + % add translation vector, if exist + if size(trans, 2)>2 + px2 = px2 + trans(1,3); + py2 = py2 + trans(2,3); + end + + + if nargout==0 || nargout==1 + varargout{1} = [px2 py2]; + elseif nargout==2 + varargout{1} = px2; + varargout{2} = py2; + end + +endfunction + Copied: trunk/octave-forge/main/geometry/geom2d/inst/transforms2d.m (from rev 8716, trunk/octave-forge/main/geometry/matGeom_raw/geom2d/transforms2d.m) =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/transforms2d.m (rev 0) +++ trunk/octave-forge/main/geometry/geom2d/inst/transforms2d.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -0,0 +1,63 @@ +%% 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} transforms2d () +%% Description of functions operating on transforms +%% +%% By 'transform' we mean an affine transform. A planar affine transform +%% can be represented by a 3x3 matrix. +%% +%% Example +%% +%% @example +%% % create a translation by the vector [10 20]: +%% T = createTranslation([10 20]) +%% T = +%% 1 0 10 +%% 0 1 20 +%% 0 0 1 +%%@end example +%% +%% @seealso{createTranslation, createRotation, createScaling, createBasisTransform, +%% createHomothecy, createLineReflection, fitAffineTransform2d, +%% transformPoint, transformVector, transformLine, transformEdge, +%% rotateVector} +%% @end deftypefn + +function transforms2d(varargin) + + help('transforms2d'); + +endfunction + Modified: trunk/octave-forge/main/geometry/geom2d/inst/vectorAngle.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/vectorAngle.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/vectorAngle.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -33,7 +33,7 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{alpha} =} vectorAngle (@var{v1}) -%% VECTORANGLE Angle of a vector, or between 2 vectors +%% Angle of a vector, or between 2 vectors %% %% A = vectorAngle(V); %% Returns angle between Ox axis and vector direction, in Counter Modified: trunk/octave-forge/main/geometry/geom2d/inst/vectorNorm.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/vectorNorm.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/vectorNorm.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -39,7 +39,7 @@ %% Without extra arguments, returns the euclidean norm of vector V. %% Optional argument @var{n} specifies the norm to use. N can be any value %% greater than 0. -%% @table +%% @table @samp %% @item N=1 %% City lock norm. %% @item N=2 Modified: trunk/octave-forge/main/geometry/geom2d/inst/vectors2d.m =================================================================== --- trunk/octave-forge/main/geometry/geom2d/inst/vectors2d.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/geom2d/inst/vectors2d.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -41,7 +41,7 @@ %% %% Several vectors are stored in a matrix with two columns, one for the %% x-coordinate, one for the y-coordinate. -%% @voce{VS = [vx1 vy1 ; vx2 vy2 ; vx3 vy3];} +%% @code{VS = [vx1 vy1 ; vx2 vy2 ; vx3 vy3];} %% %% @seealso{vectorNorm, vectorAngle, isPerpendicular, isParallel, %% normalizeVector, transformVector, rotateVector} Modified: trunk/octave-forge/main/geometry/inst/data2geo.m =================================================================== --- trunk/octave-forge/main/geometry/inst/data2geo.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/inst/data2geo.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -15,8 +15,11 @@ %% -*- texinfo -*- %% @deftypefn {Function File} {@var{fileStr} =} data2geo (@var{data}, @var{lc},@var{opt}) -%% Takes data assuming certain order and builds a .geo file compatible with gmsh. +%% Builds a file compatible with gmsh form data. %% +%% @var{data} is assumed to describe a polygon in @code{polygon2d} format. +%% +%% @seealso{polygon2d} %% @end deftypefn function strFile = data2geo(data,lc,varargin) Deleted: trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateRotation.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateRotation.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateRotation.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -1,45 +0,0 @@ -function test_suite = testCreateRotation -%TESTCREATEROTATION One-line description here, please. -% output = testCreateRotation(input) -% -% Example -% testCreateRotation -% -% 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. -% Licensed under the terms of the LGPL, see the file "license.txt" - -initTestSuite; - -function testCreateCentered - -trans = createRotation(0); -assertElementsAlmostEqual(trans, [1 0 0;0 1 0;0 0 1]); - -trans = createRotation(pi/2); -assertElementsAlmostEqual(trans, [0 -1 0; 1 0 0; 0 0 1]); - -trans = createRotation(pi); -assertElementsAlmostEqual(trans, [-1 0 0;0 -1 0;0 0 1]); - -trans = createRotation(3*pi/2); -assertElementsAlmostEqual(trans, [0 1 0; -1 0 0; 0 0 1]); - -function testCreateShifted - -p0 = [3 5]; -theta = pi/3; - -trans1 = createRotation(p0, theta); -t1 = createTranslation(-p0); -rot = createRotation(theta); -t2 = createTranslation(p0); -trans2 = t2*rot*t1; - -assertElementsAlmostEqual(trans1, trans2); Deleted: trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateScaling.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateScaling.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateScaling.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -1,46 +0,0 @@ -function test_suite = testCreateScaling(varargin) -%TESTCREATESCALING One-line description here, please. -% output = testCreateScaling(input) -% -% Example -% testCreateScaling -% -% 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. -% Licensed under the terms of the LGPL, see the file "license.txt" - -initTestSuite; - -function testCentered - -% same coeff for both x and y -trans = createScaling(2); -assertElementsAlmostEqual(trans, [2 0 0;0 2 0;0 0 1]); - -% different factor -trans = createScaling(2, 3); -assertElementsAlmostEqual(trans, [2 0 0;0 3 0;0 0 1]); - -% different factor -trans = createScaling([2 3]); -assertElementsAlmostEqual(trans, [2 0 0;0 3 0;0 0 1]); - -function testShifted - -sx = 2; -sy = 3; -p0 = [4 5]; - -trans1 = createScaling(p0, sx, sy); -t1 = createTranslation(-p0); -sca = createScaling(sx, sy); -t2 = createTranslation(p0); -trans2 = t2*sca*t1; - -assertElementsAlmostEqual(trans1, trans2); Deleted: trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateTranslation.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateTranslation.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/matGeom_raw/Tests/geom2d/testCreateTranslation.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -1,23 +0,0 @@ -function test_suite = testCreateTranslation(varargin) -%TESTCREATETRANSLATION One-line description here, please. -% output = testCreateTranslation(input) -% -% Example -% testCreateTranslation -% -% 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. -% Licensed under the terms of the LGPL, see the file "license.txt" - -initTestSuite; - -function testBasic - -trans = createTranslation(2, 3); -assertElementsAlmostEqual(trans, [1 0 2;0 1 3;0 0 1]); Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createBasisTransform.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createBasisTransform.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createBasisTransform.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -1,99 +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 transfo = createBasisTransform(source, target) -%CREATEBASISTRANSFORM Compute matrix for transforming a basis into another basis -% -% TRANSFO = createBasisTransform(SOURCE, TARGET) -% Both SOURCE and TARGET represent basis, in the following form: -% [x0 y0 ex1 ey1 ex2 ey2] -% [y0 y0] is the origin of the basis, [ex1 ey1] is the first direction -% vector, and [ex2 ey2] is the second direction vector. -% -% The result TRANSFO is a 3-by-3 matrix such that a point expressed with -% coordinates of the first basis will be represented by new coordinates -% P2 = transformPoint(P1, TRANSFO) in the target basis. -% -% TRANSFO = createBasisTransform(TARGET) -% Assumes the source is the standard (Oij) basis, with origin at (0,0), -% first direction vector equal to (1,0) and second direction vector -% equal to (0,1). -% -% -% Example -% % standard basis transform -% src = [0 0 1 0 0 1]; -% % target transform, just a rotation by atan(2/3) followed by a scaling -% tgt = [0 0 .75 .5 -.5 .75]; -% % compute transform -% trans = createBasisTransform(src, tgt); -% % transform the point (.25,1.25) into the point (1,1) -% p1 = [.25 1.25]; -% p2 = transformPoint(p1, trans) -% ans = -% 1 1 -% -% See also -% transforms2d -% -% ------ -% Author: David Legland -% e-mail: dav...@gr... -% Created: 2010-12-03, using Matlab 7.9.0.529 (R2009b) -% Copyright 2010 INRA - Cepia Software Platform. - -% init basis transform to identity -t1 = eye(3); -t2 = eye(3); - -if nargin==2 - % from source to reference basis - t1(1:2, 1) = source(3:4); - t1(1:2, 2) = source(5:6); - t1(1:2, 3) = source(1:2); -else - % if only one input, use first input as target basis, and leave the - % first matrix to identity - target = source; -end - -% from reference to target basis -t2(1:2, 1) = target(3:4); -t2(1:2, 2) = target(5:6); -t2(1:2, 3) = target(1:2); - -% compute transfo -% same as: transfo = inv(t2)*t1; -transfo = t2\t1; - Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createHomothecy.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createHomothecy.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createHomothecy.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -1,66 +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 trans = createHomothecy(point, ratio) -%CREATEHOMOTHECY Create the the 3x3 matrix of an homothetic transform -% -% TRANS = createHomothecy(POINT, K); -% POINT is the center of the homothecy, K is its factor. -% -% See also: -% transforms2d, transformPoint, createTranslation -% -% --------- -% author : David Legland -% INRA - TPV URPOI - BIA IMASTE -% created the 20/01/2005. -% - -% HISTORY -% 22/04/2009: rename as createHomothecy - -% extract coordinate of center -x0 = point(:,1); -y0 = point(:,2); - -% compute coefficients of the matrix -m00 = ratio; -m01 = 0; -m02 = x0*(1-ratio); -m10 = 0; -m11 = ratio; -m12 = y0*(1-ratio); - -% create transformation -trans = [m00 m01 m02; m10 m11 m12; 0 0 1]; Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createLineReflection.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createLineReflection.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createLineReflection.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -1,74 +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 trans = createLineReflection(line) -%CREATELINEREFLECTION Create the the 3x3 matrix of a line reflection -% -% TRANS = createLineReflection(LINE); -% where line is given as [x0 y0 dx dy], return the affine tansform -% corresponding to the desired line reflection -% -% -% See also: -% lines2d, transforms2d, transformPoint, -% createTranslation, createHomothecy, createScaling -% -% --------- -% author : David Legland -% INRA - TPV URPOI - BIA IMASTE -% created the 19/01/2005. -% - -% HISTORY -% 22/04/2009: rename as createLineReflection - -% extract line parameters -x0 = line(:,1); -y0 = line(:,2); -dx = line(:,3); -dy = line(:,4); - -% normalisation coefficient of line direction vector -delta = dx*dx + dy*dy; - -% compute coefficients of transform -m00 = (dx*dx - dy*dy)/delta; -m01 = 2*dx*dy/delta; -m02 = 2*dy*(dy*x0 - dx*y0)/delta; -m10 = 2*dx*dy/delta; -m11 = (dy*dy - dx*dx)/delta; -m12 = 2*dx*(dx*y0 - dy*x0)/delta; - -% create transformation -trans = [m00 m01 m02; m10 m11 m12; 0 0 1]; Deleted: trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createRotation.m =================================================================== --- trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createRotation.m 2011-10-09 03:12:31 UTC (rev 8716) +++ trunk/octave-forge/main/geometry/matGeom_raw/geom2d/createRotation.m 2011-10-09 16:20:45 UTC (rev 8717) @@ -1,92 +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 ... [truncated message content] |