-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtracer_frenet.m
56 lines (40 loc) · 1.5 KB
/
tracer_frenet.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
function tracer_frenet (X)
%{
This function allows to draw the tangent vectors and the normal vectors
and the centers of curvature of the curve defined by a point cloud.
Data input:
- X: cloud of points
Author: SABIR ILYASS - 2022.
%}
% Get the number of points of X
n = size(X,2);
% Initializing tangent vectors
tangent_X = zeros(2,n - 2);
% Initializing the derivation of the tangent vectors and the normal vectors
derived_tengant_vector = zeros(2, n - 2);
normal_X = zeros(2,n - 2);
% Initializing the center of curvature
center_of_curvature = zeros(2, n-2);
% Tangent vectors
for i = 1:n-2
tangent_X(:,i) = (X(:,i + 2) - X(:, i)) / norm(X(:,i) - X(:, i + 2));
end
% Derivation of the tangent vectors and the normal vectors
for i = 1:n-2
derived_tengant_vector(:,i) = 2 * ((X(:,i+2) - X(:,i+1))/norm(X(:,i+2) - X(:,i+1)) - (X(:,i+1) - X(:,i))/norm(X(:,i+1) - X(:,i))) / norm(X(:,i+2) - X(:,i));
% center of curvature
curvature = norm(derived_tengant_vector(:,i));
normal_X(:,i) = derived_tengant_vector(:,i) / curvature;
center_of_curvature(:,i) = X(:,i + 1) + normal_X(:,i) ./ curvature;
end
% % Normal vectors
% normal_X(1,:) = -tangent_X(2,:);
% normal_X(2,:) = tangent_X(1,:);
axis equal;
hold on;
quiver(X(1,2:n-1), X(2,2:n-1), tangent_X(1,:), tangent_X(2,:), 'off');
quiver(X(1,2:n-1), X(2,2:n-1), normal_X(1,:), normal_X(2,:), 'off');
title('tangent and normal vectors');
for i = 1 : n -2
cercles(center_of_curvature(1,i), center_of_curvature(2,i), X(1,i+1), X(2,i+1));
end