I’m trying to convert a normalized unit vector, representing an entity heading, into a rotation matrix for rendering.
The problem is that I’m using an (apparently) unusual forward vector for my entities. I use right-hand axes, with +Z pointing up and +Y pointing forward. (Rationale: My game has units moving across a map, and it’s easier for me to deal with the map as X/Y positions with a +Z height)
Whenever I try to look up the math for building the rotation matrix, the examples always assume my forward vector is +X, which gives the wrong result. The math assumes my entity is facing +X, and so my entities look like they’re moving sideways.
I’ve also tried a (temporary) 2D approach using atan2, but again it assumes angle 0 (forward) is +X, with the same result.
How does the math for a “look rotation” matrix work for an arbitrary axis? Or, if it’s easier, are there examples of building this sort of matrix using a right-hand +Y axis?