Dependencies:   mbed

Revision:
6:2cd6ae395c0f
Parent:
4:5a892f5ab5a8
Child:
7:3a755ebe4eaf
--- a/ActiveCell.h	Thu Mar 28 10:59:55 2019 +0000
+++ b/ActiveCell.h	Fri Apr 05 14:28:09 2019 +0000
@@ -8,11 +8,11 @@
 public:
     //cell dimension = 5x5cm
     int cellVal;
-    double forceX;
-    double forceY;
-    double distance;
+    float forceX;
+    float forceY;
+    float distance;
     int xt, yt;
-    static const double repulsiveForce = 1000;
+    static const float repulsiveForce = 20;
     //robots position
     int x0;
     int y0;
@@ -30,7 +30,7 @@
         forceX = (repulsiveForce * cellVal / pow(distance, 2)) * (xt - x0) / distance;
         forceY = (repulsiveForce * cellVal / pow(distance, 2)) * (yt - y0) / distance;
     }
-
+//Calculating distance from the robot 
     void calDist(int idX, int idY) {
         if (idX < 5) {
             xt = x0 - (5 - idX) * 5;
@@ -46,7 +46,7 @@
         } else {
             yt = y0 + (idY - 5) * 5;
         }
-        distance = sqrt(pow((double)abs(x0 - xt), 2) + pow((double)abs(y0 - yt), 2));
+        distance = sqrt(pow((float)abs(x0 - xt), 2) + pow((float)abs(y0 - yt), 2));
     }
 };