Skip to content

Commit 24a48fd

Browse files
authored
Fix rotate around custom center
1 parent bcd1a0e commit 24a48fd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/ILL/ILL/Ass/Shape/Point.moon

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ class Point
5050

5151
-- Rotate the object according the given params.
5252
rotate: (angle, c = Point!) =>
53-
{:x, :y} = @
54-
@x = x * math.cos(angle) - y * math.sin(angle)
55-
@y = x * math.sin(angle) + y * math.cos(angle)
53+
x_rel = @x - c.x
54+
y_rel = @y - c.y
55+
@x = x_rel * math.cos(angle) - y_rel * math.sin(angle) + c.x
56+
@y = x_rel * math.sin(angle) + y_rel * math.cos(angle) + c.y
5657
return @
5758

5859
-- Rotate the object according the given params.
@@ -204,4 +205,4 @@ class Point
204205
py = a.y + u * (b.y - a.y) + v * (d.y - a.y) + u * v * (a.y - b.y + c.y - d.y)
205206
return Point px, py
206207

207-
{:Point}
208+
{:Point}

0 commit comments

Comments
 (0)