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))))
71 (defun format-dimensions (format)
72 "Returns format dimensions in mm."
74 (:aps-c (cons 22.7 15.1))
75 ((:aps :dx) (cons 24 16))
76 ((:35 :35mm) (cons 36 24))
77 ((:645 :6x4.5cm) (cons 60 45))
78 ((:6x6 :6x6cm) (cons 60 60))
79 ((:6x7 :6x7cm) (cons 60 70))
80 ((:6x9 :6x9cm) (cons 60 90))
81 ((:4x5 :4x5in) (cons (* 4 +inches->mm+) (* 5 +inches->mm+)))
82 ((:5x7 :5x7in) (cons (* 5 +inches->mm+) (* 7 +inches->mm+)))
83 ((:8x10 :8x10in) (cons (* 8 +inches->mm+) (* 10 +inches->mm+)))
84 (:11x13.75in (cons (* 11 +inches->mm+) (* 13.75 +inches->mm+)))
85 (:11x16.5in (cons (* 11 +inches->mm+) (* 16.5 +inches->mm+)))
86 (:13x19in (cons (* 13 +inches->mm+) (* 19 +inches->mm+)))
87 (:16x20in (cons (* 13 +inches->mm+) (* 19 +inches->mm+)))
88 (:16x24in (cons (* 13 +inches->mm+) (* 19 +inches->mm+)))
89 (:18x22.5in (cons (* 13 +inches->mm+) (* 19 +inches->mm+)))
90 (:18x24in (cons (* 13 +inches->mm+) (* 19 +inches->mm+)))
91 (:24x30in (cons (* 13 +inches->mm+) (* 19 +inches->mm+)))
92 (:24x36in (cons (* 13 +inches->mm+) (* 19 +inches->mm+)))