In this article we investiguate in detail how to mesh a geometry with the toolbox CGLAB:

https://atoms.scilab.org/toolboxes/cglab/

```//Meshing in Scilab
//Requires CGLAB toolbox
atomsInstall 'cglab'

nx = 10;
ny = 10;
Lx = 0.45;
Ly = 0.40;

[x, y] = meshgrid(linspace(0, Lx, nx), linspace(0, Ly, ny))

n = nx * ny;
PosNoeuds = [x(:), y(:)]; // nodal coordinates

// Borders are defined with Lbord
eps = 0.0001;
Lbord = find(PosNoeuds(:, 1) < eps );
Lbord = union(Lbord, find(PosNoeuds(:, 1) > Lx - eps));
Lbord = union(Lbord, find(PosNoeuds(:, 2) < eps));
Lbord = union(Lbord, find(PosNoeuds(:, 2) > Ly - eps));

scf();
plot(PosNoeuds(:, 1), PosNoeuds(:, 2), 'b.');

// Displacement of the origin at the node (0.5 Lx,O.5 Ly)
PosNoeuds = PosNoeuds - ones(n , 1)*[Lx/2, Ly/2];

// triangular elements
tri = delaunay_2(PosNoeuds(:, 1)', PosNoeuds(:, 2)');
[nbtri2,nb2] = size(tri);
tri2 = [tri tri(:,1)];

for k = 1:nbtri2
plot2d(x(tri2(k,:)),y(tri2(k,:)),style = 2);
end
```

To read more on the subject:

CGLAB Toolbox for Geometric Algorithms