#!/usr/bin/env python3 """Regression check for the test9/test10 fake-impulse bug.""" import math def qx(deg): a=math.radians(deg)/2 return (math.cos(a),math.sin(a),0.0,0.0) def conj(q): w,x,y,z=q; return (w,-x,-y,-z) def mul(a,b): aw,ax,ay,az=a; bw,bx,by,bz=b return (aw*bw-ax*bx-ay*by-az*bz, aw*bx+ax*bw+ay*bz-az*by, aw*by-ax*bz+ay*bw+az*bx, aw*bz+ax*by-ay*bx+az*bw) def rotate(q,v): r=mul(mul(q,(0.0,*v)),conj(q)); return r[1:] def invrotate(q,v): return rotate(conj(q),v) def close(a,b,e=1e-9): return all(abs(x-y) world={world} -> local={recovered}") print('OK: changing ship orientation changes world representation without changing local velocity')