Imagine the following rectangle A and B lozenge:
Rectangle A has the dimensions 4200 by 3000. The B lozenge has the maximum dimensions of 167 by 167, its sides having 98 by 98.
Rectangle A is equivalent to diamond B, so I would like to know (a generic formula) how to pass any point of A, eg P (500, 400) to B.
Considering the translation, rotation and scale between A and B. If possible using JavaSript in the formula;
For the scale I am using a simple 3 rule.
I found this formula for rotation:
function rotacionar(x, y, radianos) {
var graus = radianos * Math.PI / 180;
var seno = Math.sin(graus);
var coseno = Math.cos(graus);
x += 98;
return {
x: parseInt(x * coseno + y * seno),
y: parseInt(y * coseno - x * seno)
}
}
I just do not know how to put it all together and give the exact point.
Note: It is to use in Phaser.IO for the user to move around the map (A = pixels and B = places where he can walk)