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 point)
19 #:use-module (srfi srfi-9)
28 (define-record-type <point>
34 (define (points-distance p1 p2)
36 (sqrt (+ (expt (- (point-x p1) (point-x p2)) 2)
37 (expt (- (point-y p1) (point-y p2)) 2)))))
39 (define (sum-points . points-to-sum)
40 (let loop ((points points-to-sum)
47 (+ x (point-x (car points)))
48 (+ y (point-y (car points))))))))
50 (define (scale-point point scale)
52 (* (point-x point) scale)
53 (* (point-y point) scale)))