int[] S = new int [scap]; // indices to resampled vertices on the computed polyloop int sn =0; // number of samples // STUDENT ADDED CLASS //////////////////////////////// // this class stores curve information, and will parameterize lengths class ParamSeg { pt Start, End; // start, end point of span vec pVec; // vector representing span length float Length; // unparameterized length of span float ParamLength; // span length/total length of curve // create a span with start/end points public ParamSeg(pt s, pt e) { Start = s; End = e; // create vector pVec = new vec(e.x - s.x, e.y - s.y); // store length Length = s.disTo(e); } // called to parameterize span public void createParamLength(float tlen){ParamLength = Length/tlen;} // called to interpolate the point on the line // ct = (t - previous parameterized spans) public pt getPos(float ct){ct /= ParamLength;return new pt(Start.x + pVec.x * ct, Start.y + pVec.y * ct);} } // STUDENT ADDED VARIABLES //////////////////////////////// float totalLength = 0; // saves the toal length of the curve boolean compFlag = true; // flag to set if lengths need to be recomputed ParamSeg [] pointLenghtArray = new ParamSeg[scap]; // used to store parameterized curve void drawSamples() {stroke(blue); for (int i=0; i C[S[i]].disTo(C[S[xp(i)]]) ) S[i]=sn(S[i]); else S[i]=sp(S[i]) ; } void copySamples() { int m=svn+1; int mi=0; for (int i=0; i (sum_prev_spans + this_span) go to next span if(partalLength + pointLenghtArray[i].ParamLength < t)partalLength += pointLenghtArray[i].ParamLength; // else return interpolated point on this span else { return pointLenghtArray[i].getPos(t - partalLength); } } return new pt(0, 0); } // hook function, called from P1b void myUniformSampling() { int numSteps = svn * 5; float resampleStep = 1.0f/(float)(numSteps); compFlag = true; // reset computation flag (we need to recompute polyline info) float step = 1.0f/numSteps; // decide how many pt tempC[] = new pt[numSteps]; // create a temporary array for info int i=0; // reset i // generate points for(float t=0;t<1.0f;t+=resampleStep) { tempC[i++] = sampleAt(t); } // copy points into polyline array for(i=0;i