Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 26 lines (19 sloc) 1.008 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
(in-package :2d-geometry)

;;; Treat polygons as immutable object, construct all representations

(defclass polygon ()
  ((point-list :reader point-list :initarg :point-list)
   (edge-list :reader edge-list :initarg :edge-list)
   (point-ring :reader point-ring :initarg :point-ring)))

(defmethod print-object ((object polygon) stream)
  (print-unreadable-object (object stream :type t :identity t)
    (format stream "[~a]" (length (edge-list object)))))

(defun make-polygon-from-point-list (point-list)
  (make-instance 'polygon
                 :point-list (copy-seq point-list)
                 :edge-list (edge-list-from-point-list point-list)
                 :point-ring (double-linked-ring-from-point-list point-list)))

(defun make-polygon-from-coords (&rest coord-list)
  (make-polygon-from-point-list (apply #'coords-to-points coord-list)))

(defun make-polygon-from-point-ring (point-ring)
  (let ((point-list (point-list-from-ring point-ring)))
    (make-polygon-from-point-list point-list)))
Something went wrong with that request. Please try again.