That sounds like a really neat project - it'd be great if you could turn it into a library.
All we have built-in for maths at the moment is https://www.espruino.com/Vec3, but that won't help you with matrix maths I'm afraid. If it's easier you could use C and the Inline C compiler (but that won't have matrix math built in either)...
IMO, at least from my experience with Bangle.js the holy grail isn't so much trying to make that ellipse into a sphere, but to add some kind of continuous calibration - because while you can calibrate when you're at your desk, if you stand up and move away from the desk, the effect of the metal in the desk changes and the calibration moves off again.
I did try some algorithms with bangle.js but without much success, but the best I got was just keeping a min/max and then estimating what the magnetic field strength was, and if eg max got further from min than 2*strength, I move min
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
That sounds like a really neat project - it'd be great if you could turn it into a library.
All we have built-in for maths at the moment is https://www.espruino.com/Vec3, but that won't help you with matrix maths I'm afraid. If it's easier you could use C and the Inline C compiler (but that won't have matrix math built in either)...
IMO, at least from my experience with Bangle.js the holy grail isn't so much trying to make that ellipse into a sphere, but to add some kind of continuous calibration - because while you can calibrate when you're at your desk, if you stand up and move away from the desk, the effect of the metal in the desk changes and the calibration moves off again.
I did try some algorithms with bangle.js but without much success, but the best I got was just keeping a min/max and then estimating what the magnetic field strength was, and if eg max got further from min than 2*strength, I move min