From ba97d2928ec3d15f2baacd41e3e8455b81b5932f Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Sun, 9 Jul 2023 16:26:28 -0400 Subject: Implement `region rotate` helper --- virtual-programs/regions.folk | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'virtual-programs') diff --git a/virtual-programs/regions.folk b/virtual-programs/regions.folk index 10684a59..b1cf45a0 100644 --- a/virtual-programs/regions.folk +++ b/virtual-programs/regions.folk @@ -127,6 +127,17 @@ namespace eval ::region { vec2 scale $vecsum 0.25 } + proc rotate {r angle} { + set theta [angle $r] + set c [centroid $r] + mapVertices v $r { + set v [vec2 sub $v $c] + set v [vec2 rotate $v $angle] + set v [vec2 add $v $c] + set v + } + } + # Scales about the center of the region, along the x and y axes of # the space of the region (not the global x and y). proc scale {r args} { -- cgit v1.2.3