From: Ian Jackson Date: Tue, 2 May 2023 14:43:45 +0000 (+0100) Subject: funcs: Add rotate2d X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=reprap-play.git;a=commitdiff_plain;h=89f155e11afb2def86198b8c177210aa4efd88ca funcs: Add rotate2d (found) Signed-off-by: Ian Jackson --- diff --git a/funcs.scad.cpp b/funcs.scad.cpp index 5857c93..c34d157 100644 --- a/funcs.scad.cpp +++ b/funcs.scad.cpp @@ -24,6 +24,9 @@ function determinant2(m) = (m[0][0] * m[1][1] - m[0][1] * m[1][0]); function clockwise2d(v) = [v[1], -v[0]]; +function rotate2d(theta, v) = [ v[0] * cos(theta) - v[1] * sin(theta), + v[1] * cos(theta) + v[0] * sin(theta) ]; + // intersection of lines p1..p2 and p3..p4 function line_intersection_2d(p1,p2,p3,p4) = [ // from https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Given_two_points_on_each_line