I have a point in the following coordinate system:
Java AWT:
0,0|------------------------|
| |
| (middle p. 400,300) |
| |
|------------------------|800,600
and I want to convert it to the following system:
OpenGL
50,50|------------------------|
| |
| (middle p. 0,0) |
| |
|------------------------|-50,-50
Any idea how can I do it?
In general, what you want to do is convert from a (rectangular) coordinate system
Ato coordinate systemB.First map the source coordinate system,
Ato a normalized range[0, 1]:Where
(x0, y0)is the top left corner and(x1, y1)is the bottom right corner. Then map it to the new coordinate system:Where
(X0, Y0)is the top left corner of your new coordinate system and(X1, Y1)is the bottom right corner of the new coordinate system.This will work for any two rectangular coordinate systems.