5.0

5.0 | 2 ratings Rate this file 24 downloads (last 30 days) File Size: 2.25 KB File ID: #23063

Compute normal vectors of 2.5D triangulation

by David Gingras

 

21 Feb 2009 (Updated 05 May 2009)

Code covered by BSD License  

That function compute the normal vectors of a 2.5D triangulation.

Download Now | Watch this File

File Information
Description

It could be useful to know the normal vectors of a surface. The function provided is able to take a 2.5D unrestricted triangulation (Delaunay or not) which define a 3D surface and computes the normal vectors of each cell. It is possible to compute vectors at the center cells or at vertices.

Inputs :
           "XYZ" is the coordinate of the vertex of the triangulation (nx3 matrix).
           "TRI" is the list of triangles which contain indexes of XYZ (mx3 matrix).
           "strPosition" is the position where the normal is computed. It
           could be 'center-cells' for a computation on the center of each
           triangle or could be 'vertices' and the vectors are computed at
          vertices with respect to the neighbor cells (string).

Outputs :
           "NormalVx", "NormalVy" and "NormalVz" are the component of
          normal vectors (normalized to 1).
          "PosVx", "PosVy" and "PosVz" is the positions of each vector.
 
Note :
           if strPosition == 'center-cells', then the dimension of each
           output are mx1.
           if strPosition == 'vertices', then the dimension of each
           output are nx1.

           All cells have to be enumerated clockwise or counter-clock.

 Example :

 [X,Y,Z]=peaks(25);
 X=reshape(X,[],1);
 Y=reshape(Y,[],1);
 Z=0.4*reshape(Z,[],1);
 TRI = delaunay(X,Y);
 [NormalVx NormalVy NormalVz PosVx PosVy PosVz]=computeNormalVectorTriangulation([X Y Z],TRI,'vertices');

 quiver3(PosVx,PosVy, PosVz, NormalVx, NormalVy, NormalVz), axis equal
 hold on
 trimesh(TRI,X,Y,Z)

 David Gingras, February 2009

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
25 Mar 2009 Gozde Unal

very nice, thanks.

30 Apr 2009 Edward Bender

Worked perfectly the first time. A+!

Please login to add a comment or rating.
Updates
05 May 2009

updated description

Tag Activity for this File
Tag Applied By Date/Time
2d Cristina McIntire 23 Feb 2009 11:02:44
triangulation David Gingras 23 Feb 2009 11:02:49
delaunay David Gingras 23 Feb 2009 11:02:49
normal vector David Gingras 23 Feb 2009 11:02:49
delaunay sabeena naushad 05 May 2009 06:04:16
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com