X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=convert.lisp;h=f663cf8fc98e1651357ea99a0cc8edb70b8ded8f;hb=d01611bf419081fd99767c816a4603496b0da247;hp=f6daab1836fce334f8652dd5fdaca3ea06fb6355;hpb=aa668443cbb520ebd5dd1d007c19aab2316562e5;p=cl-photo.git diff --git a/convert.lisp b/convert.lisp index f6daab1..f663cf8 100755 --- a/convert.lisp +++ b/convert.lisp @@ -9,8 +9,11 @@ ;;;; ;;;; $Id$ ;;;; -;;;; This file, part of cl-photo, is Copyright (c) 2005 by Kevin Rosenberg. -;;;; Rights of modification and redistribution are in the LICENSE file. +;;;; This file, part of cl-photo, is Copyright (c) 2005 by Kevin M. Rosenberg +;;;; +;;;; cl-photo users are granted the rights to distribute and use this software +;;;; as governed by the terms of the GNU General Public License v2 +;;;; (http://www.gnu.org/licenses/gpl.html) ;;;; ;;;; ************************************************************************* @@ -43,6 +46,28 @@ (defun inches->mm (d) (* d +inches->mm+)) +(declaim (inline mm->inches)) +(defun mm->inches (d) + (/ d +inches->mm+)) + +(defun length->mm (d units) + "Convert a length in units to mm." + (ecase units + (:mm d) + (:inches (inches->mm d)) + (:feet (* 12 (inches->mm d))) + (:yards (* 36 (inches->mm d))) + (:meters (* 1000 d)))) + +(defun mm->length (d units) + "Convert a number of mm to units." + (ecase units + (:mm d) + (:inches (mm->inches d)) + (:feet (/ (mm->inches d) 12)) + (:yards (/ (mm->inches d) 36)) + (:meters (/ d 1000)))) + (defun format-dimensions (format) "Returns format dimensions in mm." (ecase format