In the following code:
Point p = a[1]; center of rotation
for (int i = 0; I<4; i++)
{
int x = a[i].x - p.x;
int y = a[i].y - p.y;
a[i].x = y + p.x;
a[i].y = - x + p.y;
}
I am understanding that a 90 degree shift results in a change like:
xNew = -y
yNew = x
Could someone please explain how the two additions and subtractions of the p.x and p.y works?
Thank you,
Josheir
↧