1 ;;; Dungeon Master --- Adventure generator for GNU Guile
2 ;;; Copyright © 2019 Javier Sancho <jsf@jsancho.org>
4 ;;; Dungeon Master is free software; you can redistribute it and/or modify it
5 ;;; under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation; either version 3 of the License, or
7 ;;; (at your option) any later version.
9 ;;; Dungeon Master is distributed in the hope that it will be useful, but
10 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ;;; General Public License for more details.
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with Haunt. If not, see <http://www.gnu.org/licenses/>.
18 (define-module (dungeon-master geom)
19 #:use-module (dungeon-master geom point)
20 #:export (angle-sign))
23 (define (angle-sign center a b)
24 "Return the sign of (- (atan (- a center))
26 (let ((x1 (- (point-x a) (point-x center)))
27 (y1 (- (point-y a) (point-y center)))
28 (x2 (- (point-x b) (point-x center)))
29 (y2 (- (point-y b) (point-y center))))
30 (cond ((and (>= x1 0) (< x2 0))
32 ((and (>= x2 0) (< x1 0))
34 ((and (= x1 0) (= x2 0))
37 (if (> (- (* x2 y1) (* x1 y2)) 0) 1 -1)))))