Tests for vector functions
This commit is contained in:
parent
8dbf44a9f0
commit
65a60a2a65
3 changed files with 58 additions and 1 deletions
27
engine/math.scm
Normal file
27
engine/math.scm
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(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*)))
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue