inconsistency functions angle-between-vectors and angle-between-vectors-d
Created by: reiniervandijk
1581: there is inconsistency between functions geom-base:angle-between-vectors and geom-base:angle-between-vectors-d. They should have the same arglist, however they don't. Names differ, use of optional / key differs, but most importantly: geom-base:angle-between-vectors-d does not have an epsilon input. I guess you won't expect the user to go for let-binding zero-epsilon approach, right? :)
By genworks on 2015-01-29 23:16:15 UTC
Open for submissions: $100.
Any changes here have to be done in such a way to support legacy code without rewriting it.
By reiniervandijk on 2015-01-30 12:36:40 UTC
Code below makes
angle-between-vectors-d compatible with
angle-between-vectors. The function still supports legacy code that invokes
(vector-1 vector-2 &optional reference-vector negative?), and prints an optional warning message. Different note,
angle-between-vectors contained a bug on its own, will open (and close) in new thread.
(in-package :geom-base) (defparameter *print-deprecated-warnings?* nil) (defun angle-between-vectors-d (vector-1 vector-2 &optional reference-vector &rest more) "Number. This function is identical to angle-between-vectors, but returns the angle in degrees. Refer to angle-between-vectors for more information. Technical note: the <b>more</b> argument has been introduced to support both angle-between-vectors call conventions and the legacy signature: (vector-1 vector-2 &optional reference-vector negative?) Optionally, a deprecation warning is printed when code invokes this legacy pattern.." ;; resolve &rest arguments. (let ((arglist (let ((L (length more))) (cond ((= L 1) ;; legacy signature: ;; (vector-1 vector-2 &optional reference-vector negative?) (when *print-deprecated-warnings?* (warn "negative? argument for angle-between-vectors-d is deprecated. Use :-ve instead.")) (list vector-1 vector-2 reference-vector :-ve (first more))) ((evenp L) ;; angle-between-vectors signature: ;; (vector-1 vector-2 &optional reference-vector &key (epsilon *zero-epsilon*) -ve) (nconc (list vector-1 vector-2 reference-vector) more)) (t ;; not allowed. (error (format nil "angle-between-vectors-d received invalid arguments: ~a" (nconc (list vector-1 vector-2 reference-vector) more)))))))) (radians-to-degrees (apply #'angle-between-vectors arglist)) ))
By reiniervandijk on 2015-01-30 15:40:58 UTC
Small remark: use of
nconc is safe here. If you don't want it, use
By genworks on 2015-03-11 19:59:17 UTC
Merged slightly modified version of this fix into devo branch.