Pixel-Composer/scripts/point_rotate/point_rotate.gml

14 lines
337 B
Plaintext
Raw Normal View History

2022-01-13 05:24:03 +01:00
function point_rotate(px, py, ox, oy, a) {
2023-09-09 13:52:16 +02:00
gml_pragma("forceinline");
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)];
}