2:1 Diametric rotation matrix for a 2D orthographic projection

286 Views Asked by At

I asked this question in the game dev stack exchange, but didn't get a response. This is more of a math question with an application in game development so I hope it's alright if I ask here.

I'm trying to implement a 2D isometric game, well diametric with a 2:1 pixel ratio. To do this I have a 2D image of a cube I drew with pixel editing software, where for every pixel up, there are two pixels to the right. I'd like to post an image of it but I don't have the reputation for it. It looks something like this. From what I read this is called dimetric projection, and is composed of two axis rotations, one is 45 degrees about the x axis and the other one is arctan(1/2) around the z. Here is some more detail.

I tried to calculate the rotation matrix, but when I use this to convert an (x,y,z) in Cartesian coordinates to isometric world space coordinates(x`,y`,z`) the cube images do not align correctly with each other, leading me to believe I am missing something else to this problem, or my math is wrong. I have found ways online to fudge it, but they all ignore the z axis which I require. I'm not sure if I did my rotation matrix correctly but here it is:

$$ \begin{bmatrix} 1/\sqrt{2} & 0 & -1/\sqrt(2) \\ 1\sqrt{10} & 2/\sqrt{5} & -1/\sqrt{10} \\ -1\sqrt{2/5} & 1/\sqrt{5} & \sqrt{2/5} \\ \end{bmatrix} $$

Edit: I can now upload pictures of what I have working, notice how the images are offset. The blue coordinates are the Cartesian positions before the isometric transformations.

Iso projection