If I have a 3x3 grid and scale it to 9x9 how should I calculate the new coordinates of given points going from the 3x3 to 9x9.
See image for more info
e.g.
- Point A coordinates: (2,1) in 3x3 grid. After scaling to 9x9 the coordinate should be (5,1).
- Point B coordinates: (2,2) in 3x3 grid. After scaling to 9x9 the coordinate should be (5,5).
CodePudding user response:
As long as we know the maximum and minimum values, max and min respectively, of our current space then this is quite nice to do.
Say we have a point with x as its x-axial value and want to scale the coordinate to be between a new range of new_max and new_min, we can use
f(x)=(new_max-new_min)*((x-min)/(max-min)) new_min
which will return the point's x coordinate value scaled to your desired range.
Do this for all points, for both the x and y-axis and you're golden