1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10; Package: photo -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: convert.lisp
6 ;;;; Purpose: Conversions functions for cl-photo
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: April 2005
12 ;;;; This file, part of cl-photo, is Copyright (c) 2005 by Kevin M. Rosenberg
14 ;;;; cl-photo users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the GNU General Public License v2
16 ;;;; (http://www.gnu.org/licenses/gpl.html)
18 ;;;; *************************************************************************
22 (defconstant +radian->degrees+ (/ 360d0 pi 2))
23 (defconstant +inches->mm+ 25.4d0)
25 (declaim (inline diagonal))
27 (sqrt (+ (* x x) (* y y))))
29 (declaim (inline radians->degrees))
30 (defun radians->degrees (r)
31 (* +radian->degrees+ r))
33 (declaim (inline degrees->radians))
34 (defun degrees->radians (r)
35 (/ r +radian->degrees+))
37 (declaim (inline mm->feet))
39 (/ d +inches->mm+ 12))
41 (declaim (inline feet->mm))
43 (* d 12 +inches->mm+))
45 (declaim (inline inches->mm))
49 (declaim (inline mm->inches))
53 (defun length->mm (d units)
54 "Convert a length in units to mm."
57 (:inches (inches->mm d))
58 (:feet (* 12 (inches->mm d)))
59 (:yards (* 36 (inches->mm d)))
60 (:meters (* 1000 d))))
62 (defun mm->length (d units)
63 "Convert a number of mm to units."
66 (:inches (mm->inches d))
67 (:feet (/ (mm->inches d) 12))
68 (:yards (/ (mm->inches d) 36))
69 (:meters (/ d 1000))))