Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to find (and plot) surface normal

Subject: How to find (and plot) surface normal

From: Li Perry

Date: 6 Apr, 2010 20:33:24

Message: 1 of 4

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

Subject: How to find (and plot) surface normal

From: sivabalan N

Date: 19 Apr, 2010 03:22:07

Message: 2 of 4

Hi Perry my name is siva
my Email id: vigisiva@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@gmail.com> wrote in message <hpg5qk$o1a$1@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

Subject: How to find (and plot) surface normal

From: Roger Stafford

Date: 19 Apr, 2010 06:16:05

Message: 3 of 4

  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

Subject: How to find (and plot) surface normal

From: crus

Date: 2 Dec, 2013 04:09:10

Message: 4 of 4

Hi,
I am glad to see this problem,I believe you must have solve the problem ,now I am puzzled by this similiar ,can you give me some suggestion.
 My Email is 616974841@qq.com

hope for your reply
 thanks .


"Li Perry" wrote in message <hpg5qk$o1a$1@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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us