0
Imagine the following rectangle A and rhombus B:
Rectangle A has dimensions 4200 by 3000. Rhombus B has the maximum dimensions of 167 by 167, its sides have 98 by 98.
Rectangle A is equivalent to rhombus B, so I would like to know (a generic formula) how to pass any point of A, ex: P(500, 400) to B.
Taking into account the translation, rotation and scale between A and B. If possible using Javasript in the formula;
For the scale I’m using a simple rule of 3.
I found this formula for the spin:
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 don’t know how to put it all together.
Note: It is to use in Phaser.IO for the user to walk through the map (A = pixels and B = places where he can walk)
I don’t think that question is part of scope of the site.
– user28595
Exactly. The way the question is, it’s not part of the scope because it’s essentially a math problem. Try to at least provide example of Javascript code that you have already done and tried, which then maybe more easily enter the scope of the site.
– Luiz Vieira
That’s better?
– Érycson Nóbrega
The additional correct tag for your question would be computer graphics.
– user1084
I didn’t find this tag to add
– Érycson Nóbrega