I'm trying to understand the answer (copy/pasted below) that is laid out here: https://stackoverflow.com/a/3838294/1541165
The problem is that it's in C++ and I want to apply the described solution in PHP.
Can someone help with just a bit of the translation? Like what would A.x - B.x
look like in PHP?
first step; move the origin point.
x' = A.x - B.x y' = A.y - B.y
second step, perform rotation
x'' = x' * cos(C) - y' * sin(C) = (A.x-B.x) * cos(C) - (A.y-B.y) * sin(C)
y'' = y' * cos(C) + x' * sin(C) = (A.y-B.y) * cos(C) + (A.x-B.x) * sin(C)
third and final step, move back the coordinate frame
x''' = x'' + B.x = (A.x-B.x) * cos(C) - (A.y-B.y) * sin(C) + B.x
y''' = y'' + B.y = (A.y-B.y) * cos(C) + (A.x-B.x) * sin(C) + B.y
And presto! we have our rotation formula. I'll give it to you without all those calculations:
Rotating a point A around point B by angle C
A.x' = (A.x-B.x) * cos(C) - (A.y-B.y) * sin(C) + B.x
A.y' = (A.y-B.y) * cos(C) + (A.x-B.x) * sin(C) + B.y