Create define-system macro
This commit is contained in:
parent
26d92f7d5d
commit
b1eed4b019
@ -38,3 +38,17 @@
|
|||||||
(with-slots (running simulation-thread) sim
|
(with-slots (running simulation-thread) sim
|
||||||
(setf running nil)
|
(setf running nil)
|
||||||
(sb-thread:join-thread simulation-thread)))
|
(sb-thread:join-thread simulation-thread)))
|
||||||
|
|
||||||
|
(defmacro define-simulation (name &key lagrangian coords render start params)
|
||||||
|
`(progn
|
||||||
|
(defclass ,name (simulation)
|
||||||
|
()
|
||||||
|
(:default-initargs :start ',start :params ',params))
|
||||||
|
(defmethod update ((sim ,name) dt)
|
||||||
|
(with-slots (state params) sim
|
||||||
|
(setf state ,(let ((eqns (hamilton-eqns lagrangian coords)))
|
||||||
|
(update-body eqns coords params)))))
|
||||||
|
(defmethod render ((sim ,name))
|
||||||
|
(with-slots (state) sim
|
||||||
|
(let ,(mapcar (lambda (q) `(,q (getf state ',q))) coords)
|
||||||
|
,render)))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user