#!/usr/bin/env python3 """ heading_test.py -- identify the 0x1d matrix convention + shark nose axis by correlating every candidate basis vector against the swim velocity across the whole capture. The right candidate tracks velocity with a consistently high dot. python heading_test.py [capture] """ import sys, struct import numpy as np sys.path.insert(0, '.') from vrboard import Assembler from decode_anim import find_framed_start path = sys.argv[1] if len(sys.argv) > 1 else 'cap7.raw.bin' data = open(path, 'rb').read() asm = Assembler(); asm.feed(data[find_framed_start(data):]) recs = [] for m in asm: if m.iserver: continue if m.action == 0x1d and len(m.payload) >= 56: h = struct.unpack_from('0.9={np.mean(dots > 0.9):.2f} frac<-0.9={np.mean(dots < -0.9):.2f}' f' frac|.|<0.5={np.mean(np.abs(dots) < 0.5):.2f}')