with class

Dependencies:   ISR_Mini-explorer mbed

Fork of VirtualForces by Georgios Tsamis

Revision:
34:c208497dd079
Parent:
33:814bcd7d3cfe
Child:
35:68f9edbb3cff
--- a/Map.cpp	Fri Jun 09 00:28:32 2017 +0000
+++ b/Map.cpp	Fri Jun 09 14:30:21 2017 +0000
@@ -1,12 +1,13 @@
 #include "Map.hpp"
 
-Map::Map(float widthRealMap, float HeightRealMap, int nbCellWidth, int nbCellHeight){
+
+Map::Map(float widthRealMap, float heightRealMap, int nbCellWidth, int nbCellHeight){
 	this->widthRealMap=widthRealMap;
-	this->HeightRealMap=HeightRealMap;
+	this->heightRealMap=heightRealMap;
 	this->nbCellWidth=nbCellWidth;
 	this->nbCellHeight=nbCellHeight;
 	this->sizeCellWidth=widthRealMap/(float)nbCellWidth;
-	this->sizeCellHeight=HeightRealMap/(float)nbCellHeight;
+	this->sizeCellHeight=heightRealMap/(float)nbCellHeight;
 	
 	this->cellsLogValues= new float*[nbCellWidth];
 	for(int i = 0; i < nbCellWidth; ++i)
@@ -23,11 +24,11 @@
 void Map::fill_initialLogValues(){
     //Fill map, we know the border are occupied
     for (int i = 0; i<this->nbCellWidth; i++) {
-        for (int j = 0; j<nbCellHeight; j++) {
-            if(j==0 || j==nbCellHeight-1 || i==0 || i==nbCellWidth-1)
-                this->initialLogValues[i][j] = proba_to_log(1);
+        for (int j = 0; j<this->nbCellHeight; j++) {
+            if(j==0 || j==this->nbCellHeight-1 || i==0 || i==this->nbCellWidth-1)
+                this->initialLogValues[i][j] = this->proba_to_log(1);
             else
-                initialLogValues[i][j] = proba_to_log(0.5);
+                this->initialLogValues[i][j] = this->proba_to_log(0.5);
         }
     }
 }
@@ -43,7 +44,33 @@
     return log(p/(1-p));
 }
 
-void Map::print_final_map() {
+void Map::update_cell_value(int widthIndice,int heightIndice ,float proba){
+    this->cellsLogValues[widthIndice][heightIndice]=this->cellsLogValues[widthIndice][heightIndice]+this->proba_to_log(proba)+this->initialLogValues[widthIndice][heightIndice];//map is filled as map[0][0] get the data for the point closest to the origin
+}
+
+float Map::robot_x_coordinate_in_world(float robot_x, float robot_y){
+    return this->nbCellWidth*this->sizeCellWidth-robot_y;
+}
+
+float Map::robot_y_coordinate_in_world(float robot_x, float robot_y){
+    return robot_x;
+}
+
+float Map::cell_width_coordinate_to_world(int i){
+	return this->sizeCellWidth/2+i*this->sizeCellWidth;
+}
+
+float Map::cell_height_coordinate_to_world(int j){
+	return this->sizeCellHeight/2+j*this->sizeCellHeight;
+}
+
+float Map::get_proba_cell(int widthIndice, int heightIndice){
+	return  this->log_to_proba(this->cellsLogValues[widthIndice][heightIndice]);
+}
+
+/*
+
+void MiniExplorerCoimbra::print_final_map() {
     float currProba;
     pc.printf("\n\r");
     for (int y = this->nbCellHeight -1; y>-1; y--) {
@@ -78,8 +105,8 @@
     float heightBonus=sizeCellHeight/2;
 
     pc.printf("\n\r");
-    for (int y = nbCellHeight -1; y>-1; y--) {
-        for (int x= 0; x<nbCellWidth; x++) {
+    for (int y = this->nbCellHeight -1; y>-1; y--) {
+        for (int x= 0; x<this->nbCellWidth; x++) {
             heightIndiceInOrthonormal=this->cell_height_coordinate_to_world(y);
             widthIndiceInOrthonormal=this->cell_width_coordinate_to_world(x);
             if(Yrobot >= (heightIndiceInOrthonormal+heightMalus) && Yrobot <= (heightIndiceInOrthonormal+heightBonus) && Xrobot >= (widthIndiceInOrthonormal+widthMalus) && Xrobot <= (widthIndiceInOrthonormal+widthBonus))                    
@@ -140,27 +167,4 @@
         pc.printf("\n\r");
     }
 }
-
-void Map::update_cell_value(int widthIndice,int heightIndice ,float proba){
-    this->cellsLogValues[widthIndice][heightIndice]=this->cellsLogValues[widthIndice][heightIndice]+this->proba_to_log(proba)+this->initialLogValues[widthIndice][heightIndice];//map is filled as map[0][0] get the data for the point closest to the origin
-}
-
-float Map::robot_x_coordinate_in_world(float robot_x, float robot_y){
-    return this->nbCellWidth*this->sizeCellWidth-robot_y;
-}
-
-float Map::robot_y_coordinate_in_world(float robot_x, float robot_y){
-    return robot_x;
-}
-
-float Map::cell_width_coordinate_to_world(int i){
-	return this->sizeCellWidth/2+i*this->sizeCellWidth;
-}
-
-float Map::cell_height_coordinate_to_world(int j){
-	return this->sizeCellHeight/2+j*this->sizeCellHeight;
-}
-
-float Map::get_proba_cell(int widthIndice, int heightIndice){
-	return  this->log_to_proba(this->cellsLogValues[widthIndice][heightIndice]);
-}
+*/
\ No newline at end of file