Angle between two best-fit planes

5 visualizaciones (últimos 30 días)
Meghana Dinesh
Meghana Dinesh el 29 de Abr. de 2015
Editada: Meghana Dinesh el 30 de Abr. de 2015
I have a set of points (as in Points3D.mat attached here). I find the equation of best fit plane using affine_fit by Adrien Leygue. This is how I call the function:
[ n_1,V_1,p_1,X_1,Y_1,Z_1 ] = Fit_Display_Plane( point3d );
[ n_2,V_2,p_2,X_2,Y_2,Z_2 ] = Fit_Display_Plane( point3d );
Function definition:
function [ n,V,p,x,y,z ] = Fit_Display_Plane( point3d )
[n,V,p] = affine_fit(point3d);
[S1,S2] = meshgrid([100 -50 200]); %([10000 -5000 20000]);
%generate the point coordinates
x = p(1)+[S1(:) S2(:)]*V(1,:)';
y = p(2)+[S1(:) S2(:)]*V(2,:)';
z = p(3)+[S1(:) S2(:)]*V(3,:)';
%plot the plane
surf(reshape(x,3,3),reshape(y,3,3),reshape(z,3,3),'facecolor','blue','facealpha',0.5);
% xlabel('x');
% ylabel('y');
% zlabel('z');
% axis equal
end
When I do this, I obviously get the same set of values for [ n_1,V_1,p_1,X_1,Y_1,Z_1 ] and [ n_2,V_2,p_2,X_2,Y_2,Z_2 ]
My main intention is to find the angle between two planes ( the first plane is the reference plane. The second plane's tilt w.r.t first plane in X, Y and Z axes should be found .),
To do so, I am doing:
function [ Angle1,Angle2,Angle3 ] = FindAlphaBeta( n_1,p_1,n_2,p_2)
N1 = n_1;
N2 = n_2;
Nxy=[0 0 1]; %unit normal to XY plane
N1=N1/norm(N1); %make sure all normals are unit vectors
N2=N2/norm(N2);
Angle_XY=acosd(dot(cross(N1,Nxy), cross(N2,Nxy))) %the result
Nxz=[0 1 0]; %unit normal to XY plane
Angle_XZ=acosd(dot(cross(N1,Nxz), cross(N2,Nxz))) %the result
Nyz=[1 0 0]; %unit normal to XY plane
Angle_YZ=acosd(dot(cross(N1,Nyz), cross(N2,Nyz))) %the result
Angle1 = Angle_XY;
Angle2 = Angle_XZ;
Angle3 = Angle_YZ;
end
Since in the current case, n_1 = n_2 and p_1 = p_2, I am supposed to get zero value for Angle1, Angle2 and Angle3. (i.e. the angle between the lines formed when these two planes are intersected by X = 0 plane, Y = 0 plane and Z = 0 plane)
Instead, I get these values:
Angle_XY = 88.1821; % Angle between the two lines formed when Z = 0 plane intersects
Angle_XZ = 2.5280; % Angle between the two lines formed when Y = 0 plane intersects
Angle_YZ = 14.2455; % Angle between the two lines formed when X = 0 plane intersects
Where am I going wrong?
I can see only two possibilities:
  1. My function FindAlphaBeta is wrong.
  2. function affine_fit is not giving me the results what I intend to get.
Could anyone correct me? I have been trying this since a very long time. Let me know if more details are required. I need help in the linear algebra part.
Regards,
Meghana.
  2 comentarios
Matt J
Matt J el 29 de Abr. de 2015
Editada: Matt J el 29 de Abr. de 2015
To make things easier, could you simply give us the values of n_1 and n_2 that are being generated by Fit_Display_Plane? The angle calculations done in FindAlphaBeta do not use anything else. In other words, there is no apparent reason to be feeding p_1 and p_2 to that function.
As a side note, it is not clear how to interpret the p,V,x,y,z output arguments from Fit_Display_Plane. Whoever gave you that routine, they were not kind enough to provide help text...
Meghana Dinesh
Meghana Dinesh el 30 de Abr. de 2015
Well, thanks for your input.
I was trying various other ways to find these three angles. Hence, I feed p_1 and p_2 to that function. The link to affine_fit by Adrien Leygue is given in the second statement of my question. This contains a little help on how to use the output parameters p,V,x,y,z.

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 29 de Abr. de 2015
Editada: Matt J el 29 de Abr. de 2015
My guess is that the fitted planes are nearly parallel to the XY plane, so that the Angle_XY result is meaningless. However, see also comments above.
At the very least, you need to modify FindAlphaBeta so that it tries to detect and handle these degenerate situations.
  1 comentario
Meghana Dinesh
Meghana Dinesh el 30 de Abr. de 2015
Editada: Meghana Dinesh el 30 de Abr. de 2015
I have attached the output parameters of Fit_Display_Plane (n_1,V_1,p_1,X_1,Y_1,Z_1) in OutputOfPlaneFit.mat below. I have also attached affine_fit by Adrien Leygue, which contains an interpretation of variables n, V, p, X, Y and Z.

Iniciar sesión para comentar.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by