]> git.jsancho.org Git - dungeon-master.git/blob - dungeon-master/geom.scm
Make regions from the Delaunay triangulation
[dungeon-master.git] / dungeon-master / geom.scm
1 (define-module (dungeon-master geom)
2   #:use-module (dungeon-master geom point)
3   #:export (angle-sign))
4
5
6 (define (angle-sign center a b)
7   "Return the sign of (- (atan (- a center))
8                          (atan (- b center)))"
9   (let ((x1 (- (point-x a) (point-x center)))
10         (y1 (- (point-y a) (point-y center)))
11         (x2 (- (point-x b) (point-x center)))
12         (y2 (- (point-y b) (point-y center))))
13     (cond ((and (>= x1 0) (< x2 0))
14              1)
15           ((and (>= x2 0) (< x1 0))
16              -1)
17           ((and (= x1 0) (= x2 0))
18            (if (> y2 y1) 1 -1))
19           (else
20            (if (> (- (* x2 y1) (* x1 y2)) 0) 1 -1)))))