TeamSweepy / Greywater

Repo for Greywater Isometric RPG
2 stars 0 forks source link

Isometric Transform #10

Closed Jeremy-Barnes closed 10 years ago

Jeremy-Barnes commented 10 years ago

I'm altering the toNormalCoord method in Globals (formerly in Camera) because the math doesn't seem to check out.

Robin, that method was yours, can you verify where that math came from or show me how I'm wrong? It should be the exact inverse of toIsoCoord, right?

For reference, the toIsoCoord method (which is correct) is:

float x = xCoord - yCoord;
float y = (xCoord + yCoord) / 2;

The toNormalCoord method used to be (and I think this math is bad, but please everyone double check me):

float x = (2 * xIso + yIso) / 2;
float y = (2 * yIso - xIso) / 2;

My proposed change is this:

float x = xIso/2 - yIso;
float y = yIso - xIso/2;
Jeremy-Barnes commented 10 years ago
//from toIsoCoord
xIso = xCoord - yCoord;
yIso = (xCoord + yCoord)/2

//from toNormalCoord
xCoord = xIso + yCoord
yCoord = 2*yIso - xCoord

//solve
xCoord = xIso + 2yIso - xCoord
2*xCoord = xIso + 2yIso
xCoord = xIso/2 + yIso

yCoord = 2*yIso - xCoord
yCoord = 2*yIso - xIso/2 - yIso
yCoord = yIso - xIso/2

Thats the system of equations I used to get to my proposed change. It may very well be wrong, everyone should input here because I'm not the best at math.

Biodiscus commented 10 years ago

Yup, my bad. I did fix it, but forgot to commit it.

Jeremy-Barnes commented 10 years ago

Okay, cool. I thought I was going crazy. Thanks!