Mathematical Principles for Scientific Computing and Visualization  
http://www.farinhansford.com/books/scv
by Gerald Farin and Dianne Hansford

This notebook constructs an estimate for a normal to a triangle mesh.
The normal is calculated manually.

Figure 13.6 was created with this notebook.

Exercise: Calculate the normal using one or more methods.

See Chapter 13: Facets for details.

Updated May 2008

(* Output results to folder that this file lives in *)
(SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];) 

(* Define a point set. The peak point is at the center. *)

 (pt1={0,0,0};) 
(pt2={1,0,0};) 
(pt3={3,1,-0.5`};) 
(pt4={2,3,0};) 
(pt5={0,2,0};) 
(peak={1,1,1};) 

(* Define a triangulation based on the point set *)

(tri1=Graphics3D[Polygon[{pt1,pt2,peak}]];) 
(tri2=Graphics3D[Polygon[{pt2,pt3,peak}]];) (tri3=Graphics3D[Polygon[{pt3,pt4,peak}]];) (tri4=Graphics3D[Polygon[{pt4,pt5,peak}]];) (tri5=Graphics3D[Polygon[{pt5,pt1,peak}]];) 

(* Combine the triangles to create the mesh *)
(mesh1={tri1,tri2,tri3,tri4,tri5};) 

(* Define a normal -- hand calculated as the average of the normals of the faces meeting at the peak vertex *)

normal=Graphics3D[{Thick,Line[{peak,peak+{-0.2`,0,1.5`}}]}];

(pic=Show[{mesh1,normal},ViewPoint->{1,-1,1.5`},Boxed->False])

(* Output a postscript file *)
 Export["mesh_normal.eps",pic]