I'm working this example in my java book, it is supposed to graph a mathematical function and it does work, but i don't understand the last two lines, can someone explain them to me? Assume that data is an array of doubles and holds function values for a certain 'range' in this case the range is -pi to pi.
The book has a comment for this little slice of code and i have an idea of what it is doing, but i would like to know exactly why we do the last two lines in this loop.
// Scale and translate data values
for (int i = 0; i < d.width; i++) {
double value = data[i];
double k = (value - min) / (max - min);
data[i] = d.height * (1 - k);
}
can someone help me out?