Original Post
Hello, I am trying to, as the title states, convert screen coordinates to world and vise versa. My camera is always in the middle of the screen and it can both rotate and translate. Compensating for the translation is easy, but computing the rotated coordinates has stumped me.
Here is what i have:
pos is the cameras position, and rot is it's rotation. My vectors are [x,y,z] but, for the time being, my engine will operate only in 2D.
What do i need to do to compute the coordinates when the camera is rotated about the z axis?
Thank You.
Here is what i have:
Vector Camera::ScreenPosToWorldPos(Vector &v) { Vector result; result = Vector(v.x + (pos.x - *screenwidth/2),v.y + (pos.y - *screenheight/2),pos.z); return result; } Vector Camera::WorldPosToScreenPos(Vector &v) { Vector result; result = v - pos; result.z = pos.z; return result; }pos is the cameras position, and rot is it's rotation. My vectors are [x,y,z] but, for the time being, my engine will operate only in 2D.
What do i need to do to compute the coordinates when the camera is rotated about the z axis?
Thank You.