Pixel-Composer/scripts/point_rotate/point_rotate.gml

12 lines
307 B
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
function point_rotate(px, py, ox, oy, a) {
2023-02-23 07:02:19 +01:00
a = angle_difference(a, 0);
if(a == 0) return [ px, py ];
if(a == 180) return [ ox + (ox - px), oy + (oy - py) ];
2022-01-13 05:24:03 +01:00
var cx = px - ox;
var cy = py - oy;
var d = -degtorad(a);
return [ox + cx * cos(d) - cy * sin(d),
oy + cx * sin(d) + cy * cos(d)];
}