diff options
| author | Tino Calancha | 2016-07-12 00:38:14 +0900 |
|---|---|---|
| committer | Tino Calancha | 2016-07-12 00:38:14 +0900 |
| commit | 713e922243fb60d850f7b0ff83f3e2a3682f1832 (patch) | |
| tree | f604573b3fa2475cbc5014860dacbe7fe7461593 | |
| parent | 188fb3b58a17d566c2b0feabf8ec26c1eaa42c61 (diff) | |
| download | emacs-713e922243fb60d850f7b0ff83f3e2a3682f1832.tar.gz emacs-713e922243fb60d850f7b0ff83f3e2a3682f1832.zip | |
Ignore angle mode while simplifying units
* lisp/calc/calc-forms.el (math-to-hms, math-from-hms):
Ignore value of 'calc-angle-mode' when 'math-simplifying-units'
is non-nil (Bug#23889).
* lisp/calc/calc-math.el (math-to-radians, math-from-radians)
(math-from-radians-2, math-to-radians-2): Idem.
| -rw-r--r-- | lisp/calc/calc-forms.el | 12 | ||||
| -rw-r--r-- | lisp/calc/calc-math.el | 12 |
2 files changed, 17 insertions, 7 deletions
diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el index c94b89d6b10..153b90429ea 100644 --- a/lisp/calc/calc-forms.el +++ b/lisp/calc/calc-forms.el | |||
| @@ -317,7 +317,9 @@ | |||
| 317 | (list 'calcFunc-hms a)) | 317 | (list 'calcFunc-hms a)) |
| 318 | ((math-negp a) | 318 | ((math-negp a) |
| 319 | (math-neg (math-to-hms (math-neg a) ang))) | 319 | (math-neg (math-to-hms (math-neg a) ang))) |
| 320 | ((eq (or ang calc-angle-mode) 'rad) | 320 | ((eq (or ang |
| 321 | (and (not math-simplifying-units) calc-angle-mode)) | ||
| 322 | 'rad) | ||
| 321 | (math-to-hms (math-div a (math-pi-over-180)) 'deg)) | 323 | (math-to-hms (math-div a (math-pi-over-180)) 'deg)) |
| 322 | ((memq (car-safe a) '(cplx polar)) a) | 324 | ((memq (car-safe a) '(cplx polar)) a) |
| 323 | (t | 325 | (t |
| @@ -354,12 +356,16 @@ | |||
| 354 | (if (eq (car-safe a) 'sdev) | 356 | (if (eq (car-safe a) 'sdev) |
| 355 | (math-make-sdev (math-from-hms (nth 1 a) ang) | 357 | (math-make-sdev (math-from-hms (nth 1 a) ang) |
| 356 | (math-from-hms (nth 2 a) ang)) | 358 | (math-from-hms (nth 2 a) ang)) |
| 357 | (if (eq (or ang calc-angle-mode) 'rad) | 359 | (if (eq (or ang |
| 360 | (and (not math-simplifying-units) calc-angle-mode)) | ||
| 361 | 'rad) | ||
| 358 | (list 'calcFunc-rad a) | 362 | (list 'calcFunc-rad a) |
| 359 | (list 'calcFunc-deg a))))) | 363 | (list 'calcFunc-deg a))))) |
| 360 | ((math-negp a) | 364 | ((math-negp a) |
| 361 | (math-neg (math-from-hms (math-neg a) ang))) | 365 | (math-neg (math-from-hms (math-neg a) ang))) |
| 362 | ((eq (or ang calc-angle-mode) 'rad) | 366 | ((eq (or ang |
| 367 | (and (not math-simplifying-units) calc-angle-mode)) | ||
| 368 | 'rad) | ||
| 363 | (math-mul (math-from-hms a 'deg) (math-pi-over-180))) | 369 | (math-mul (math-from-hms a 'deg) (math-pi-over-180))) |
| 364 | (t | 370 | (t |
| 365 | (math-add (math-div (math-add (math-div (nth 3 a) | 371 | (math-add (math-div (math-add (math-div (nth 3 a) |
diff --git a/lisp/calc/calc-math.el b/lisp/calc/calc-math.el index 699ef6f49ae..567635eb65b 100644 --- a/lisp/calc/calc-math.el +++ b/lisp/calc/calc-math.el | |||
| @@ -763,12 +763,14 @@ If this can't be done, return NIL." | |||
| 763 | (defun math-to-radians (a) ; [N N] | 763 | (defun math-to-radians (a) ; [N N] |
| 764 | (cond ((eq (car-safe a) 'hms) | 764 | (cond ((eq (car-safe a) 'hms) |
| 765 | (math-from-hms a 'rad)) | 765 | (math-from-hms a 'rad)) |
| 766 | ((memq calc-angle-mode '(deg hms)) | 766 | ((and (not math-simplifying-units) |
| 767 | (memq calc-angle-mode '(deg hms))) | ||
| 767 | (math-mul a (math-pi-over-180))) | 768 | (math-mul a (math-pi-over-180))) |
| 768 | (t a))) | 769 | (t a))) |
| 769 | 770 | ||
| 770 | (defun math-from-radians (a) ; [N N] | 771 | (defun math-from-radians (a) ; [N N] |
| 771 | (cond ((eq calc-angle-mode 'deg) | 772 | (cond ((and (not math-simplifying-units) |
| 773 | (eq calc-angle-mode 'deg)) | ||
| 772 | (if (math-constp a) | 774 | (if (math-constp a) |
| 773 | (math-div a (math-pi-over-180)) | 775 | (math-div a (math-pi-over-180)) |
| 774 | (list 'calcFunc-deg a))) | 776 | (list 'calcFunc-deg a))) |
| @@ -779,14 +781,16 @@ If this can't be done, return NIL." | |||
| 779 | (defun math-to-radians-2 (a &optional force-symbolic) ; [N N] | 781 | (defun math-to-radians-2 (a &optional force-symbolic) ; [N N] |
| 780 | (cond ((eq (car-safe a) 'hms) | 782 | (cond ((eq (car-safe a) 'hms) |
| 781 | (math-from-hms a 'rad)) | 783 | (math-from-hms a 'rad)) |
| 782 | ((memq calc-angle-mode '(deg hms)) | 784 | ((and (not math-simplifying-units) |
| 785 | (memq calc-angle-mode '(deg hms))) | ||
| 783 | (if (or calc-symbolic-mode force-symbolic) | 786 | (if (or calc-symbolic-mode force-symbolic) |
| 784 | (math-div (math-mul a '(var pi var-pi)) 180) | 787 | (math-div (math-mul a '(var pi var-pi)) 180) |
| 785 | (math-mul a (math-pi-over-180)))) | 788 | (math-mul a (math-pi-over-180)))) |
| 786 | (t a))) | 789 | (t a))) |
| 787 | 790 | ||
| 788 | (defun math-from-radians-2 (a &optional force-symbolic) ; [N N] | 791 | (defun math-from-radians-2 (a &optional force-symbolic) ; [N N] |
| 789 | (cond ((memq calc-angle-mode '(deg hms)) | 792 | (cond ((and (not math-simplifying-units) |
| 793 | (memq calc-angle-mode '(deg hms))) | ||
| 790 | (if (or calc-symbolic-mode force-symbolic) | 794 | (if (or calc-symbolic-mode force-symbolic) |
| 791 | (math-div (math-mul 180 a) '(var pi var-pi)) | 795 | (math-div (math-mul 180 a) '(var pi var-pi)) |
| 792 | (math-div a (math-pi-over-180)))) | 796 | (math-div a (math-pi-over-180)))) |