Project 3D Vector into object orientation

64 Views Asked by At

So I'm currently attempting to project a 3D Vector (obtained from an accelerometer) into the object orientation (obtained by integrating the angular velocity obtained from the object gyroscope, returned as a 3D Vector). However I'm not really sure how to do that.

I'm using an Excel spreadsheet right now to know which results I can expect from the test data to be imported into the software I'm working on.

1

There are 1 best solutions below

0
On

Projecting a vector v onto another vector p is as simple as computing the dot product of the former with a unit length vector in the direction of the latter np:

vp = (v.np)np = (v.p / ||p||2)p

Component-wise that is:

// Dot product of v and p
vdp = v.x*p.x + v.y*p.y + v.z*p.z
// Square norm of p
p2 = p.x*p.x + p.y*p.y + p.z*p.z
// Projection
vp.x = (vdp / p2) * p.x
vp.y = (vdp / p2) * p.y
vp.z = (vdp / p2) * p.z

The length of the projection itself is v.np, which is equal to vdp / sqrt(p2).