function computeNormalBetweenXYpoints, xPoints, yPoints nPoints = n_elements(xPoints) if nPoints ne n_elements(yPoints) then message,'Number of x and y points do not match' normal = fltarr(2,nPoints-1) v2 = [0.0, 0.0, 1.0] for i=0L,nPoints-2 do begin v1 = [xPoints[i+1] - xPoints[i],yPoints[i+1] - yPoints[i],0] v1 = v1/norm(v1) v3 = crossp(v1,v2) v3 = v3/norm(v3) normal[0,i] = xPoints[i] + v3[0] normal[1,i] = yPoints[i] + v3[1] endfor return, normal end pro testComputeNormalBetweenXYpoints theta = findgen(36)*10 x = 2*cos(theta*!dtor) y = sin(theta*!dtor) plot,x,y,ystyle=1,xstyle=1,psym=-1,xrange=[-2,2],yrange=[-2,2] normals = computeNormalBetweenXYpoints(x,y) for i=0,n_elements(x)-2 do begin plots,[x[i],normals[0,i]],[y[i],normals[1,i]] ;plots,[normals[0,i]],[normals[1,i]],psym=1 endfor wshow return & end