I've got 2 int16_t numbers, say 388 and 10288, which are sensor readings from an accelerometer. I want to estimate the angle of the device on that, but seemingly there are some type overflow issues:
My final goal is this:
theta = atan(-ax/sqrt((float)ay*ay+az*az));
The problem occurs in the bracket: ay^2 and az^2 are the 2 power of the given numbers. I recalculated with matlab and for the above example I get
a^2+b^2 = 388^2+10288^2 = 105993488 what I get from the arduino however is
To be short: I don't know much about fixed point math or thelike and I couldn't find a sufficient answer to this: How do I calculate the square root term?