]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/lily-library.scm
Issue 4634: Simplify coord-rotate
[lilypond.git] / scm / lily-library.scm
index c5bf8cc59de12066e1f4bbf7e6aa88e321ef883e..0bfce9eb0c8a748099b3af053cf29d822de8a4b6 100644 (file)
@@ -707,20 +707,13 @@ right (@var{dir}=+1)."
 (define-public (coord-scale coordinate amount)
   (coord-operation * amount coordinate))
 
-(define-public (coord-rotate coordinate degrees-in-radians)
-  (let*
-      ((coordinate
-        (cons
-         (exact->inexact (coord-x coordinate))
-         (exact->inexact (coord-y coordinate))))
-       (radius
-        (sqrt
-         (+ (* (coord-x coordinate) (coord-x coordinate))
-            (* (coord-y coordinate) (coord-y coordinate)))))
-       (angle (angle-0-2pi (atan (coord-y coordinate) (coord-x coordinate)))))
-    (cons
-     (* radius (cos (+ angle degrees-in-radians)))
-     (* radius (sin (+ angle degrees-in-radians))))))
+(define-public (coord-rotate coordinate angle)
+  (let ((c (cos angle))
+        (s (sin angle))
+        (x (coord-x coordinate))
+        (y (coord-y coordinate)))
+    (cons (- (* c x) (* s y))
+          (+ (* s x) (* c y)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; trig