I have a grid at which I place an object I want to rotate right around a fixed cell (cell3). The object contains coordinates, like:
activeObject = {
coords: {
cell1: {
x: 0,
y: 0
},
cell2: {
x: 1,
y: 1
},
cell3: {
x: 2,
y: 2
},
cell4: {
x: 2,
y: 3
},
cell5: {
x: 3,
y: 3
},
}
}
Output:
I want to rotate this object around cell3 e.g. using x: 2, y: 2 without hard coding each cell position using some kind of (basic) trigonometry. I realize that I have to check how far is each cell from cell3, and the orientation. But I don't know how to do the calculation as I am not so good with trigonometry. The new active object would be:
activeObject = {
coords: {
cell1: {
x: 4,
y: 0
},
cell2: {
x: 4,
y: 1
},
cell3: {
x: 2,
y: 2
},
cell4: {
x: 1,
y: 2
},
cell5: {
x: 1,
y: 3
},
}
}
Output: