Maths Alert!
A bit of background is needed on this one: I was attempting to take a bunch of coordinates and rotate them around a circle on the z axis. Simple. No, it’s not when you know how to do the maths (matrix based rotations) on paper, but you have no idea how to apply the maths knowledge to a programmatic solution. After lots of searches of functions that looked extremely complicated and feature rich (I wanted simple, one function code), I finally discovered the answer:
x1 = cos(angle)*x - sin(angle)*y; y1 = sin(angle)*x + cos(angle)*y;
What this basically does it take your two points, x and y, and rotate them by the amount given as angle, storing the new values in x1 and y1. You need to have x and y to begin with, as it needs something to rotate.