Acceleration vectors coordinates in 3D space from 3-axis accelerometer


I’m using a 3-axis accelerometer along with a gyroscope and magnetometer to estimate the current attitude of an object, using quaternions.

For that, I need an initial attitude estimation using the accelerometer. I get the acceleration vectors norms from its 3 axes.

I want to determine the direction of one of these vectors in 3D space as coordinates as the direction of one of these vector will be the same than my object’s.

I am using a coordinates system with the z axis as “up” and the y and x axes defining the horizontal plane in a terrestrial referential.
I only need its direction “relative to the up direction”, as I can rotate the vector using the magnetometer afterwards or just define it as rotation 0 : we can consider the calculated vector to be on the same plane as the referential z axis and any of the horizontal axes.

I don’t have much experience in 3D space math so I’m a bit lost and can’t figure it out :confused:
I know the normalized total acceleration vector has coordinates of (x = 0, y = 0, z = -1) since it’s pointing straight down and other relation between acceleromter axes but couldn’t get a solution.

Can anyone that tried this before help ? I think it can be done, but if there’s an easier alternative I would be happy too : )

(Sorry if this the wrong thread to post this in as I’m more asking a math question than a sensor question, and also for bad english.)

Look up "Arduino AHRS". RTImulib and the Madgwick or Mahoney filters are popular. Pololu has decent code for the orientation sensors they sell.

The accelerometer tells you the Down direction and the magnetometer tells you how to find magnetic North, but the magnetometer ABSOLUTELY MUST be properly calibrated.

Avoid Kris Winer's code for the MPU9250, and anything from TKJElectronics, as they don't work.