1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Is your ultimate goal to compute an appropriate projection matrix? $\endgroup$ – amd Dec 8 '18 at 1:20
  • $\begingroup$ That is correct @amd $\endgroup$ – Ziamor Dec 8 '18 at 1:26
  • $\begingroup$ Can you first scale so the 2 to 1 pixel complication is removed from the problem? Then reformulate based on that? Are you wanting to rotate the cube about its center? Can you express as two successive rotations (factoring)? $\endgroup$ – John L Winters Dec 8 '18 at 1:53
  • $\begingroup$ Would you be able to elaborate about the scaling first part? I have enough rep now to upload images so I added a picture to help better visualize my problem. The cube also isn't truly a cube, it's an 2D image in 3d space. @JohnLWinters $\endgroup$ – Ziamor Dec 8 '18 at 2:34
  • $\begingroup$ Yes I voted for your question. Pretend you have a 1 to 1 pixel instead of a 2 to 1 to simplify and focus on the rotations. $\endgroup$ – John L Winters Dec 8 '18 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.