Why do the surface norms calculated by SURFNORM and QUIVER3 not coincide in MATLAB 6.5 (R13)?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I use the following code to plot the surface normal of a surface object using 2 methods with the SURFNORM and QUIVER3 functions:
[X,Y] = meshgrid(-2:0.25:2,-1:0.2:1);
Z = X.* exp(-X.^2 - Y.^2);
[U,V,W] = surfnorm(X,Y,Z);
quiver3(X,Y,Z,U,V,W,0.5);
hold on;
surfnorm(X,Y,Z); % difference is here
colormap hsv;
view(-35,45);
axis ([-2 2 -1 1 -.6 .6]);
hold off;
grid on;
legend('SURFNORM output to QUIVER3','Data','SURFNORM plot');
However, the surface normals created with the two methods do not coincide with one another when viewing them in a figure window.
Respuesta aceptada
MathWorks Support Team
el 27 de Jun. de 2009
This is the correct behavior. A unit vector only displays orientation information. The orientation needs to be scaled if the aspect ratio is not the basic [1 1 1] as is in the case of an arbitrary plot. Another way to see this is to think of a line going from [0,1] to [1,1]. Imagine plotting the line in different aspect ratios–the unit vector would have to change to stay normal.
To correct the perceived misalignment with SURFNORM and QUIVER3, you can set both the DataAspectRatio and PlotBoxAspectRatio properties of the Axes Object as shown in the following example code:
[X,Y] = meshgrid(-2:0.25:2,-1:0.2:1);
Z = X.* exp(-X.^2 - Y.^2);
[U,V,W] = surfnorm(X,Y,Z);
quiver3(X,Y,Z,U,V,W,0.5);
hold on
surf(X,Y,Z);
colormap hsv
hold on;
set(gca,'DataAspectRatio',[1 1 1]);% set data aspect ratio
set(gca,'PlotBoxAspectRatio',[1 1 1]);% set plot box aspect ratio
surfnorm(X,Y,Z);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!