Skip to content

Commit

Permalink
Add angle-distance
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Feb 19, 2024
1 parent 6d2e259 commit b2b27ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,7 @@
#:rad->deg
#:db
#:angle-midpoint
#:angle-distance
#:clamp-angle
#:lerp-angle
#:symbol->c-name
Expand Down
4 changes: 4 additions & 0 deletions toolkit.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,10 @@
(when (< PI (- b a)) (decf b F-2PI))
(mod (/ (+ b a) 2) F-2PI))

(defun angle-distance (a b)
(let ((da (mod (- b a) F-2PI)))
(- (mod (* 2 da) F-2PI) da)))

(defun clamp-angle (min a max)
(flet ((normalize-180 (a)
(- (mod (+ a F-PI) F-2PI) F-PI)))
Expand Down

0 comments on commit b2b27ec

Please sign in to comment.