I have recently been working on a game with using OpenGL and C++ through GLFW.
In the game I have an airship with a turret mounted on it. The airship moves around in world space coordinates and the turret 'follows' it.
The turret has it's own coordinate space for its look/aim direction. Basically, when the turret aims in direction (0,0,1)
, it aims parallel to the airships direction of movement.
To give the turret a world space target, I have a matrix that takes world space coordinates and transforms these to turret space coordinates.
As the turret fires, I want it to spawn projectiles in world space, so is there an elegant way of using my transformation matrix to convert turret space coordinates back to world space?
A more general way of asking the question might be: if I have a matrix M
that takes coordinates from space A
to space B
. Is there an easy way to use M
to get the coordinates from B
to A
?