Mercurial Hosting > traffic-intelligence
annotate trafficintelligence/tests/moving.txt @ 1217:5038c357b57f
updating code for direct computation (very slow solver)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 16 May 2023 22:12:39 -0400 |
parents | dc28364f34b9 |
children | 69b531c7a061 |
rev | line source |
---|---|
1030
aafbc0bab925
moved method around to avoid cross-dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1028
diff
changeset
|
1 >>> from trafficintelligence.moving import * |
aafbc0bab925
moved method around to avoid cross-dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1028
diff
changeset
|
2 >>> from trafficintelligence import storage |
92
a5ef9e40688e
makes use of matplotlib function to test if point is in a polygon
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
91
diff
changeset
|
3 >>> import numpy as np |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
4 |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
5 >>> Interval().empty() |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
6 True |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
7 >>> Interval(0,1).empty() |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
8 False |
104
13187af8622d
finally added the representation of intervals
Nicolas Saunier <nico@confins.net>
parents:
96
diff
changeset
|
9 >>> Interval(0,1) |
1064
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
10 0-1 |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 >>> Interval(0,1).length() |
91
daa05fae1a70
modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
79
diff
changeset
|
12 1.0 |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
13 >>> Interval(23.2,24.9).length() |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
14 1.6999999999999993 |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 >>> Interval(10,8).length() |
91
daa05fae1a70
modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
79
diff
changeset
|
16 0.0 |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
17 |
1064
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
18 >>> i = Interval.parse('3-5') |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
19 >>> i.first == 3 and i.last == 5 |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
20 True |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
21 >>> type(i) |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
22 <class 'trafficintelligence.moving.Interval'> |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
23 >>> i = TimeInterval.parse('3-5') |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
24 >>> type(i) |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
25 <class 'trafficintelligence.moving.TimeInterval'> |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
26 >>> list(i) |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
27 [3, 4, 5] |
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
28 |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
29 >>> TimeInterval(0,1).length() |
91
daa05fae1a70
modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
79
diff
changeset
|
30 2.0 |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
31 >>> TimeInterval(10,8).length() |
91
daa05fae1a70
modified the type of the result of interval lengths to float, added comments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
79
diff
changeset
|
32 0.0 |
776
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
33 >>> TimeInterval(10,8) == TimeInterval(10,8) |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
34 True |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
35 >>> TimeInterval(10,8) == TimeInterval(8,10) |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
36 True |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
37 >>> TimeInterval(11,8) == TimeInterval(10,8) |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
38 False |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
39 |
107
916678481896
corrected bug for TimeInterval interation and added corresponding test
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
104
diff
changeset
|
40 >>> [i for i in TimeInterval(9,13)] |
916678481896
corrected bug for TimeInterval interation and added corresponding test
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
104
diff
changeset
|
41 [9, 10, 11, 12, 13] |
916678481896
corrected bug for TimeInterval interation and added corresponding test
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
104
diff
changeset
|
42 |
96
9928c2fa72cc
added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
92
diff
changeset
|
43 >>> TimeInterval(2,5).equal(TimeInterval(2,5)) |
9928c2fa72cc
added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
92
diff
changeset
|
44 True |
9928c2fa72cc
added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
92
diff
changeset
|
45 >>> TimeInterval(2,5).equal(TimeInterval(2,4)) |
9928c2fa72cc
added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
92
diff
changeset
|
46 False |
9928c2fa72cc
added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
92
diff
changeset
|
47 >>> TimeInterval(2,5).equal(TimeInterval(5,2)) |
9928c2fa72cc
added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
92
diff
changeset
|
48 False |
9928c2fa72cc
added equal method to intervals
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
92
diff
changeset
|
49 |
248
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
50 >>> TimeInterval(3,6).distance(TimeInterval(4,6)) |
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
51 0 |
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
52 >>> TimeInterval(3,6).distance(TimeInterval(6,10)) |
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
53 0 |
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
54 >>> TimeInterval(3,6).distance(TimeInterval(8,10)) |
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
55 2 |
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
56 >>> TimeInterval(20,30).distance(TimeInterval(3,15)) |
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
57 5 |
732
ad31520e81b5
modification for moving tests (unionIntrvals)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
682
diff
changeset
|
58 >>> TimeInterval.unionIntervals([TimeInterval(3,6), TimeInterval(8,10),TimeInterval(11,15)]) |
1064
cbc026dacf0b
changed interval string representation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1041
diff
changeset
|
59 3-15 |
248
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
60 |
776
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
61 >>> Point(0,3) == Point(0,3) |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
62 True |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
63 >>> Point(0,3) == Point(0,3.2) |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
64 False |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
65 >>> Point(3,4)-Point(1,7) |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
66 (2.000000,-3.000000) |
451
cd342a774806
Point/CurvilinearTrajectory/Interaction utiles
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
372
diff
changeset
|
67 >>> -Point(1,2) |
cd342a774806
Point/CurvilinearTrajectory/Interaction utiles
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
372
diff
changeset
|
68 (-1.000000,-2.000000) |
940
d8ab183a7351
verified motion prediction with prototypes at constant speed (test needed)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
918
diff
changeset
|
69 >>> Point(1,2)*0.5 |
571
a9c1d61a89b4
corrected bug for segment intersection
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
569
diff
changeset
|
70 (0.500000,1.000000) |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
71 |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
72 >>> Point(3,2).norm2Squared() |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
73 13 |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
74 |
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
75 >>> Point.distanceNorm2(Point(3,4),Point(1,7)) |
248
571ba5ed22e2
added utils for bus processing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
76 3.605551275463989 |
43
6d11d9e7ad4e
methods for trajectories and objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
77 |
1106
799ef82caa1a
added code to compute bounding rectangle around each user
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1097
diff
changeset
|
78 >>> Point.boundingRectangle([Point(0,0), Point(1,0), Point(0,1), Point(1,1)], Point(1, 1)) |
799ef82caa1a
added code to compute bounding rectangle around each user
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1097
diff
changeset
|
79 [(0.500000,1.500000), (1.500000,0.500000), (0.500000,-0.500000), (-0.500000,0.500000)] |
799ef82caa1a
added code to compute bounding rectangle around each user
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1097
diff
changeset
|
80 >>> Point.boundingRectangle([Point(0,0), Point(1,0), Point(0,1), Point(1,1)], Point(-1, -1)) |
799ef82caa1a
added code to compute bounding rectangle around each user
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1097
diff
changeset
|
81 [(0.500000,-0.500000), (-0.500000,0.500000), (0.500000,1.500000), (1.500000,0.500000)] |
799ef82caa1a
added code to compute bounding rectangle around each user
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1097
diff
changeset
|
82 |
799ef82caa1a
added code to compute bounding rectangle around each user
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1097
diff
changeset
|
83 |
631
2d1d33ae1c69
major work on pPET and pet, issues remain for pPET computed with predicted trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
595
diff
changeset
|
84 >>> Point(3,2).inPolygon(np.array([[0,0],[1,0],[1,1],[0,1]])) |
79
5d487f183fe2
added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
69
diff
changeset
|
85 False |
631
2d1d33ae1c69
major work on pPET and pet, issues remain for pPET computed with predicted trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
595
diff
changeset
|
86 >>> Point(3,2).inPolygon(np.array([[0,0],[4,0],[4,3],[0,3]])) |
79
5d487f183fe2
added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
69
diff
changeset
|
87 True |
5d487f183fe2
added method to test points in polygons and tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
69
diff
changeset
|
88 |
255
13ec22bec5d4
corrected typos and bugs and added a test
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
249
diff
changeset
|
89 >>> predictPositionNoLimit(10, Point(0,0), Point(1,1)) # doctest:+ELLIPSIS |
13ec22bec5d4
corrected typos and bugs and added a test
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
249
diff
changeset
|
90 ((1.0...,1.0...), (10.0...,10.0...)) |
249
99173da7afae
corrected small bugs and typos
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
248
diff
changeset
|
91 |
569
0057c04f94d5
work in progress on intersections (for PET)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
542
diff
changeset
|
92 >>> segmentIntersection(Point(0,0), Point(0,1), Point(1,1), Point(2,3)) |
1170
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
93 (None, None) |
569
0057c04f94d5
work in progress on intersections (for PET)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
542
diff
changeset
|
94 >>> segmentIntersection(Point(0,1), Point(0,3), Point(1,0), Point(3,1)) |
1170
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
95 (None, None) |
571
a9c1d61a89b4
corrected bug for segment intersection
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
569
diff
changeset
|
96 >>> segmentIntersection(Point(0.,0.), Point(2.,2.), Point(0.,2.), Point(2.,0.)) |
1170
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
97 ((1.000000,1.000000), 0.5) |
674
01b89182891a
corrected bug for intersection of lines (thanks to Paul for finding)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
661
diff
changeset
|
98 >>> segmentIntersection(Point(0,0), Point(4,4), Point(0,4), Point(4,0)) |
1170
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
99 ((2.000000,2.000000), 0.5) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
100 >>> segmentIntersection(Point(0,0), Point(0,3), Point(1,1), Point(-1,1)) # doctest:+ELLIPSIS |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
101 ((0.000000,1.000000), 0.333...) |
569
0057c04f94d5
work in progress on intersections (for PET)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
542
diff
changeset
|
102 >>> segmentIntersection(Point(0,1), Point(1,2), Point(2,0), Point(3,2)) |
1170
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
103 (None, None) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
104 |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
105 >>> segmentOrientationCrossing(Point(0.,0.), Point(2.,2.), Point(0.,2.), Point(2.,0.)) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
106 False |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
107 >>> segmentOrientationCrossing(Point(0.,0.), Point(2.,2.), Point(2.,0.), Point(0.,2.)) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
108 True |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
109 >>> segmentOrientationCrossing(Point(0,0), Point(0,3), Point(1,1), Point(-1,1)) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
110 True |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
111 |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
112 >>> o1 = MovingObject.generate(1, Point(1.,0.), Point(1.,0.), TimeInterval(0,10)) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
113 >>> instants, intersections, rightToLeftOrientations = o1.getInstantsCrossingLine(Point(0.,3.5), Point(2.,3.5)) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
114 >>> rightToLeftOrientations == [] |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
115 True |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
116 >>> len(instants) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
117 0 |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
118 >>> o1 = MovingObject.generate(1, Point(0.,1.), Point(1.,0.), TimeInterval(0,10)) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
119 >>> instants, intersections, rightToLeftOrientations = o1.getInstantsCrossingLine(Point(3.5,0.), Point(3.5, 2.), False) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
120 >>> rightToLeftOrientations == [] |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
121 True |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
122 >>> instants[0] |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
123 3.5 |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
124 >>> instants, intersections, rightToLeftOrientations = o1.getInstantsCrossingLine(Point(3.5,0.), Point(3.5, 2.), True) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
125 >>> len(rightToLeftOrientations) |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
126 1 |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
127 >>> rightToLeftOrientations[0] |
b55adb13f262
added functions on line crossing orientation and important reorganization and cleaning of related code
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1134
diff
changeset
|
128 False |
569
0057c04f94d5
work in progress on intersections (for PET)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
542
diff
changeset
|
129 |
776
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
130 >>> t1 = Trajectory.fromPointList([(92.2, 102.9), (56.7, 69.6)]) |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
131 >>> t2 = Trajectory.fromPointList([(92.2, 102.9), (56.7, 69.6)]) |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
132 >>> t1 == t2 |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
133 True |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
134 >>> t3 = Trajectory.fromPointList([(92.24, 102.9), (56.7, 69.6)]) |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
135 >>> t1 == t3 |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
136 False |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
137 >>> t3 = Trajectory.fromPointList([(92.2, 102.9), (56.7, 69.6), (56.7, 69.6)]) |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
138 >>> t1 == t3 |
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
139 False |
1177
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
140 >>> t1.append(t2) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
141 >>> t1.length() |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
142 4 |
776
84420159c5f4
added __eq__ functions for Point and Trajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
768
diff
changeset
|
143 |
577
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
144 >>> left = Trajectory.fromPointList([(92.291666666666686, 102.99239033124439), (56.774193548387103, 69.688898836168306)]) |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
145 >>> middle = Trajectory.fromPointList([(87.211021505376351, 93.390778871978512), (59.032258064516128, 67.540286481647257)]) |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
146 >>> right = Trajectory.fromPointList([(118.82392473118281, 115.68263205013426), (63.172043010752688, 66.600268576544309)]) |
569
0057c04f94d5
work in progress on intersections (for PET)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
542
diff
changeset
|
147 >>> alignments = [left, middle, right] |
577
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
148 >>> for a in alignments: a.computeCumulativeDistances() |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
149 >>> getSYfromXY(Point(73, 82), alignments) |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
150 [1, 0, (73.819977,81.106170), 18.172277808821125, 18.172277808821125, 1.2129694042343868] |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
151 >>> getSYfromXY(Point(78, 83), alignments, 0.5) |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
152 [1, 0, (77.033188,84.053889), 13.811799123113715, 13.811799123113715, -1.4301775140225983] |
152
74b1fc68d4df
re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
113
diff
changeset
|
153 |
113
606010d1d9a4
corrected errors in trajectories (if empty) and getTrajectoryInPolygon
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
107
diff
changeset
|
154 >>> Trajectory().length() |
606010d1d9a4
corrected errors in trajectories (if empty) and getTrajectoryInPolygon
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
107
diff
changeset
|
155 0 |
69
cc192d0450b3
added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
43
diff
changeset
|
156 >>> t1 = Trajectory([[0.5,1.5,2.5],[0.5,3.5,6.5]]) |
1177
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
157 >>> t1.length() |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
158 3 |
69
cc192d0450b3
added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
43
diff
changeset
|
159 >>> t1[1] |
cc192d0450b3
added full support for two implementations of indicators, with tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
43
diff
changeset
|
160 (1.500000,3.500000) |
284
f2cf16ad798f
added LCSS for trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
255
diff
changeset
|
161 |
542
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
162 >>> t1.differentiate() |
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
163 (1.000000,3.000000) (1.000000,3.000000) |
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
164 >>> t1.differentiate(True) |
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
165 (1.000000,3.000000) (1.000000,3.000000) (1.000000,3.000000) |
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
166 >>> t1 = Trajectory([[0.5,1.5,3.5],[0.5,2.5,7.5]]) |
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
167 >>> t1.differentiate() |
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
168 (1.000000,2.000000) (2.000000,5.000000) |
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
169 |
576
0eff0471f9cb
added functions to use trajectories as alignments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
573
diff
changeset
|
170 >>> t1.computeCumulativeDistances() |
0eff0471f9cb
added functions to use trajectories as alignments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
573
diff
changeset
|
171 >>> t1.getDistance(0) |
0eff0471f9cb
added functions to use trajectories as alignments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
573
diff
changeset
|
172 2.23606797749979 |
0eff0471f9cb
added functions to use trajectories as alignments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
573
diff
changeset
|
173 >>> t1.getDistance(1) |
0eff0471f9cb
added functions to use trajectories as alignments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
573
diff
changeset
|
174 5.385164807134504 |
577
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
175 >>> t1.getDistance(2) |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
176 Index 2 beyond trajectory length 3-1 |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
177 >>> t1.getCumulativeDistance(0) |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
178 0.0 |
576
0eff0471f9cb
added functions to use trajectories as alignments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
573
diff
changeset
|
179 >>> t1.getCumulativeDistance(1) |
577
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
180 2.23606797749979 |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
181 >>> t1.getCumulativeDistance(2) |
576
0eff0471f9cb
added functions to use trajectories as alignments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
573
diff
changeset
|
182 7.6212327846342935 |
577
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
183 >>> t1.getCumulativeDistance(3) |
d0abd2ee17b9
changed arguments to type Point
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
576
diff
changeset
|
184 Index 3 beyond trajectory length 3 |
576
0eff0471f9cb
added functions to use trajectories as alignments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
573
diff
changeset
|
185 |
0eff0471f9cb
added functions to use trajectories as alignments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
573
diff
changeset
|
186 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
345
diff
changeset
|
187 >>> from utils import LCSS |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
345
diff
changeset
|
188 >>> lcss = LCSS(lambda x,y: Point.distanceNorm2(x,y) <= 0.1) |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
345
diff
changeset
|
189 >>> Trajectory.lcss(t1, t1, lcss) |
284
f2cf16ad798f
added LCSS for trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
255
diff
changeset
|
190 3 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
345
diff
changeset
|
191 >>> lcss = LCSS(lambda p1, p2: (p1-p2).normMax() <= 0.1) |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
345
diff
changeset
|
192 >>> Trajectory.lcss(t1, t1, lcss) |
284
f2cf16ad798f
added LCSS for trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
255
diff
changeset
|
193 3 |
345
fa64b2e3a64f
added simple classification based on speed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
284
diff
changeset
|
194 |
504
a40c75f04903
optimized direct time to collision computation and added tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
451
diff
changeset
|
195 >>> p1=Point(0,0) |
a40c75f04903
optimized direct time to collision computation and added tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
451
diff
changeset
|
196 >>> p2=Point(1,0) |
a40c75f04903
optimized direct time to collision computation and added tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
451
diff
changeset
|
197 >>> v1 = Point(0.1,0.1) |
a40c75f04903
optimized direct time to collision computation and added tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
451
diff
changeset
|
198 >>> v2 = Point(-0.1, 0.1) |
a40c75f04903
optimized direct time to collision computation and added tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
451
diff
changeset
|
199 >>> abs(Point.timeToCollision(p1, p2, v1, v2, 0.)-5.0) < 0.00001 |
a40c75f04903
optimized direct time to collision computation and added tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
451
diff
changeset
|
200 True |
a40c75f04903
optimized direct time to collision computation and added tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
451
diff
changeset
|
201 >>> abs(Point.timeToCollision(p1, p2, v1, v2, 0.1)-4.5) < 0.00001 |
a40c75f04903
optimized direct time to collision computation and added tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
451
diff
changeset
|
202 True |
531
f012a8ad7a0e
corrected bug in Point.timeToCollision that might result in negative TTCs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
524
diff
changeset
|
203 >>> p1=Point(0,1) |
f012a8ad7a0e
corrected bug in Point.timeToCollision that might result in negative TTCs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
524
diff
changeset
|
204 >>> p2=Point(1,0) |
f012a8ad7a0e
corrected bug in Point.timeToCollision that might result in negative TTCs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
524
diff
changeset
|
205 >>> v1 = Point(0,0.1) |
f012a8ad7a0e
corrected bug in Point.timeToCollision that might result in negative TTCs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
524
diff
changeset
|
206 >>> v2 = Point(0.1, 0) |
f012a8ad7a0e
corrected bug in Point.timeToCollision that might result in negative TTCs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
524
diff
changeset
|
207 >>> Point.timeToCollision(p1, p2, v1, v2, 0.) == None |
f012a8ad7a0e
corrected bug in Point.timeToCollision that might result in negative TTCs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
524
diff
changeset
|
208 True |
f012a8ad7a0e
corrected bug in Point.timeToCollision that might result in negative TTCs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
524
diff
changeset
|
209 >>> Point.timeToCollision(p2, p1, v2, v1, 0.) == None |
f012a8ad7a0e
corrected bug in Point.timeToCollision that might result in negative TTCs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
524
diff
changeset
|
210 True |
583
6ebfb43e938e
added midpoint function (from laurent gauthier)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
582
diff
changeset
|
211 >>> Point.midPoint(p1, p2) |
6ebfb43e938e
added midpoint function (from laurent gauthier)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
582
diff
changeset
|
212 (0.500000,0.500000) |
987
f026ce2af637
found bug with direct ttc computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
959
diff
changeset
|
213 >>> p1=Point(0.,0.) |
f026ce2af637
found bug with direct ttc computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
959
diff
changeset
|
214 >>> p2=Point(5.,0.) |
f026ce2af637
found bug with direct ttc computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
959
diff
changeset
|
215 >>> v1 = Point(2.,0.) |
f026ce2af637
found bug with direct ttc computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
959
diff
changeset
|
216 >>> v2 = Point(1.,0.) |
f026ce2af637
found bug with direct ttc computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
959
diff
changeset
|
217 >>> Point.timeToCollision(p1, p2, v1, v2, 0.) |
f026ce2af637
found bug with direct ttc computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
959
diff
changeset
|
218 5.0 |
f026ce2af637
found bug with direct ttc computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
959
diff
changeset
|
219 >>> Point.timeToCollision(p1, p2, v1, v2, 1.) |
f026ce2af637
found bug with direct ttc computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
959
diff
changeset
|
220 4.0 |
504
a40c75f04903
optimized direct time to collision computation and added tests
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
451
diff
changeset
|
221 |
661
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
222 >>> objects = storage.loadTrajectoriesFromSqlite('../samples/laurier.sqlite', 'object') |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
223 >>> len(objects) |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
224 5 |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
225 >>> objects[0].hasFeatures() |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
226 False |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
227 >>> features = storage.loadTrajectoriesFromSqlite('../samples/laurier.sqlite', 'feature') |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
228 >>> for o in objects: o.setFeatures(features) |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
229 >>> objects[0].hasFeatures() |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
230 True |
dc70d9e711f5
some method name change and new methods for features in objects (MovingObject) and methods to access indicator values in interactions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
631
diff
changeset
|
231 |
918
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
887
diff
changeset
|
232 >>> o1 = MovingObject.generate(1, Point(-5.,0.), Point(1.,0.), TimeInterval(0,10)) |
1041
fc7c0f38e8a6
added nObjects to MovingObject, with loading/saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1030
diff
changeset
|
233 >>> o1.getNObjects() is None |
fc7c0f38e8a6
added nObjects to MovingObject, with loading/saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1030
diff
changeset
|
234 True |
fc7c0f38e8a6
added nObjects to MovingObject, with loading/saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1030
diff
changeset
|
235 >>> o1.setNObjects(1.1) |
fc7c0f38e8a6
added nObjects to MovingObject, with loading/saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1030
diff
changeset
|
236 >>> o1.setNObjects(0.5) |
fc7c0f38e8a6
added nObjects to MovingObject, with loading/saving
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1030
diff
changeset
|
237 Number of objects represented by object 1 must be greater or equal to 1 (0.5) |
918
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
887
diff
changeset
|
238 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(0,10)) |
631
2d1d33ae1c69
major work on pPET and pet, issues remain for pPET computed with predicted trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
595
diff
changeset
|
239 >>> MovingObject.computePET(o1, o2, 0.1) |
887
e2452abba0e7
added option to compute PET in safety analysis script, and save in database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
776
diff
changeset
|
240 (0.0, 5, 5) |
918
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
887
diff
changeset
|
241 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(5,15)) |
631
2d1d33ae1c69
major work on pPET and pet, issues remain for pPET computed with predicted trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
595
diff
changeset
|
242 >>> MovingObject.computePET(o1, o2, 0.1) |
887
e2452abba0e7
added option to compute PET in safety analysis script, and save in database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
776
diff
changeset
|
243 (5.0, 5, 10) |
918
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
887
diff
changeset
|
244 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(15,30)) |
887
e2452abba0e7
added option to compute PET in safety analysis script, and save in database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
776
diff
changeset
|
245 >>> MovingObject.computePET(o1, o2, 0.1) |
e2452abba0e7
added option to compute PET in safety analysis script, and save in database
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
776
diff
changeset
|
246 (15.0, 5, 20) |
631
2d1d33ae1c69
major work on pPET and pet, issues remain for pPET computed with predicted trajectories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
595
diff
changeset
|
247 |
1094
c96388c696ac
adding functions for simulation, with contribution from student Lionel Nebot-Janvier, lionel.nebot-janvier@polymtl.ca
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1086
diff
changeset
|
248 >>> t1 = CurvilinearTrajectory.generate(3, 1., 10, 'b') |
c96388c696ac
adding functions for simulation, with contribution from student Lionel Nebot-Janvier, lionel.nebot-janvier@polymtl.ca
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1086
diff
changeset
|
249 >>> t1.length() |
1085
7853106677b7
added generate static function for CurvilinearTrajectory and modified how to create them with None list in lanes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1064
diff
changeset
|
250 10 |
1094
c96388c696ac
adding functions for simulation, with contribution from student Lionel Nebot-Janvier, lionel.nebot-janvier@polymtl.ca
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1086
diff
changeset
|
251 >>> t1[3] |
1085
7853106677b7
added generate static function for CurvilinearTrajectory and modified how to create them with None list in lanes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1064
diff
changeset
|
252 [6.0, 0, 'b'] |
1097
b3f8b26ee838
modification for simulation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1094
diff
changeset
|
253 >>> t2 = CurvilinearTrajectory.generate(15, 1., 10, 'a', 1.) |
1094
c96388c696ac
adding functions for simulation, with contribution from student Lionel Nebot-Janvier, lionel.nebot-janvier@polymtl.ca
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1086
diff
changeset
|
254 >>> t2[4] |
1097
b3f8b26ee838
modification for simulation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1094
diff
changeset
|
255 [19.0, 1.0, 'a'] |
1094
c96388c696ac
adding functions for simulation, with contribution from student Lionel Nebot-Janvier, lionel.nebot-janvier@polymtl.ca
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1086
diff
changeset
|
256 >>> t1.append(t2) |
c96388c696ac
adding functions for simulation, with contribution from student Lionel Nebot-Janvier, lionel.nebot-janvier@polymtl.ca
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1086
diff
changeset
|
257 >>> t1.length() |
c96388c696ac
adding functions for simulation, with contribution from student Lionel Nebot-Janvier, lionel.nebot-janvier@polymtl.ca
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1086
diff
changeset
|
258 20 |
1097
b3f8b26ee838
modification for simulation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1094
diff
changeset
|
259 >>> t1[9] |
b3f8b26ee838
modification for simulation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1094
diff
changeset
|
260 [12.0, 0, 'b'] |
b3f8b26ee838
modification for simulation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1094
diff
changeset
|
261 >>> o = MovingObject(0, TimeInterval(1,21)) |
b3f8b26ee838
modification for simulation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1094
diff
changeset
|
262 >>> o.curvilinearPositions = t1 |
b3f8b26ee838
modification for simulation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1094
diff
changeset
|
263 >>> o.interpolateCurvilinearPositions(2.3) |
b3f8b26ee838
modification for simulation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1094
diff
changeset
|
264 [4.3, 0.0, 'b'] |
1114
7135b5eaa6b4
correcting poor requirement for interpolateCurvilinearPositions (when changing alignment)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1110
diff
changeset
|
265 >>> o.interpolateCurvilinearPositions(9.7) # doctest:+ELLIPSIS |
7135b5eaa6b4
correcting poor requirement for interpolateCurvilinearPositions (when changing alignment)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1110
diff
changeset
|
266 [11.7..., 0.0..., 'b'] |
7135b5eaa6b4
correcting poor requirement for interpolateCurvilinearPositions (when changing alignment)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1110
diff
changeset
|
267 >>> o.interpolateCurvilinearPositions(10.7) |
1116
a3982d591a61
placeholder implementation for interpolateCurvilinearPositions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1114
diff
changeset
|
268 Object 0 changes lane at 10.7 and alignments are not provided |
1114
7135b5eaa6b4
correcting poor requirement for interpolateCurvilinearPositions (when changing alignment)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1110
diff
changeset
|
269 >>> t2 = CurvilinearTrajectory.generate(0, 1., 10, 'a', 1.) |
1085
7853106677b7
added generate static function for CurvilinearTrajectory and modified how to create them with None list in lanes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1064
diff
changeset
|
270 |
1110
6bbcd9433732
formatting and addition of one method to CurvilinearTrajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1106
diff
changeset
|
271 >>> t1 = CurvilinearTrajectory.generate(3, 1., 10, 'b') |
6bbcd9433732
formatting and addition of one method to CurvilinearTrajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1106
diff
changeset
|
272 >>> t1.duplicateLastPosition() |
6bbcd9433732
formatting and addition of one method to CurvilinearTrajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1106
diff
changeset
|
273 >>> t1[-1] == t1[-2] |
6bbcd9433732
formatting and addition of one method to CurvilinearTrajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1106
diff
changeset
|
274 True |
6bbcd9433732
formatting and addition of one method to CurvilinearTrajectory
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1106
diff
changeset
|
275 |
1086
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
276 >>> a = Trajectory.generate(Point(0.,0.), Point(10.,0.), 4) |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
277 >>> t = Trajectory.generate(Point(0.1,-1.), Point(1.,0.), 22) |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
278 >>> prepareAlignments([a]) |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
279 >>> ct = CurvilinearTrajectory.fromTrajectoryProjection(t, [a]) |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
280 >>> ct[3] |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
281 [3.1, 1.0, 0] |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
282 >>> p = getXYfromSY(ct[3][0], ct[3][1], ct[3][2], [a]) |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
283 >>> (Point(p[0], p[1])-t[3]).norm2() < 1e-10 |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
284 True |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
285 >>> p = getXYfromSY(ct[21][0], ct[21][1], ct[21][2], [a]) |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
286 >>> (Point(p[0], p[1])-t[21]).norm2() < 1e-10 |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
287 True |
8734742c08c0
major refactoring of curvilinear trajectory projections
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1085
diff
changeset
|
288 |
542
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
289 >>> t = CurvilinearTrajectory(S = [1., 2., 3., 5.], Y = [0.5, 0.5, 0.6, 0.7], lanes = ['1']*4) |
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
290 >>> t.differentiate() # doctest:+ELLIPSIS |
1085
7853106677b7
added generate static function for CurvilinearTrajectory and modified how to create them with None list in lanes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1064
diff
changeset
|
291 [1.0, 0.0, None] [1.0, 0.099..., None] [2.0, 0.099..., None] |
542
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
292 >>> t.differentiate(True) # doctest:+ELLIPSIS |
1085
7853106677b7
added generate static function for CurvilinearTrajectory and modified how to create them with None list in lanes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1064
diff
changeset
|
293 [1.0, 0.0, None] [1.0, 0.099..., None] [2.0, 0.099..., None] [2.0, 0.099..., None] |
582
7e1ae4d97f1a
corrected bug for curvilinear trajectory with only one position and differentiation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
577
diff
changeset
|
294 >>> t = CurvilinearTrajectory(S = [1.], Y = [0.5], lanes = ['1']) |
7e1ae4d97f1a
corrected bug for curvilinear trajectory with only one position and differentiation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
577
diff
changeset
|
295 >>> t.differentiate().empty() |
7e1ae4d97f1a
corrected bug for curvilinear trajectory with only one position and differentiation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
577
diff
changeset
|
296 True |
542
a3add9f751ef
added differentiate function for curvilinear trajectories and modified the addPosition functions
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
531
diff
changeset
|
297 |
1018
d7afc59f6966
work in progress
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
998
diff
changeset
|
298 >>> o1 = MovingObject.generate(1, Point(1., 2.), Point(1., 1.), TimeInterval(0,10)) |
1019
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
299 >>> o1.features = [o1] |
1018
d7afc59f6966
work in progress
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
998
diff
changeset
|
300 >>> o2 = MovingObject.generate(2, Point(14., 14.), Point(1., 0.), TimeInterval(14,20)) |
1019
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
301 >>> o2.features = [o2] |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
302 >>> o3 = MovingObject.generate(3, Point(2., 2.), Point(1., 1.), TimeInterval(2,12)) |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
303 >>> o3.features = [o3] |
1177
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
304 >>> o4 = MovingObject.generate(4, Point(4., 4.), Point(1., 1.), TimeInterval(11,20)) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
305 >>> o4.features = [o4] |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
306 >>> o5 = MovingObject.generate(5, Point(5., 5.), Point(1., 1.), TimeInterval(12,22)) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
307 >>> o5.features = [o5] |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
308 |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
309 >>> objNum = 14 |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
310 >>> o13, f13 = MovingObject.concatenate(o1, o3, objNum) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
311 >>> o13.getNum() == objNum |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
312 True |
1019
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
313 >>> o13.getTimeInterval() == TimeInterval(0,12) |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
314 True |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
315 >>> t=5 |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
316 >>> o13.getPositionAtInstant(t) == (o1.getPositionAtInstant(t)+o3.getPositionAtInstant(t)).divide(2) |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
317 True |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
318 >>> len(o13.getFeatures()) |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
319 2 |
1134
4b2a55d570c1
resolve issue for short features when merging objects manually
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1133
diff
changeset
|
320 |
1177
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
321 >>> o12, f12 = MovingObject.concatenate(o1, o2, 15, 15) |
1019
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
322 >>> o12.getTimeInterval() == TimeInterval(o1.getFirstInstant(), o2.getLastInstant()) |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
323 True |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
324 >>> v = o12.getVelocityAtInstant(12) |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
325 >>> v == Point(3./4, 2./4) |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
326 True |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
327 >>> o12.getPositionAtInstant(11) == o1.getPositionAtInstant(10)+v |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
328 True |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
329 >>> len(o12.getFeatures()) |
5d2f6afae35b
work on object concatenation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1018
diff
changeset
|
330 3 |
1177
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
331 >>> f12.length() |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
332 5.0 |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
333 >>> f12.getPositions().length() |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
334 5 |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
335 >>> f12.getVelocities().length() |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
336 5 |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
337 |
1180
dc28364f34b9
minor cleanup
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1177
diff
changeset
|
338 >>> o14, f14 = MovingObject.concatenate(o1, o4, 16, 16) |
1177
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
339 >>> len(o14.getFeatures()) |
1180
dc28364f34b9
minor cleanup
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1177
diff
changeset
|
340 3 |
1177
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
341 >>> o14.getPositionAtInstant(10) == o1.getPositionAtInstant(10) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
342 True |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
343 >>> o14.getPositionAtInstant(11) == o4.getPositionAtInstant(11) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
344 True |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
345 |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
346 >>> o15, f15 = MovingObject.concatenate(o1, o5, 17, 17) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
347 >>> len(o15.getFeatures()) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
348 3 |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
349 >>> f15.length() |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
350 3.0 |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
351 >>> o15.getFeatures()[-1] == f15 |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
352 True |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
353 >>> o1.getPositionAtInstant(10) == o15.getPositionAtInstant(10) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
354 True |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
355 >>> f15.getPositionAtInstant(11) == o15.getPositionAtInstant(11) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
356 True |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
357 >>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
358 True |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
359 >>> o15.updatePositions() |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
360 >>> o1.getPositionAtInstant(10) == o15.getPositionAtInstant(10) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
361 True |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
362 >>> f15.getPositionAtInstant(11) == o15.getPositionAtInstant(11) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
363 True |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
364 >>> o5.getPositionAtInstant(12) == o15.getPositionAtInstant(12) |
aa88acf06876
rewrote object concatenation method, cleaner
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1170
diff
changeset
|
365 True |
1018
d7afc59f6966
work in progress
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
998
diff
changeset
|
366 |
918
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
887
diff
changeset
|
367 >>> o1 = MovingObject.generate(1, Point(0., 2.), Point(0., 1.), TimeInterval(0,2)) |
524
1dced8932b08
corrected bugs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
504
diff
changeset
|
368 >>> o1.classifyUserTypeSpeedMotorized(0.5, np.median) |
345
fa64b2e3a64f
added simple classification based on speed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
284
diff
changeset
|
369 >>> userTypeNames[o1.getUserType()] |
fa64b2e3a64f
added simple classification based on speed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
284
diff
changeset
|
370 'car' |
524
1dced8932b08
corrected bugs
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
504
diff
changeset
|
371 >>> o1.classifyUserTypeSpeedMotorized(1.5, np.median) |
345
fa64b2e3a64f
added simple classification based on speed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
284
diff
changeset
|
372 >>> userTypeNames[o1.getUserType()] |
fa64b2e3a64f
added simple classification based on speed
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
284
diff
changeset
|
373 'pedestrian' |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
374 |
918
3a06007a4bb7
modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
887
diff
changeset
|
375 >>> o1 = MovingObject.generate(1, Point(0.,0.), Point(1.,0.), TimeInterval(0,10)) |
1133
c4d9c270f999
modification for performance computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1116
diff
changeset
|
376 >>> gt1 = BBMovingObject(MovingObject.generate(1, Point(0.2,0.6), Point(1.,0.), TimeInterval(0,10)), MovingObject.generate(2, Point(-0.2,-0.4), Point(1.,0.), TimeInterval(0,10)), 1, TimeInterval(0,10), ) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
377 >>> gt1.computeCentroidTrajectory() |
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
378 >>> computeClearMOT([gt1], [], 0.2, 0, 10) |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
379 (None, 0.0, 11, 0, 0, 11, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
380 >>> computeClearMOT([], [o1], 0.2, 0, 10) |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
381 (None, None, 0, 0, 11, 0, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
382 >>> computeClearMOT([gt1], [o1], 0.2, 0, 10) # doctest:+ELLIPSIS |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
383 (0.0999..., 1.0, 0, 0, 0, 11, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
384 >>> computeClearMOT([gt1], [o1], 0.05, 0, 10) |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
385 (None, -1.0, 11, 0, 11, 11, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
386 |
998
933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
987
diff
changeset
|
387 >>> o1 = MovingObject(1, TimeInterval(0,3), positions = Trajectory([list(range(4)), [0.1, 0.1, 1.1, 1.1]])) |
933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
987
diff
changeset
|
388 >>> o2 = MovingObject(2, TimeInterval(0,3), positions = Trajectory([list(range(4)), [0.9, 0.9, -0.1, -0.1]])) |
1133
c4d9c270f999
modification for performance computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1116
diff
changeset
|
389 >>> gt1 = BBMovingObject(MovingObject(positions = Trajectory([list(range(4)), [0.]*4])), MovingObject(positions = Trajectory([list(range(4)), [0.]*4])), 1, TimeInterval(0,3)) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
390 >>> gt1.computeCentroidTrajectory() |
1133
c4d9c270f999
modification for performance computation
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1116
diff
changeset
|
391 >>> gt2 = BBMovingObject(MovingObject(positions = Trajectory([list(range(4)), [1.]*4])), MovingObject(positions = Trajectory([list(range(4)), [1.]*4])), 2, TimeInterval(0,3)) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
392 >>> gt2.computeCentroidTrajectory() |
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
393 >>> computeClearMOT([gt1, gt2], [o1, o2], 0.2, 0, 3) # doctest:+ELLIPSIS |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
394 (0.1..., 0.75, 0, 2, 0, 8, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
395 >>> computeClearMOT([gt2, gt1], [o2, o1], 0.2, 0, 3) # doctest:+ELLIPSIS |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
396 (0.1..., 0.75, 0, 2, 0, 8, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
397 >>> computeClearMOT([gt1], [o1, o2], 0.2, 0, 3) |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
398 (0.1, -0.25, 0, 1, 4, 4, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
399 >>> computeClearMOT([gt1], [o2, o1], 0.2, 0, 3) # symmetry |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
400 (0.1, -0.25, 0, 1, 4, 4, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
401 >>> computeClearMOT([gt1, gt2], [o1], 0.2, 0, 3) # doctest:+ELLIPSIS |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
402 (0.100..., 0.375, 4, 1, 0, 8, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
403 >>> computeClearMOT([gt2, gt1], [o1], 0.2, 0, 3) # doctest:+ELLIPSIS |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
404 (0.100..., 0.375, 4, 1, 0, 8, None, None) |
595
17b02c8054d0
added tests and corrected one bug
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
583
diff
changeset
|
405 >>> computeClearMOT([gt1, gt2], [o1, o2], 0.08, 0, 3) |
959
4f32d82ca390
corrected error due to change in Hog (scikit image)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
940
diff
changeset
|
406 (None, -1.0, 8, 0, 8, 8, None, None) |