Given a data-set of X-Y coordinates in a matrix of 61x2 for points of an airfoil. How would I go about creating normal vectors along each point along the airfoil. I've plotted the airfoil so far:
Let us assume that your airfoil is closed.
To calculate the normals at each points you can average the normals to each segment.
This should take care of the trailing edge issue…
I suppose your data is x, y
xtmp1 = [x, x(1)]
ytmp1 = [y, y(1)]
xtmp2 = [x(end), x]
ytmp2 = [y(end), y]
nx = (diff(ytmp1)+diff(ytmp2))/2.0
ny = -(diff(xtmp1)+diff(xtmp2))/2.0
nx
will contain x-component of your normal and ny
will contain y-component of your normal
of course you can normalize the result if you want normals of equal length
ntmp = 1.0 ./ sqrt(nx.*nx+ny.*ny)
nx = nx .* tmp
ny = ny .* tmp
As suggested you can also normalize each segment's normal and then average as such
xtmp1 = [x, x(1)]
ytmp1 = [y, y(1)]
xtmp2 = [x(end), x]
ytmp2 = [y(end), y]
nxF = diff(ytmp1)
nyF = -diff(xtmp1)
nxB = diff(ytmp2)
nyB = -diff(xtmp2)
ntmp = 1.0 ./ sqrt(nxF.*nxF+nyF.*nyF)
nxF = nxF .* tmp
nyF = nyF .* tmp
ntmp = 1.0 ./ sqrt(nxB.*nxB+nyB.*nyB)
nxB = nxB .* tmp
nyB = nyB .* tmp
nx = (nxF+nxB)/2.0
ny = (nyF+nxB)/2.0
And then normalize nx
and ny