This took a ridiculous amount of time to hack together, but here’s a Common Lisp function to decide the shortest angle between two other angles. It’s used in the example of seeking a point above. I can now add noise to this to make a more AARON-style pen.

(defun shortest-angle-difference (a1 a2)
  "Find the shortest positive or negative distance between two angles."
  ;; This was slowly assembled from various online sources, none of which worked
  ;; Normalize angles to 0..2pi
  (let ((from (mod a1 +radian+))
        (to (mod a2 +radian+)))
      ;; If from and to are equal (0 = 2pi radians) the angle is zero
      (if (or (= from to)
              (= (+ from to) +radian+))
          (let ((angle (- to from)))
            (if (> (abs angle) pi)
                ;; Please simplify me
                (* (- (signum angle)) (- +radian+ (abs angle)))
Posted in Art Computing, Generative Art, Projects

In Archive