-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2D.m
56 lines (42 loc) · 1.14 KB
/
test2D.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
close all
% Randomize triangle vertices
vertices = (rand(3,2) - 0.5).*2;
% Plot triangle
figure
hold on
T = delaunayTriangulation(vertices);
triplot(T)
% Rotation of theta rad
theta = 6*rand;
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
vertices_R = (R*vertices')';
% Plot rotated triangle
T = delaunayTriangulation(vertices_R);
triplot(T,'--')
% Scale
scale = (rand -.5)*4;
vertices_S = vertices.*scale;
% Plot scaled triangle
T = delaunayTriangulation(vertices_S);
triplot(T,':')
% Translation
translation = (rand -.5)*4;
vertices_T = vertices+translation;
% Plot translated triangle
T = delaunayTriangulation(vertices_T);
triplot(T,':')
%Distances computation
a = vertices(2,:) - vertices(1,:);
b = vertices(3,:) - vertices(2,:);
u = vertices_R(2,:) - vertices_R(1,:);
v = vertices_R(3,:) - vertices_R(2,:);
disp("Rotation distance");
LSD(a,b,u,v)
u = vertices_S(2,:) - vertices_S(1,:);
v = vertices_S(3,:) - vertices_S(2,:);
disp("Scale distance");
LSD(a,b,u,v)
u = vertices_T(2,:) - vertices_T(1,:);
v = vertices_T(3,:) - vertices_T(2,:);
disp("Translation distance");
LSD(a,b,u,v)