This repository has been archived on 2021-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
NC/mp3/Project_3_Maggioni_Claudio/datasets/Mesh_generation/gridt.m

26 lines
516 B
Mathematica
Raw Normal View History

2020-10-21 13:21:51 +00:00
function [A,xy] = gridt(k)
% GRIDT : Generate triangular mesh.
%
% [A,xy] = GRIDT(k) returns a k*(k+1)/2-square symmetric positive
% definite matrix A with the structure of an equilateral triangular
% mesh with side k, and an array xy of coordinates of the mesh points.
% Start with a square 7-point grid.
[A,xy] = grid7(k);
% Mask off one triangle of it.
xy = xy-1;
f = find(xy(:,1)+xy(:,2)<k);
A = A(f,f);
xy = xy(f,:);
% Make the other triangle equilateral.
T = [ 1 0 ; 1/2 2/sqrt(5)];
xy = xy*T;
end