Question about normals in surfnorm function

2 views (last 30 days)
Myles
Myles on 19 Jun 2013
Hi everybody, I have a quick question about the built in MATLAB function surfnorm. I have inputs which create a surface and when using the surfnorm function it outputs what LOOKS like correct normals; however, once I try and extract the normals using:
[Nx, Ny, Nz] = surfnorm(x,y,z)
The components of the normal seem to be incorrect - I have tested the function with quite a few surfaces and it appears to work for spheres, and some simple planes, but the normals it outputs for my surface, or a cylinder (which LOOK correct in both figures) seem to be incorrect. I've attached some code for a cylinder and what I have extracted so maybe someone can see what I am doing wrong.
[x,y,z] = cylinder(1:10);
surfnorm(x,y,z)
[Nx,Ny,Nz] = surfnorm(x,y,z);
p1 = [x(5),y(5),z(5)];
n1 = [Nx(5),Ny(5),Nz(5)];
p3 = p1 + n1;
vec1 = [p1;p3];
hold on
plot3(vec1(:,1),vec1(:,2),vec1(:,3),'g')
Alternatively, for a sphere it works fine, just change the first few lines to this:
[x,y,z] = sphere(10);
surfnorm(x,y,z);
[Nx,Ny,Nz] = surfnorm(x,y,z);
Any help would be greatly appreciated!
Thanks,
Myles

Answers (0)

Community Treasure Hunt

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

Start Hunting!