From: Li Perry on
Hey,

I have a 3D point cloud.
I need to create a surface mesh and find the normal vector to each vertex.

I wrote a very naive method that:
-- finds the normal vector of each triangle in the mesh
-- finds the neighboring trinagles of each vertex
-- returns the sum of all the neighbors' noramls as the vertex normal

My questions are:
1. Is this correct? Is there a better way to find the surface normal?
2. How can I plot the result so I can see the whole mesh with its normals?
I use "trisurf" to plot the mesh, but I don't know how to add the normal vectors..
(sorry if this is trivial, I'm quite new with matlab..)

Thanks,
Li
From: sivabalan N on
Hi Perry my name is siva
my Email id: vigisiva(a)gmail.com
I too having the same doubts...
i need a help will u do?
1.how can i find vector normal of a each triangle of a surfce created in matlab?
2.How to find angle between each veactor normal adjusant?
if u knw source code or reference website plz plz inform me...
im thank ful to u..
im waitng for ur valuable reply........
***************************************
"Li Perry" <lazygoldenpanda(a)gmail.com> wrote in message <hpg5qk$o1a$1(a)fred.mathworks.com>...
> Hey,
>
> I have a 3D point cloud.
> I need to create a surface mesh and find the normal vector to each vertex.
>
> I wrote a very naive method that:
> -- finds the normal vector of each triangle in the mesh
> -- finds the neighboring trinagles of each vertex
> -- returns the sum of all the neighbors' noramls as the vertex normal
>
> My questions are:
> 1. Is this correct? Is there a better way to find the surface normal?
> 2. How can I plot the result so I can see the whole mesh with its normals?
> I use "trisurf" to plot the mesh, but I don't know how to add the normal vectors..
> (sorry if this is trivial, I'm quite new with matlab..)
>
> Thanks,
> Li
From: Roger Stafford on
Li, I would think a more natural representation of normals would be to associate the normal to each triangle with the center (centroid) of that same triangle. That way you can use the precise normal that can be calculated for each triangle rather than an approximation for normals at the vertices. I am not sure of the best way to weight different triangles' normals surrounding a particular vertex.

If a triangle has the three vertices P1 = [x1,y1,z1], P2 = [x2,y2,z2], and P3 = [x3,y3,z3], then its centroid is located at

P0 = (P1+P2+P3)/3.

A unit normal to this triangle can be computed as

u = cross(P2-P1,P3-P1);
u = u/norm(u); % Make u of unit length

This normal will point inward or outward depending on the direction of the path

P1 --> P2 --> P3 --> P1,

relative to the inner/outer directions of the surface. Pointing the fingers of your right hand in the direction of this triangular path, your thumb would point in the direction of the normal, u, as calculated above, assuming the x,y,z axes are in right-hand orientation.

That last should answer siva's question 1. For question 2. the angle between two vectors, v1 and v2, is given by:

angle = atan2(norm(cross(v1,v2)),dot(v1,v2));

It is independent of the lengths of v1 and v2, and ranges between 0 and pi radians.

Roger Stafford