Please disregard my code from comment #1, it's fishy.
More appropiate would be (dropping the idea to rotate around other ponts
than zero):

#(define (get-PI/4-rotated-quadrants radians)
  (cond ((>= radians TWO-PI)
         (get-PI/4-rotated-quadrants (- radians TWO-PI)))
        ((< radians 0)
         (get-PI/4-rotated-quadrants (+ radians TWO-PI )))
        (else
          (let* (;; get the octants
                 (oct (truncate (/ radians (/ PI 4)))))
            ;; get the rotated quadrants
            (cond ((= oct 7) 0)
                  ((even? oct)
                   (/ oct 2))
                  (else (/ (1+ oct) 2)))))))

(define-public (coord-rotate-p-II coordinate angle-in-radians)
  ;; getting around (sin PI) not being exactly zero by switching to cos
at
  ;; appropiate angles and/or taking the negative value (vice versa for
cos)
  (let* ((angle (angle-0-2pi angle-in-radians))
         (quadrant (get-PI/4-rotated-quadrants angle))
         (moved-angle (- angle (/ (* quadrant PI) 2)))
         (cm (cos moved-angle))
         (sm (sin moved-angle))
         (c (cond ((= 1 quadrant) (- sm))
                  ((= 2 quadrant) (- cm))
                  ((= 3 quadrant) sm)
                  (else cm)))
         (s (cond ((= 1 quadrant) cm)
                  ((= 2 quadrant) (- sm))
                  ((= 3 quadrant) (- cm))
                  (else sm)))
         (x (coord-x coordinate))
         (y (coord-y coordinate)))
    (cons (- (* c x) (* s y))
          (+ (* s x) (* c y)))))


Maybe in a follow up?
The patch itself LGTM

https://codereview.appspot.com/263690043/

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to