]> git.jsancho.org Git - dungeon-master.git/blobdiff - dungeon-master/geom/point.scm
Voronoi mesh relax
[dungeon-master.git] / dungeon-master / geom / point.scm
index 64faaac44a4c7b8e3272a463071418ce6bebea50..3f471eb9fa706efac47d2349b99e2b4ce1ad4bf9 100644 (file)
@@ -4,7 +4,9 @@
             point?
             point-x
             point-y
-           points-distance))
+           points-distance
+            sum-points
+            scale-point))
 
 (define-record-type <point>
   (make-point x y)
   (abs
    (sqrt (+ (expt (- (point-x p1) (point-x p2)) 2)
             (expt (- (point-y p1) (point-y p2)) 2)))))
+
+(define (sum-points . points-to-sum)
+  (let loop ((points points-to-sum)
+             (x 0)
+             (y 0))
+    (cond ((null? points)
+           (make-point x y))
+          (else
+           (loop (cdr points)
+                 (+ x (point-x (car points)))
+                 (+ y (point-y (car points))))))))
+
+(define (scale-point point scale)
+  (make-point
+   (* (point-x point) scale)
+   (* (point-y point) scale)))