MCPcopy Create free account
hub / github.com/aster94/SensorFusion / invSqrt

Method invSqrt

src/SensorFusion.cpp:57–68  ·  view source on GitHub ↗

See: http://en.wikipedia.org/wiki/Fast_inverse_square_root

Source from the content-addressed store, hash-verified

55
56// See: http://en.wikipedia.org/wiki/Fast_inverse_square_root
57float SF::invSqrt(float x)
58{
59 float halfx = 0.5f * x;
60 union {
61 float f;
62 uint32_t i;
63 } conv = { .f = x };
64 conv.i = 0x5f3759df - (conv.i >> 1);
65 conv.f *= 1.5f - (halfx * conv.f * conv.f);
66 conv.f *= 1.5f - (halfx * conv.f * conv.f);
67 return conv.f;
68}
69
70//-------------------------------------------------------------------------------------------
71void SF::computeAngles()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected