-
Graph maths
Hiya
I've got a problem that I suppose is more about maths than Java. I'm doing the cs106a Stanford online class, and am stuck thinking about how to represent a graph on a page, where the values of y goes up as you go down the page, and the values of the data goes up in the other direction. And the value of y is variable, because the window can be resized. There's also a bottom and a top margin to the graph on the window, so the top data value doesn't match precisely to 0 and the 0 data value doesn't map precisely to getHeight().
The max data value is 1000. So 1000 would always be at 0 + margin. And 0 data value would always be getHeight() - margin. Not sure how to go from there to calculating the point on the page for any value in between...
Cheers, R
-
Re: Graph maths
I really don't know what you're asking, but I would suggest getting out a piece of paper and a pencil and drawing a bunch of different scenarios until you start to see a pattern.
-
Re: Graph maths
Well, the pattern doesn't really change, it's as I described. lets say there's a point on the graph at 750. I'm trying to find a formula that would calculate the position on the y axis for that point. Or any point between 0 and 1000.