A surface normal is a vector which is perpendicular to a surface. Amongst other things, normals are used in 3d Graphics to determine how much light illuminates any given surface with a directional light source.
Here is a visualisation of Normals, using white lines:
To calculate a normal, The surface fragment must be defined by a triangle of 3 points (going anticlockwise looking down on the surface).
From inc/OpenglSceneFram.inc type vector float x,y,z
macro VectorDiff(pr,pt,pd)
==========================
pr.x=pt.x-pd.x
pr.y=pt.y-pd.y
pr.z=pt.z-pd.z
end macro
sub SurfaceNormal(vector *n,*p1,*p2,*p3)
========================================
'assumes triangle points are defined anticlockwise
vector u,v
VectorDiff(u,p1,p2)
VectorDiff(v,p1,p3)
n.x=(u.y*v.z)-(u.z*v.y)
n.y=(u.z*v.x)-(u.x*v.z)
n.z=(u.x*v.y)-(u.y*v.x)
end sub