Commit 24dff6bc authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Optionally do not rationalize conversion factors

Optionally do not rationalize conversion factors. This has been
selected for angles that involve pi.
parent 7f91e263
;; Definitions of units and dimensions.
;; Liam Healy Fri Mar 1 2002 - 15:34
;; Time-stamp: <2011-01-30 18:34:56EST unit-definitions.lisp>
;; Time-stamp: <2015-04-20 12:45:08EDT unit-definitions.lisp>
;; Copyright 2011 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -211,10 +211,10 @@
`((radian 1.0 (rad radians) "rad")
(steradian 1.0 (sr steradians))
(degree (/ ,pi 180)
(,(antik-symbol *degree-symbol*) deg degrees) (,*degree-symbol* "\\dgr"))
(arcminute (/ degree 60) (arcmin arcminutes arc-minute arc-minutes))
(arcsecond (/ arcminute 60) (arcsec arcseconds arc-second arc-seconds))
(revolution (* 2 ,pi) (rev orbit))))
(,(antik-symbol *degree-symbol*) deg degrees) (,*degree-symbol* "\\dgr") nil)
(arcminute (/ degree 60) (arcmin arcminutes arc-minute arc-minutes) nil)
(arcsecond (/ arcminute 60) (arcsec arcseconds arc-second arc-seconds) nil)
(revolution (* 2 ,pi) (rev orbit) nil)))
;;;; Derived units
;; Define physical dimensions and units of measure and systems of units.
;; Liam Healy Wed Feb 27 2002 - 13:18
;; Time-stamp: <2015-04-06 22:49:09EDT units.lisp>
;; Time-stamp: <2015-04-20 12:51:32EDT units.lisp>
;; Copyright 2011, 2013, 2015 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -509,7 +509,7 @@
(check-uname new new)
(dolist (s names) (check-uname new s)))
(defun define-unit (unit definition &optional synonyms print-name dimension)
(defun define-unit (unit definition &optional synonyms print-name dimension (rationalize t))
"Define the unit. If the definition is a number then the dimension
information will be extracted from dimension."
;; Check if name/synonym is already defined.
......@@ -522,7 +522,12 @@
(setf (dimension unit)
;; if dimension is given, use it; otherwise, derive from expression
(if dimension (parse-unit-sexp dimension) derived-dim)
(siconversion unit) (if conversion (rationalize conversion) 1)
(siconversion unit)
(if conversion
(if rationalize
(rationalize conversion)
(synonyms unit) (pushnew (unit-remove-illegal-chars unit) synonyms)
(print-name unit) print-name
(canonical-name unit) unit)
......@@ -534,8 +539,9 @@
"Define the units given. The second argument is a list of lists, each
consisting of a unit name, its definition, and a list of synonyms."
(dolist (uda unit-def-syn-pnm)
(destructuring-bind (units definition &optional synonyms print-name) uda
(define-unit units definition synonyms print-name dimension))))
(destructuring-bind (units definition &optional synonyms print-name (rationalize t))
(define-unit units definition synonyms print-name dimension rationalize))))
(defparameter *unit-symbol-macros* nil
"Unit symbols that were defined with unit-symbol-macro.")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment