X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2Fmain%2Fnvm%2Futils.lisp;h=a656df32eb37dd6b89f12d444d40d25f51b42248;hb=97c390f;hp=06941f562ecc3bfb85b12ee2ad0d27253b88772d;hpb=75a961089cba4b6aa4a3e947616ee4026ec3b057;p=clnl diff --git a/src/main/nvm/utils.lisp b/src/main/nvm/utils.lisp index 06941f5..a656df3 100644 --- a/src/main/nvm/utils.lisp +++ b/src/main/nvm/utils.lisp @@ -1,6 +1,28 @@ (in-package #:clnl-nvm) -(defun min-pxcor () (getf (clnl-model:world-dimensions *model*) :xmin)) -(defun max-pxcor () (getf (clnl-model:world-dimensions *model*) :xmax)) -(defun min-pycor () (getf (clnl-model:world-dimensions *model*) :ymin)) -(defun max-pycor () (getf (clnl-model:world-dimensions *model*) :ymax)) +(defun min-pxcor () (getf *dimensions* :xmin)) +(defun max-pxcor () (getf *dimensions* :xmax)) +(defun min-pycor () (getf *dimensions* :ymin)) +(defun max-pycor () (getf *dimensions* :ymax)) + +(defvar *cached-sins* + (loop + :for i :from 0 :to 360 + :collect + (let + ((potential-sin (strictmath:sin (strictmath:to-radians i)))) + (if (< (abs potential-sin) 3.2d-15) 0d0 potential-sin)))) + +(defun using-cached-sin (n) + (if (= (floor n) n) (nth (floor n) *cached-sins*) (strictmath:sin (strictmath:to-radians n)))) + +(defvar *cached-coses* + (loop + :for i :from 0 :to 360 + :collect + (let + ((potential-cos (strictmath:cos (strictmath:to-radians i)))) + (if (< (abs potential-cos) 3.2d-15) 0d0 potential-cos)))) + +(defun using-cached-cos (n) + (if (= (floor n) n) (nth (floor n) *cached-coses*) (strictmath:cos (strictmath:to-radians n))))