How to find the average "direction" of a set of vectors?

99 Views Asked by At

There are a lot of similar sounding questions I have found but none match my problem. I have a set of 3d vectors (x, y, z) that represent acceleration in 3 axis, the values come from a real life accelerometer that moves in a straight line then stops. As the accelerometer moves from stationary initaially to stationary at the end, simply taking the average of all vectors will give roughly (0,0,0) as the net acceleration is 0. I want to find the unit vector that points "forward" in 3D space.

https://i.stack.imgur.com/0uyHz.jpg

This image tries to illustrate my problem, in my set of vectors I have some that point forwards and some that point backwards, all close to being inline with the red "forward" vector that I want to find. I am working in python using numpy but a general mathmatical solution would still be very helpful. I am not sure if my problem is mathmatically a "thing" that you can do as it isn't very strictly defined, my only solution currently is to get a subset of vectors that I know are pointing roughly in the same direction and find their average, but this feels hacky and isn't really what I want.