From instruction: Draw a straight line and follow it
Code: nD by peter
nD
void drawLine(ulong n, int samples){ double* p0 = new double[n]; double* p1 = new double[n]; double* dI = new double[n]; for(ulong i=0;i<n;i++){ p0[i] = rand(); p1[i] = rand(); dI[i] = (p0[i]-p1[i])/(double)samples; } for(int s=0;s<samples;s++){ for (ulong i=0;i<n;i++)p0[i]+=dI[i]; drawPoint(p0); } delete[] p0; p0 = NULL; delete[] p1; p1 = NULL; delete[] dI; dI = NULL; }
[download]
Written in C++. Released under the GPLv2 license