-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.lisp
34 lines (26 loc) · 921 Bytes
/
utils.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(in-package #:cl-ode)
(declaim (optimize (speed 3)))
(defun make-vector3 (x y z w)
(make-array 4 :element-type 'single-float :initial-contents (list x y z w)))
(defun make-zero-vector3 ()
(make-array 4 :element-type 'single-float :initial-element 0.0))
(defun make-zero-vector4 ()
(make-array 4 :element-type 'single-float :initial-element 0.0))
(defun multiply-vector (s v)
(map '(SIMPLE-ARRAY SINGLE-FLOAT) (lambda (x)
(* s x))
v))
(defun add-vectors (v1 v2)
(map '(SIMPLE-ARRAY SINGLE-FLOAT) #'- v1 v2))
(defun subtract-vectors (v1 v2)
(map '(SIMPLE-ARRAY SINGLE-FLOAT) #'- v1 v2))
(defun dot (v1 v2)
(map '(SIMPLE-ARRAY SINGLE-FLOAT) #'* v1 v2))
(defmacro with-ode-object ((name value) &body body)
(let ((hidden-name (gensym)))
`(let* ((,hidden-name ,value)
(,name ,hidden-name))
(unwind-protect
(progn
,@body)
(destroy ,hidden-name)))))