Added "angle".
This commit is contained in:
parent
a9657c4642
commit
2a49d5c538
|
@ -1,7 +1,7 @@
|
|||
|
||||
(library (ikarus not-yet-implemented)
|
||||
(export
|
||||
angle make-polar
|
||||
make-polar
|
||||
bitwise-copy-bit-field bitwise-reverse-bit-field
|
||||
bitwise-rotate-bit-field bitwise-if fxreverse-bit-field
|
||||
fxrotate-bit-field
|
||||
|
@ -17,7 +17,7 @@
|
|||
string-upcase)
|
||||
|
||||
(import (except (ikarus)
|
||||
angle make-polar
|
||||
make-polar
|
||||
bitwise-copy-bit-field bitwise-reverse-bit-field
|
||||
bitwise-rotate-bit-field bitwise-if fxreverse-bit-field
|
||||
fxrotate-bit-field
|
||||
|
@ -57,7 +57,7 @@
|
|||
(not-yet
|
||||
;;; should be implemented
|
||||
string-downcase string-titlecase string-upcase
|
||||
angle make-polar
|
||||
make-polar
|
||||
bitwise-if
|
||||
bitwise-rotate-bit-field bitwise-copy-bit-field bitwise-reverse-bit-field
|
||||
fxreverse-bit-field fxrotate-bit-field
|
||||
|
|
|
@ -3619,10 +3619,10 @@
|
|||
|
||||
(library (ikarus complex-numbers)
|
||||
(export make-rectangular $make-rectangular
|
||||
real-part imag-part magnitude)
|
||||
real-part imag-part angle magnitude)
|
||||
(import
|
||||
(except (ikarus)
|
||||
make-rectangular real-part imag-part magnitude)
|
||||
make-rectangular real-part imag-part angle magnitude)
|
||||
(except (ikarus system $compnums) $make-rectangular))
|
||||
|
||||
(define ($make-rectangular r i)
|
||||
|
@ -3667,6 +3667,35 @@
|
|||
[else
|
||||
(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
|
||||
(lambda (x)
|
||||
(cond
|
||||
|
|
|
@ -1 +1 @@
|
|||
1537
|
||||
1538
|
||||
|
|
Loading…
Reference in New Issue