Rotating A Point In 2D In Lua
From GPWiki
-- math.cos and math.sin expect a radian value, and this little function converts degrees to radians toRadians = function(degrees) return degrees / 180 * math.pi end function rotatePoint(point, origin, degrees) local x = origin.x + ( math.cos(toRadians(degrees)) * (point.x - origin.x) - math.sin(toRadians(degrees)) * (point.y - origin.y) ) local y = origin.y + ( math.sin(toRadians(degrees)) * (point.x - origin.x) + math.cos(toRadians(degrees)) * (point.y - origin.y) ) point.x = x point.y = y end