I’m manipulating a 2D map with basic sin and cos quite successfully to give a 3d perspective.
The issue I’m having is I’m stuck trying to find what is visible in the viewport.
Effectively doing the transformation in reverse, the output is [0,0] and [width,height] and I want to know where on my map those points lie.
I’ve got it to the point of trying to reverse:
display_x = (source_x * cos(z)) + (source_y * sin(z))
display_y = (source_y * cos(z)) - (source_x * sin(z))
If I know display_x and display_y and source_x and source_y are the unknowns, how can I solve what the unknowns are?
My simultaneous equation knowledge is a little rusty.
You’re effectively using a 2d rotation matrix
(I’m pretty sure you have a typo where you swapped source_x for source_y in the definition of display_y)
http://en.wikipedia.org/wiki/Rotation_matrix
all you need to do to invert this matrix is find it’s transpose (flipped over the diagonal) because it’s guaranteed to be orthogonal.
so it should be: