
An interactive guide to sensor fusion with quaternions
Bogdanp
created: Aug. 15, 2025, 2:17 p.m. | updated: Aug. 16, 2025, 12:36 p.m.
A portal into the world of sensor fusion with quaternions.
There's a lot of information about sensor fusion nobody seems to talk about, so I'm trying to fill some gaps.
Note that the resulting quaternion must be normalized*/ quat_from_two_vectors(vector_a: number[], vector_b: number[]); /*Produce a quaternion from euler angles*/ quat_from_euler(x: number, y: number, z: number); /*Multiply two quaternions together*/ quat_mult(q1: Quaternion, q2: Quaternion); /*Multiply some value across each component of the quaternion*/ quat_product(q: Quaternion, val: number); /*Add two quaternions together, component-wise*/ quat_add(q1: Quaternion, q2: Quaternion); /*Subtract two quaternions, component-wise.
********/ let q_world = q_body.copy(); q_world = quat_mult(q_bodyToEarth, q_world); q_world = quat_mult(q_world, quat_conj(q_bodyToEarth)); results.push(q_world.copy()); } return results; }Now that's pretty cool!
********/ let q_world = q_body.copy(); q_world = quat_mult(q_bodyToEarth, q_world); q_world = quat_mult(q_world, quat_conj(q_bodyToEarth)); results.push(q_world.copy()); } return results; }All I changed was the starting orientation and now the cube has some weird sway.
22 hours, 19 minutes ago: Hacker News: Front Page