FlameDuck #1 for(i=1;i<nRows-1;i++) means FOR i = 1 TO nRows-2, not nRows-1. Or use Until: For i = 1 Until nRows-1. Wouldn't Sinf() and Cosf() be expecting radians? Yes it would.