comparison 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
comparison
equal deleted inserted replaced
541:048b43654870 542:a3add9f751ef
75 >>> t1.getTrajectoryInPolygonNoShapely(np.array([[0,0],[4,0],[4,3],[0,3]])) 75 >>> t1.getTrajectoryInPolygonNoShapely(np.array([[0,0],[4,0],[4,3],[0,3]]))
76 (0.500000,0.500000) 76 (0.500000,0.500000)
77 >>> t1.getTrajectoryInPolygonNoShapely(np.array([[10,10],[14,10],[14,13],[10,13]])).length() 77 >>> t1.getTrajectoryInPolygonNoShapely(np.array([[10,10],[14,10],[14,13],[10,13]])).length()
78 0 78 0
79 79
80 >>> t1.differentiate()
81 (1.000000,3.000000) (1.000000,3.000000)
82 >>> t1.differentiate(True)
83 (1.000000,3.000000) (1.000000,3.000000) (1.000000,3.000000)
84 >>> t1 = Trajectory([[0.5,1.5,3.5],[0.5,2.5,7.5]])
85 >>> t1.differentiate()
86 (1.000000,2.000000) (2.000000,5.000000)
87
80 >>> from utils import LCSS 88 >>> from utils import LCSS
81 >>> lcss = LCSS(lambda x,y: Point.distanceNorm2(x,y) <= 0.1) 89 >>> lcss = LCSS(lambda x,y: Point.distanceNorm2(x,y) <= 0.1)
82 >>> Trajectory.lcss(t1, t1, lcss) 90 >>> Trajectory.lcss(t1, t1, lcss)
83 3 91 3
84 >>> lcss = LCSS(lambda p1, p2: (p1-p2).normMax() <= 0.1) 92 >>> lcss = LCSS(lambda p1, p2: (p1-p2).normMax() <= 0.1)
100 >>> Point.timeToCollision(p1, p2, v1, v2, 0.) == None 108 >>> Point.timeToCollision(p1, p2, v1, v2, 0.) == None
101 True 109 True
102 >>> Point.timeToCollision(p2, p1, v2, v1, 0.) == None 110 >>> Point.timeToCollision(p2, p1, v2, v1, 0.) == None
103 True 111 True
104 112
113 >>> t = CurvilinearTrajectory(S = [1., 2., 3., 5.], Y = [0.5, 0.5, 0.6, 0.7], lanes = ['1']*4)
114 >>> t.differentiate() # doctest:+ELLIPSIS
115 [1.0, 0.0, '1'] [1.0, 0.099..., '1'] [2.0, 0.099..., '1']
116 >>> t.differentiate(True) # doctest:+ELLIPSIS
117 [1.0, 0.0, '1'] [1.0, 0.099..., '1'] [2.0, 0.099..., '1'] [2.0, 0.099..., '1']
118
105 >>> o1 = MovingObject(positions = Trajectory([[0]*3,[2]*3]), velocities = Trajectory([[0]*3,[1]*3])) 119 >>> o1 = MovingObject(positions = Trajectory([[0]*3,[2]*3]), velocities = Trajectory([[0]*3,[1]*3]))
106 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.median) 120 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.median)
107 >>> userTypeNames[o1.getUserType()] 121 >>> userTypeNames[o1.getUserType()]
108 'car' 122 'car'
109 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.mean) 123 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.mean)