27 lines
586 B
Scheme
27 lines
586 B
Scheme
(module (engine math) ()
|
|
(import scheme
|
|
(chicken base)
|
|
(chicken module))
|
|
|
|
(export PI PI/2)
|
|
(define PI
|
|
3.141592653589793238462643383279502884197169399375105820974944592307816406286)
|
|
|
|
(define PI/2
|
|
(/ PI 2))
|
|
|
|
(export rad-to-deg deg-to-rad)
|
|
;; Radians and degrees conversion
|
|
(define (rad-to-deg rad)
|
|
(* rad
|
|
(/ 180 PI)))
|
|
(define (deg-to-rad deg)
|
|
(* deg
|
|
(/ PI 180)))
|
|
|
|
(export *float-precision* approx-=)
|
|
(define *float-precision* (make-parameter 0.001))
|
|
;; Approximately equal - for real number comparison
|
|
(define (approx-= x y)
|
|
(< (abs (- x y)) (*float-precision*)))
|
|
)
|