diff python/tests/moving.txt @ 542:a3add9f751ef

added differentiate function for curvilinear trajectories and modified the addPosition functions
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 07 Jul 2014 16:54:10 -0400
parents f012a8ad7a0e
children 0057c04f94d5
line wrap: on
line diff
--- a/python/tests/moving.txt	Mon Jul 07 12:30:46 2014 -0400
+++ b/python/tests/moving.txt	Mon Jul 07 16:54:10 2014 -0400
@@ -77,6 +77,14 @@
 >>> t1.getTrajectoryInPolygonNoShapely(np.array([[10,10],[14,10],[14,13],[10,13]])).length()
 0
 
+>>> t1.differentiate()
+(1.000000,3.000000) (1.000000,3.000000)
+>>> t1.differentiate(True)
+(1.000000,3.000000) (1.000000,3.000000) (1.000000,3.000000)
+>>> t1 = Trajectory([[0.5,1.5,3.5],[0.5,2.5,7.5]])
+>>> t1.differentiate()
+(1.000000,2.000000) (2.000000,5.000000)
+
 >>> from utils import LCSS
 >>> lcss = LCSS(lambda x,y: Point.distanceNorm2(x,y) <= 0.1)
 >>> Trajectory.lcss(t1, t1, lcss)
@@ -102,6 +110,12 @@
 >>> Point.timeToCollision(p2, p1, v2, v1, 0.) == None
 True
 
+>>> t = CurvilinearTrajectory(S = [1., 2., 3., 5.], Y = [0.5, 0.5, 0.6, 0.7], lanes = ['1']*4)
+>>> t.differentiate() # doctest:+ELLIPSIS
+[1.0, 0.0, '1'] [1.0, 0.099..., '1'] [2.0, 0.099..., '1']
+>>> t.differentiate(True) # doctest:+ELLIPSIS
+[1.0, 0.0, '1'] [1.0, 0.099..., '1'] [2.0, 0.099..., '1'] [2.0, 0.099..., '1']
+
 >>> o1 = MovingObject(positions = Trajectory([[0]*3,[2]*3]), velocities = Trajectory([[0]*3,[1]*3]))
 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.median)
 >>> userTypeNames[o1.getUserType()]