composites (p:ps) = cs
where cs = (p*p) : merge (map (p*) (merge ps cs)) (composites ps)
merge (x:xs) (y:ys) | xy = diff (x:xs) ys
We added visualization of collisions to physbam’s opengl viewer for the high resolution cloth paper. These turn out to be one of the prettiest things it generates. Here are screenshots of edge-edge collision pairs (two edges colliding) and point-face collision pairs (a point colliding with a face) for a scene with a bunch of soft deformable objects:
Here’s a snippet of code to sneak into someone’s .pythonrc if you want them to hate you:
import sys
from numpy import *
class Evil:
size = array(1).itemsize
__array_interface__ = {
'shape' : (1,),
'typestr' : '<i%d'%size,
'data' : (id(1)+2*size, 0) }
asarray(Evil())[0] = 2
assert 1 == 2
It’s even platform independent! (Note: it will be less innocuous if the class isn’t named Evil.)