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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| % On vide la mémoire
close all
clear all
clc
%% Tolerance_A.m
% Version 2 : ajout d'une rotation pour tester l'approximation du plan
% Nombre de points nominaux de l'anneau
N = 360;
% Centre de l'anneau
x = 0;
y = 0;
z = 0;
% Rayon max de l'anneau
R_max = 15;
% Rayon min de l'anneau
R_min = 12;
% Définition de l'anneau nominal
XAnneau_nom = [];
YAnneau_nom = [];
ZAnneau_nom = [];
for VTheta = 0:(2*pi)/N:2*pi
p = rand(1);
X = x + (R_min + (R_max-R_min) * p) * cos(VTheta);
Y = y * ones(size(VTheta));
Z = z + (R_min + (R_max-R_min) * p) * sin(VTheta);
XAnneau_nom = [XAnneau_nom X];
YAnneau_nom = [YAnneau_nom Y];
ZAnneau_nom = [ZAnneau_nom Z];
end
Anneau_nom = [XAnneau_nom; YAnneau_nom; ZAnneau_nom];
% Affichage de l'anneau nominale
figure
plot3(Anneau_nom(1,:), Anneau_nom(2,:), Anneau_nom(3,:), '*r'); hold on
xlabel ('X')
ylabel('Y')
zlabel ('Z')
% Définition de l'anneau expérimental
Ordre = 1 / 10000;
Anneau_exp = [XAnneau_nom; YAnneau_nom; ZAnneau_nom];
for i = 1 : N + 1
p = rand(1);
Anneau_exp(2, i) = Anneau_exp(2, i) + 2 * Ordre * p - Ordre;
end
% Valeurs de rotation suivant les axes (radian)
Alpha = 0; % rotation autour de l'axe x
Betha = 0; % rotation autour de l'axe y
Gamma = 0; % rotation autour de l'axe z
Rotation_x = [1, 0, 0;
0, cos(Alpha), -sin(Alpha);
0, sin(Alpha), cos(Alpha)];
Rotation_y = [cos(Betha), 0, sin(Betha);
0, 1, 0;
-sin(Betha), 0, cos(Betha)];
Rotation_z = [cos(Gamma), -sin(Gamma), 0;
sin(Gamma), cos(Gamma), 0;
0, 0, 1];
% Matrice de rotation
Rotation = Rotation_x*Rotation_y*Rotation_z;
% Ajout de la rotation et de la translation
Anneau_exp = Rotation * Anneau_exp;
% Affichage de l'anneau expérimental
plot3(Anneau_exp(1,:), Anneau_exp(2,:), Anneau_exp(3,:), '*b');
grid on
% Résolution du plan
% Nous savons que l'équation d'un plan est de la forme : aX + bY + cZ + d = 0
% On pose aX + bY + cZ = -d
% On fixe la valeur de d = 1
% Nous allors résoudre cette équation
d = 4;
X = (Anneau_exp(1, :).');
Y = (Anneau_exp(2, :).');
Z = (Anneau_exp(3, :).');
i = size(X);
M = [X Y Z];
Res = M \ (-d * ones(i));
a = Res(1); b = Res(2); c = Res(3) ;
% Affichage du plan
[Xp, Zp] = meshgrid(-R_max:0.5:R_max);
Yp = @(Xp,Zp) (-d - a*Xp - c*Zp)/b;
mesh(Xp,Yp(Xp,Zp),Zp); |
Partager