chiark / gitweb /
poster-tube-lid: tidy
[reprap-play.git] / funcs.scad.cpp
index 92292bebc3db62a31cc802f2b1a0406815d65b95..c34d15707f8fa76e4db729c54fa9d850aa29edc8 100644 (file)
@@ -16,12 +16,17 @@ function vectorlen(v)   = sqrt(vsq(0) + vsq(1) + vsq(2));
 function unitvector2d(v) = v / vectorlen2d(v);
 function unitvector(v)   = v / vectorlen(v);
 
+function atan2vector(v) = atan2(v[1], v[0]);
+
 // | m[0][0] m[0][1] |
 // | m[1][0] m[1][1] |
 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