File Exchange

image thumbnail

Compute STL Vertex Normals

version 1.0 (1.73 KB) by

Find the per-vertex normals for a tesselated surface.



View License

The default normal vectors associated with tesselated surfaces are computed for each triangle face. Some purposes (like nice rendering) require per-vertex normals instead. These are typically calculated by averaging the face normals. This function offers two methods, first, an average normal weighted by triangle area, and second the normal as an average of the surrounding triangle faces. The second option is faster (because it uses the pre-computed unit-normals), but the first method generates nicer surface-normals, particularly at regions with sharp edges or small triangles.

This should do essentially the same thing as Dirk-Jan Kroon's 'Patch Normals' submission #24330, and my code is probably slower because it is not compiled. However, it's a bit simpler to read and (hopefully) to use.

Comments and Ratings (1)

MATLAB Release
MATLAB 7.13 (R2011b)

Inspired by: Patch Normals, Binary STL file reader

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video