From db834f9b73bbdfe5bdd762ffb051aa11bd492409 Mon Sep 17 00:00:00 2001 From: dlegland Date: Thu, 26 Sep 2019 10:17:21 +0200 Subject: [PATCH] various code cleanup --- CHANGELOG.md | 7 ++++--- matGeom/geom2d/crackPattern.m | 13 +++++++------ matGeom/geom2d/crackPattern2.m | 4 ++-- matGeom/geom2d/hexagonalGrid.m | 23 +++++++++++------------ matGeom/geom3d/rotation3dAxisAndAngle.m | 4 ++-- matGeom/meshes3d/cutMeshByPlane.m | 4 +++- 6 files changed, 29 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be7460ae..b5608dce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,11 @@ and finally by module. ## [Unreleased] -## MatGeom 1.2.0 - 2018-06-07 +## MatGeom 1.2.1 - 2019-09-26 -Main changes are new functions for processing 3D meshes, and renaming of -inertia ellipse/ellipsoid into equivalent ellipse/ellipsoid. +Main changes are new functions for processing 3D meshes (repairing, +simplification), and renaming of inertia ellipse/ellipsoid into equivalent +ellipse/ellipsoid. ### Added diff --git a/matGeom/geom2d/crackPattern.m b/matGeom/geom2d/crackPattern.m index b1a62845..4d288512 100644 --- a/matGeom/geom2d/crackPattern.m +++ b/matGeom/geom2d/crackPattern.m @@ -19,8 +19,10 @@ % figure; % drawEdge(E); % -% See also drawEdge +% See also +% drawEdge % + % --------- % % author : David Legland @@ -94,7 +96,7 @@ end else if abs(pos2)0 if pos2 end NL = size(lines, 1); diff --git a/matGeom/geom2d/hexagonalGrid.m b/matGeom/geom2d/hexagonalGrid.m index ad111941..d7020d5c 100644 --- a/matGeom/geom2d/hexagonalGrid.m +++ b/matGeom/geom2d/hexagonalGrid.m @@ -1,7 +1,7 @@ function varargout = hexagonalGrid(bounds, origin, size, varargin) %HEXAGONALGRID Generate hexagonal grid of points in the plane. % -% usage +% usage: % PTS = hexagonalGrid(BOUNDS, ORIGIN, SIZE) % generate points, lying in the window defined by BOUNDS (=[xmin ymin % xmax ymax]), starting from origin with a constant step equal to size. @@ -10,18 +10,18 @@ % % TODO: add possibility to use rotated grid % + % --------- % % author : David Legland % INRA - TPV URPOI - BIA IMASTE % created the 06/08/2005. % + size = size(1); dx = 3*size; dy = size*sqrt(3); - - % consider two square grids with different centers pts1 = squareGrid(bounds, origin + [0 0], [dx dy], varargin{:}); pts2 = squareGrid(bounds, origin + [dx/3 0], [dx dy], varargin{:}); @@ -32,11 +32,9 @@ pts = [pts1;pts2;pts3;pts4]; - - % eventually compute also edges, clipped by bounds % TODO : manage generation of edges -if nargout>1 +if nargout > 1 edges = zeros([0 4]); x0 = origin(1); y0 = origin(2); @@ -55,11 +53,11 @@ ny = length(ly); nx = length(lx); - if bounds(1)-x1+dx end end % process output arguments -if nargout>0 +if nargout > 0 varargout{1} = pts; - if nargout>1 + if nargout > 1 varargout{2} = edges; end end \ No newline at end of file diff --git a/matGeom/geom3d/rotation3dAxisAndAngle.m b/matGeom/geom3d/rotation3dAxisAndAngle.m index b77ea0c0..ca89c6e6 100644 --- a/matGeom/geom3d/rotation3dAxisAndAngle.m +++ b/matGeom/geom3d/rotation3dAxisAndAngle.m @@ -1,5 +1,5 @@ function [axis, theta] = rotation3dAxisAndAngle(mat) -%ROTATION3DAXISANDANGLE Determine axis and angle of a 3D rotation matrix. +%ROTATION3DAXISANDANGLE Determine axis and angle of a 3D rotation matrix. % % [AXIS, ANGLE] = rotation3dAxisAndAngle(MAT) % Where MAT is a 4-by-4 matrix representing a rotation, computes the @@ -58,7 +58,7 @@ % try to get a point on the line % seems to work, but not sure about stability -[V, D] = eig(mat-eye(4)); %#ok +[V, D] = eig(mat-eye(4)); %#ok origin = V(1:3,4)'/V(4, 4); % create line corresponding to rotation axis diff --git a/matGeom/meshes3d/cutMeshByPlane.m b/matGeom/meshes3d/cutMeshByPlane.m index 08ffd74b..54663b1f 100644 --- a/matGeom/meshes3d/cutMeshByPlane.m +++ b/matGeom/meshes3d/cutMeshByPlane.m @@ -1,5 +1,6 @@ function varargout = cutMeshByPlane(v, f, plane, varargin) %CUTMESHBYPLANE Cut a mesh by a plane. +% % [ABOVE, IN, BELOW] = cutMeshByPlane(MESH, PLANE) % where MESH, ABOVE, IN, BELOW are structs with the fields vertices and % faces, and PLANE is given as a row containing initial point and 2 @@ -20,6 +21,7 @@ % [BELOW_V, BELOW_F] = cutMeshByPlane(MESH, PLANE, 'part', 'below') is % possible, too. % + % --------- % Authors: oqilipo, David Legland % Created: 2017-07-09 @@ -33,7 +35,7 @@ % If first argument is a struct if nargin == 2 || nargin == 4 if ~isempty(varargin) - varargin={plane, varargin{:}}; + varargin = [{plane}, varargin(:)']; end plane = f; [v, f] = parseMeshData(v);