test

Dependencies:   mbed MMA8452Q

Fork of HelloWorld by Simon Ford

Revision:
18:171cb8d2f243
Parent:
17:c463c5a434ec
Child:
19:992f183385e8
--- a/main.cpp	Thu Aug 31 17:37:12 2017 +0000
+++ b/main.cpp	Thu Aug 31 17:54:54 2017 +0000
@@ -20,15 +20,21 @@
         // printf("X[%.2f] Y[%.2f] Z[%.2f]\n",x, y, z) ;
          wait(0.1);
 
-        float angle = 1-(((2*x*x+2*y*y)/(x*x+y*y+z*z)));
+        int X = x * 100;
+        int Y = y * 100;
+        int Z = z * 100;
+
+        float angle = 1-(((2*X*X+2*Y*Y)/(X*X+Y*Y+Z*Z)));
+        
         pc.printf("avant acos = %f", angle);
         //float resultat = ((3.14/2.0) -( angle + (angle *angle * angle)/6.0 + (3*angle*angle*angle*angle*angle)/40.0))/2;
-        float resultat = acos(angle)/2.0;
-        pc.printf("valeur rad new= %f", resultat);
-        float degree = resultat * 18000.0/314.0;
-        pc.printf("valeur deg new = %f", degree);
-        degree = degree * 10;
-        int degreInt = (int)degree;
+        
+        int resultat = acos(angle)*5;
+        pc.printf("valeur rad new= %d", resultat);
+        int degree = resultat * 18000/314;
+        pc.printf("valeur deg new = %d", degree);
+        //degree = degree * 10;
+        int degreInt = degree;
         pc.printf("valeur deg new = %d", degreInt);