]> rtime.felk.cvut.cz Git - eurobot/public.git/blobdiff - src/motion/turn.cc
motion: Fix compile error.
[eurobot/public.git] / src / motion / turn.cc
index a5c742e3513aedec791208425727743a761bf498..49bc1fe9e95285b2f3bb0196e37b80ab5b844d2a 100644 (file)
@@ -1,5 +1,24 @@
+//     Copyright 2009 Michal Sojka <sojkam1@fel.cvut.cz>
+//     Copyright 2009 Petr Beneš
+//
+//     This file is part of Trgen library.
+//
+//     Trgen is free software: you can redistribute it and/or modify
+//     it under the terms of the GNU General Public License as published by
+//     the Free Software Foundation, either version 3 of the License, or
+//     (at your option) any later version.
+//
+//     Trgen is distributed in the hope that it will be useful,
+//     but WITHOUT ANY WARRANTY; without even the implied warranty of
+//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//     GNU General Public License for more details.
+//
+//     You should have received a copy of the GNU General Public License
+//     along with Trgen.  If not, see <http://www.gnu.org/licenses/>.
+
 #include "trgen.h"
 #include "trgendbg.h"
+#include <stdio.h>
 
 namespace Segment {
 
@@ -47,6 +66,22 @@ namespace Segment {
         return ns;
     }
 
+    TrajectorySegment* Turn::splitAtByTime(double time, Point *newEnd) {
+       if (time <= t1 || time >= t2) {
+            dbgPrintf("splitAt: distance=%g turnBy=%g\n", time, turnBy);
+            return NULL;
+        }
+
+        Turn *ns = new Turn(*this);
+       double distance = 0.5 * acc * time * time + v1 * time;
+       if (turnBy < 0)
+               distance = -distance;
+       turnBy = distance;
+        ns->startHeading+=distance;
+        ns->turnBy -= distance;
+        return ns;
+    }
+
     void Turn::getRefPos(double time, Pos &rp) {
         double t = time-t1;
         double fraction = t/(t2-t1);