i2cdevlib
i2cdevlib copied to clipboard
getMagnitude() returning nan for VectorInt16
the magnitude in helper_3dmath is currently calculated as following:
sqrt(x*x + y*y + z*z);
this works well for Quaternion and VectorFloat but is causing issues for VectorInt16
I think it should be changed to
sqrt((float)x*(float)x + (float) y*(float)y + (float)z*(float)z);
or have a warning that the numbers have to be smaller than 256 so that it works. This is also effecting the funktions normalize and getNormalized, because getMagnitude is used there.
You are right. I tried your version and it works just fine.