KieranWynn / pyquaternion

A fully featured, pythonic library for representing and using quaternions
http://kieranwynn.github.io/pyquaternion/
MIT License
339 stars 68 forks source link

Optimise slerp() and intermediates(), make other parts more concise #81

Open DroneBetter opened 2 years ago

DroneBetter commented 2 years ago

The optimisation of slerp() (four fewer allocations, no inversion of one input quaternion necessary) is based on my independent derivation for my 3D engine here intermediates() needs only for the (n+1)th root of q1 to be calculated, then for q0 to be recursively multiplied by it, more efficiently (and could also be done more concisely by itertools.accumulate() but would require a lambda function and would be no more efficient)

DroneBetter commented 2 years ago

Wait a minute, the final one also replaces the uses of np.matrix and reduces numerical error (from the other pull requests) because I wanted to pull the slerp-and-conciseness branch into my master branch (into which I merged them also), sorry