Mercurial > hg > amuse
comparison methods.lisp @ 20:6eb54ad3b8b4
Bug fixes mostly, but also re-aliasing onset to moment rather than timepoint
darcs-hash:20061213162757-f76cc-39094b0c337efac30d8a957a9087436146ea2e82.gz
author | David Lewis <d.lewis@gold.ac.uk> |
---|---|
date | Wed, 13 Dec 2006 16:27:57 +0000 |
parents | 2f331bbdfab8 |
children | 99ccd775245a |
comparison
equal
deleted
inserted
replaced
19:2f331bbdfab8 | 20:6eb54ad3b8b4 |
---|---|
163 | 163 |
164 ;; Allen | 164 ;; Allen |
165 | 165 |
166 (defmethod meets ((object1 anchored-period) | 166 (defmethod meets ((object1 anchored-period) |
167 (object2 anchored-period)) | 167 (object2 anchored-period)) |
168 (or (time= (cut-off object1) (onset object2)) | 168 (or (time= (cut-off object1) object2) |
169 (time= (cut-off object2) (onset object1)))) | 169 (time= (cut-off object2) object1))) |
170 | 170 |
171 (defmethod before ((object1 anchored-period) | 171 (defmethod before ((object1 anchored-period) |
172 (object2 anchored-period)) | 172 (object2 anchored-period)) |
173 (time< (cut-off object1) (onset object2))) | 173 (time> object2 (cut-off object1))) |
174 | 174 |
175 (defmethod overlaps ((object1 anchored-period) | 175 (defmethod overlaps ((object1 anchored-period) |
176 (object2 anchored-period)) | 176 (object2 anchored-period)) |
177 (or (and (time> (cut-off object1) (onset object2)) | 177 ;; FIXME: Is there a tidier method? |
178 (time< (onset object1) (onset object2))) | 178 (or (and (time> object2 object1) ; object1 starts before object2 |
179 (and (time> (cut-off object1) (cut-off object2)) | 179 (time> (cut-off object1) object2) ; object1 ends after object2 starts |
180 (time< (onset object1) (cut-off object2))))) | 180 (time> (cut-off object2) (cut-off object1))) ; object1 ends before object2 does |
181 (and (time> object1 object2) ; object1 starts after object2 | |
182 (time> (cut-off object2) object1) ; object1 starts before object2 ends | |
183 (time> (cut-off object1) (cut-off object2))))) ; object1 ends after object2 does | |
181 | 184 |
182 (defmethod during ((object1 anchored-period) | 185 (defmethod during ((object1 anchored-period) |
183 (object2 anchored-period)) | 186 (object2 anchored-period)) |
184 (and (time> (onset object1) (onset object2)) | 187 (and (time> object1 object2) |
185 (time< (cut-off object2) (cut-off object2)))) | 188 (time< (cut-off object2) (cut-off object2)))) |
186 | 189 |
187 (defmethod starts ((object1 anchored-period) | 190 (defmethod starts ((object1 anchored-period) |
188 (object2 anchored-period)) | 191 (object2 anchored-period)) |
189 (time= (onset object1) (onset object2))) | 192 (time= object1 object2)) |
190 | 193 |
191 (defmethod ends ((object1 anchored-period) | 194 (defmethod ends ((object1 anchored-period) |
192 (object2 anchored-period)) | 195 (object2 anchored-period)) |
193 (time= (cut-off object1) (cut-off object2))) | 196 (time= (cut-off object1) (cut-off object2))) |
194 | 197 |
200 ((disjoint object1 object2) | 203 ((disjoint object1 object2) |
201 ;; if they don't overlap, return nil, not a negative-valued | 204 ;; if they don't overlap, return nil, not a negative-valued |
202 ;; period | 205 ;; period |
203 nil) | 206 nil) |
204 (t | 207 (t |
205 (let ((new-onset (max (onset object1) | 208 (let ((new-onset (max (timepoint object1) |
206 (onset object2)))) | 209 (timepoint object2)))) |
207 (make-anchored-period new-onset | 210 (make-anchored-period new-onset |
208 (time- (min (cut-off object1) | 211 (time- (min (cut-off object1) |
209 (cut-off object2)) | 212 (cut-off object2)) |
210 new-onset)))))) | 213 new-onset)))))) |
211 | 214 |