I’m looking for an efficient way to convert axes coordinates to pixel coordinates for multiple screen resolutions.
For example if had a data set of values for temperature over time, something like:
int temps[] = {-8, -5, -4, 0, 1, 0, 3};
int times[] = {0, 12, 16, 30, 42, 50, 57};
What’s the most efficient way to transform the dataset to pixel coordinates so I could draw a graph on a 800×600 screen.
Assuming you’re going from
TEMP_MINtoTEMP_MAX, just do:where
#define Y_MAX (600). Similarly for the x-coordinate. This isn’t tested, so you may need to modify it slightly to deal with the edge-case (temps[i] == TEMP_MAX) properly.