fix type punned pointer warnings
This commit is contained in:
parent
ee729814ca
commit
481b9b3798
@ -21,6 +21,7 @@
|
||||
|
||||
#include "MadgwickAHRS.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// Definitions
|
||||
@ -269,9 +270,12 @@ void Madgwick::updateIMU(float gx, float gy, float gz, float ax, float ay,
|
||||
float Madgwick::invSqrt(float x) {
|
||||
float halfx = 0.5f * x;
|
||||
float y = x;
|
||||
long i = *(long *)&y;
|
||||
// long i = *(long *)&y;
|
||||
long i;
|
||||
memcpy(&i, &y, sizeof(float));
|
||||
i = 0x5f3759df - (i >> 1);
|
||||
y = *(float *)&i;
|
||||
// y = *(float *)&i;
|
||||
memcpy(&y, &i, sizeof(float));
|
||||
y = y * (1.5f - (halfx * y * y));
|
||||
y = y * (1.5f - (halfx * y * y));
|
||||
return y;
|
||||
|
Loading…
x
Reference in New Issue
Block a user