triangle_grid


triangle_grid, an Octave code which generates a grid of points over the interior of a triangle in 2D.

Starting with any 3 points A, B, and C that define a triangle, we can divide each side of the triangle into N subintervals, and create a triangular grid. This defines ((N+1)*(N+2))/2 points that lie on the intersections of grid lines. The arrangement is suggested by this diagram:

              X
             9 X
            8 9 X
           7 8 9 X
          6 7 8 9 X
         5 6 7 8 9 X
        4 5 6 7 8 9 X
       3 4 5 6 7 8 9 X
      2 3 4 5 6 7 8 9 X
     1 2 3 4 5 6 7 8 9 X
    0 1 2 3 4 5 6 7 8 9 X
      

The library includes a routine which allows the user to pick an arbitrary triangle and an arbitrary number of subdivisions. It then returns the triangular gridpoints defined by that choice.

Licensing:

The computer code and data files described and made available on this web page are distributed under the MIT license

Languages:

triangle_grid is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.

Related Data and Programs:

triangle_grid_test

octave_grid, an Octave code which generates a regular grid of points inside a variety of regions in one, two, three or many dimensions.

Source Code:


Last revised on 06 April 2019.