
In [2]:
addpath('toolbox_signal')


## Planar Triangulation¶

A planar triangulation is a collection of |n| 2D points, whose coordinates are stored in a |(2,n)| matrix |vertex|, and a topological collection of triangle, stored in a |(m,2)| matrix |faces|.

Number of points.

In [3]:
n = 200;


Compute randomized points in a square.

In [4]:
vertex = 2*rand(2,n)-1;


A simple way to build a triangulation of the convex hull of the points is to compute the Delaunay triangulation of the points.

In [5]:
faces = delaunay(vertex(1,:),vertex(2,:))';


One can display the triangulation.

In [6]:
clf;
subplot(1,2,1);
hh = plot(vertex(1,:),vertex(2,:), 'k.');
axis('equal'); axis('off');
set(hh,'MarkerSize',10);
title('Points');
subplot(1,2,2);
plot_mesh(vertex,faces);
title('Triangulation');


## Point Modification¶

It is possible to modify the position of the points like a particles system. The dynamics is govered by the connectivity to enfoce an even distribution. During the modification of the positions, the connectivity is updated.

Fix some points on a disk.

In [7]:
m = 20;
t = linspace(0,2*pi,m+1); t(end) = [];
vertexF = [cos(t);sin(t)];
vertex(:,1:m) = vertexF;
faces = delaunay(vertex(1,:),vertex(2,:))';


Initialize the positions.

In [8]:
vertex1 = vertex;


Compute the delaunay triangulation.

In [9]:
faces1 = delaunay(vertex1(1,:),vertex1(2,:))';


Compute the list of edges.

In [10]:
E = [faces([1 2],:) faces([2 3],:) faces([3 1],:)];
p = size(E,2);


We build the adjacency matrix of the triangulation.

In [11]:
A = sparse( E(1,:), E(2,:), ones(p,1) );


Normalize the adjacency matrix to obtain a smoothing operator.

In [12]:
d = 1./sum(A);
iD = spdiags(d(:), 0, n,n);
W = iD * A;


Apply the filtering.

In [13]:
vertex1 = vertex1*W';


Set of the position of fixed points.

In [14]:
vertex1(:,1:m) = vertexF;


Display the positions before / after.

In [15]:
clf;
subplot(1,2,1);
plot_mesh(vertex,faces);
title('Before filering');
subplot(1,2,2);
plot_mesh(vertex1,faces1);
title('After filtering');


Exercise 1

Compute several steps of iterative filterings, while ensuring the positions of the fixed points.

In [16]:
exo1()

In [17]:
%% Insert your code here.