To rotate an object A degrees around point P:
Set 'distance' to distance(Object.X, Object.Y, P.X, P.Y)
Set 'angle' to angle(Object.X, Object.Y, P.X, P.Y)
Set X to P.X + cos(angle + A) * distance
Set Y to P.Y + sin(angle + A) * distance
Haven't checked that but I think it's right...