Home > matGeom > geom2d > triangleGrid.m

triangleGrid

PURPOSE ^

TRIANGLEGRID Generate triangular grid of points in the plane.

SYNOPSIS ^

function varargout = triangleGrid(bounds, origin, size, varargin)

DESCRIPTION ^

TRIANGLEGRID Generate triangular grid of points in the plane.

   usage
   PTS = triangleGrid(BOUNDS, ORIGIN, SIZE)
   generate points, lying in the window defined by BOUNDS, given in form
   [xmin ymin xmax ymax], starting from origin with a constant step equal
   to size. 
   SIZE is constant and is equals to the length of the sides of each
   triangles. 

   TODO: add possibility to use rotated grid

   ---------

   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 06/08/2005.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = triangleGrid(bounds, origin, size, varargin)
0002 %TRIANGLEGRID Generate triangular grid of points in the plane.
0003 %
0004 %   usage
0005 %   PTS = triangleGrid(BOUNDS, ORIGIN, SIZE)
0006 %   generate points, lying in the window defined by BOUNDS, given in form
0007 %   [xmin ymin xmax ymax], starting from origin with a constant step equal
0008 %   to size.
0009 %   SIZE is constant and is equals to the length of the sides of each
0010 %   triangles.
0011 %
0012 %   TODO: add possibility to use rotated grid
0013 %
0014 %   ---------
0015 %
0016 %   author : David Legland
0017 %   INRA - TPV URPOI - BIA IMASTE
0018 %   created the 06/08/2005.
0019 %
0020 
0021 dx = size(1);
0022 dy = size(1)*sqrt(3);
0023 
0024 % consider two square grids with different centers
0025 pts1 = squareGrid(bounds, origin, [dx dy], varargin{:});
0026 pts2 = squareGrid(bounds, origin + [dx dy]/2, [dx dy], varargin{:});
0027 
0028 % gather points
0029 pts = [pts1;pts2];
0030 
0031 
0032 % process output
0033 if nargout>0
0034     varargout{1} = pts;
0035 end

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019