11.07.2014 Views

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPENDIX B. PROGRAM LISTINGS 261<br />

int i;<br />

int nmin = 0;<br />

int nmax = 0;<br />

int descent = 1;<br />

Point p1, p2;<br />

p1 = (Point)elementAt(points, 0);<br />

/* run through all points given */<br />

for(i = 1; i < sizeVector(points); i++) {<br />

p2 = (Point)elementAt(points, i);<br />

/* if next point increases */<br />

if(p2->y > p1->y && descent) {<br />

nmin++;<br />

descent = 0;<br />

}<br />

/* if next point decreases, indicate decrease */<br />

if(p2->y < p1->y && !descent) {<br />

nmax++;<br />

descent = 1;<br />

}<br />

p1 = p2;<br />

}<br />

if(type == MINIMUM)<br />

return nmin;<br />

else<br />

return nmax;<br />

}<br />

double lowest(Vector points) {<br />

int i;<br />

Point p;<br />

double minf, minZ;<br />

/* minimum is set to first point */<br />

p = (Point)elementAt(points, 0);<br />

minf = p->x;<br />

minZ = p->y;<br />

/* find lowest point in data vector <strong>and</strong> return it */<br />

for(i = 1; i < sizeVector(points); i++) {<br />

p = (Point)elementAt(points, i);<br />

if(p->y < minZ) {<br />

minf = p->x;<br />

minZ = p->y;<br />

}<br />

}<br />

return minf;<br />

}<br />

double highest(Vector points) {<br />

int i;<br />

Point p;<br />

double maxf, maxZ;<br />

/* maximum is set to first point */<br />

p = (Point)elementAt(points, 0);<br />

maxf = p->x;<br />

maxZ = p->y;<br />

/* find highest point in data vector <strong>and</strong> return it */<br />

for(i = 1; i < sizeVector(points); i++) {<br />

p = (Point)elementAt(points, i);<br />

if(p->y > maxZ) {

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!