aaa

Fork of Move by 涼太郎 中村

Revision:
20:908443fd2b09
Parent:
19:0b0ed6b22de9
Child:
21:282c2b61e462
--- a/move.cpp	Sat Sep 10 12:25:58 2016 +0000
+++ b/move.cpp	Sat Sep 10 13:00:34 2016 +0000
@@ -489,14 +489,18 @@
     x = coordinateX();
     y = coordinateY();
     theta = coordinateTheta();//自己位置取得
+    
+    if(targetx - x == 0) return 0; 
+    
     phi = atan(double(targety - y) / double(targetx - x));//目的地への角度phi取得
-    while(phi>PI) {
-        phi-=2*PI;
+    if(targetx - x < 0) 
+    {
+        if(targety  - y > 0)
+            phi += PI;
+        else if(targety - y < 0)
+            phi -= PI;
     }
-    while(phi<=(-1)*PI) {
-        phi+=2*PI;
-    }
-
+    
     return phi;
 }