Added "angle".
This commit is contained in:
parent
a9657c4642
commit
2a49d5c538
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
(library (ikarus not-yet-implemented)
|
(library (ikarus not-yet-implemented)
|
||||||
(export
|
(export
|
||||||
angle make-polar
|
make-polar
|
||||||
bitwise-copy-bit-field bitwise-reverse-bit-field
|
bitwise-copy-bit-field bitwise-reverse-bit-field
|
||||||
bitwise-rotate-bit-field bitwise-if fxreverse-bit-field
|
bitwise-rotate-bit-field bitwise-if fxreverse-bit-field
|
||||||
fxrotate-bit-field
|
fxrotate-bit-field
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
string-upcase)
|
string-upcase)
|
||||||
|
|
||||||
(import (except (ikarus)
|
(import (except (ikarus)
|
||||||
angle make-polar
|
make-polar
|
||||||
bitwise-copy-bit-field bitwise-reverse-bit-field
|
bitwise-copy-bit-field bitwise-reverse-bit-field
|
||||||
bitwise-rotate-bit-field bitwise-if fxreverse-bit-field
|
bitwise-rotate-bit-field bitwise-if fxreverse-bit-field
|
||||||
fxrotate-bit-field
|
fxrotate-bit-field
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
(not-yet
|
(not-yet
|
||||||
;;; should be implemented
|
;;; should be implemented
|
||||||
string-downcase string-titlecase string-upcase
|
string-downcase string-titlecase string-upcase
|
||||||
angle make-polar
|
make-polar
|
||||||
bitwise-if
|
bitwise-if
|
||||||
bitwise-rotate-bit-field bitwise-copy-bit-field bitwise-reverse-bit-field
|
bitwise-rotate-bit-field bitwise-copy-bit-field bitwise-reverse-bit-field
|
||||||
fxreverse-bit-field fxrotate-bit-field
|
fxreverse-bit-field fxrotate-bit-field
|
||||||
|
|
|
@ -3619,10 +3619,10 @@
|
||||||
|
|
||||||
(library (ikarus complex-numbers)
|
(library (ikarus complex-numbers)
|
||||||
(export make-rectangular $make-rectangular
|
(export make-rectangular $make-rectangular
|
||||||
real-part imag-part magnitude)
|
real-part imag-part angle magnitude)
|
||||||
(import
|
(import
|
||||||
(except (ikarus)
|
(except (ikarus)
|
||||||
make-rectangular real-part imag-part magnitude)
|
make-rectangular real-part imag-part angle magnitude)
|
||||||
(except (ikarus system $compnums) $make-rectangular))
|
(except (ikarus system $compnums) $make-rectangular))
|
||||||
|
|
||||||
(define ($make-rectangular r i)
|
(define ($make-rectangular r i)
|
||||||
|
@ -3667,6 +3667,35 @@
|
||||||
[else
|
[else
|
||||||
(die 'magnitude "not a number" x)])))
|
(die 'magnitude "not a number" x)])))
|
||||||
|
|
||||||
|
(define angle
|
||||||
|
(lambda (x)
|
||||||
|
(import (ikarus system $bignums) (ikarus system $ratnums))
|
||||||
|
(define PI (acos -1))
|
||||||
|
(cond
|
||||||
|
[(fixnum? x)
|
||||||
|
(if (fx>? x 0)
|
||||||
|
0
|
||||||
|
(if (fx<? x 0)
|
||||||
|
PI
|
||||||
|
(die 'angle "undefined for 0")))]
|
||||||
|
[(bignum? x)
|
||||||
|
(if ($bignum-positive? x) 0 PI)]
|
||||||
|
[(ratnum? x)
|
||||||
|
(let ([n ($ratnum-n x)])
|
||||||
|
(if (> n 0) 0 PI))]
|
||||||
|
[(flonum? x)
|
||||||
|
(atan 0.0 x)]
|
||||||
|
[(compnum? x)
|
||||||
|
(let ([r ($compnum-real x)]
|
||||||
|
[i ($compnum-imag x)])
|
||||||
|
(atan i r))]
|
||||||
|
[(cflonum? x)
|
||||||
|
(let ([r ($cflonum-real x)]
|
||||||
|
[i ($cflonum-imag x)])
|
||||||
|
(atan i r))]
|
||||||
|
[else
|
||||||
|
(die 'angle "not a number" x)])))
|
||||||
|
|
||||||
(define real-part
|
(define real-part
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(cond
|
(cond
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1537
|
1538
|
||||||
|
|
Loading…
Reference in New Issue