Mercurial > hg > nsaunier > traffic-intelligence
comparison python/moving.py @ 21:3c4629550f5f
added basic getters for objects
| author | Nicolas Saunier <nico@confins.net> |
|---|---|
| date | Mon, 30 Nov 2009 18:54:26 -0500 |
| parents | 5a21d2cfee44 |
| children | 169cd4679366 |
comparison
equal
deleted
inserted
replaced
| 20:ef0d7caf8e91 | 21:3c4629550f5f |
|---|---|
| 104 | 104 |
| 105 def draw(self): | 105 def draw(self): |
| 106 from matplotlib.pylab import plot | 106 from matplotlib.pylab import plot |
| 107 plot(self.positions[0], self.positions[1]) | 107 plot(self.positions[0], self.positions[1]) |
| 108 | 108 |
| 109 def length(self): | |
| 110 return len(self.getXCoordinates()) | |
| 111 | |
| 112 def getXCoordinates(self): | |
| 113 return self.positions[0] | |
| 114 | |
| 115 def getYCoordinates(self): | |
| 116 return self.positions[1] | |
| 117 | |
| 109 def xBounds(self): | 118 def xBounds(self): |
| 110 # look for function that does min and max in one pass | 119 # look for function that does min and max in one pass |
| 111 return [min(self.positions[0]), max(self.positions[0])] | 120 return [min(self.getXCoordinates()), max(self.getXCoordinates())] |
| 112 | 121 |
| 113 def yBounds(self): | 122 def yBounds(self): |
| 114 # look for function that does min and max in one pass | 123 # look for function that does min and max in one pass |
| 115 return [min(self.positions[1]), max(self.positions[1])] | 124 return [min(self.getYCoordinates()), max(self.getYCoordinates())] |
| 116 | 125 |
| 117 def norm(self): | 126 def norm(self): |
| 118 '''Returns the list of the norms at each instant''' | 127 '''Returns the list of the norms at each instant''' |
| 119 # def add(x, y): return x+y | 128 # def add(x, y): return x+y |
| 120 # sq = map(add, [x*x for x in self.positions[0]], [y*y for y in self.positions[1]]) | 129 # sq = map(add, [x*x for x in self.positions[0]], [y*y for y in self.positions[1]]) |
| 121 # return sqrt(sq) | 130 # return sqrt(sq) |
| 137 self.positions = positions | 146 self.positions = positions |
| 138 self.geometry = geometry | 147 self.geometry = geometry |
| 139 self.type = type | 148 self.type = type |
| 140 # compute bounding polygon from trajectory | 149 # compute bounding polygon from trajectory |
| 141 | 150 |
| 151 def length(self): | |
| 152 return self.timeInterval.length() | |
| 153 | |
| 154 def getXCoordinates(self): | |
| 155 return self.positions.getXCoordinates() | |
| 156 | |
| 157 def getYCoordinates(self): | |
| 158 return self.positions.getYCoordinates() | |
| 159 | |
| 142 def draw(self): | 160 def draw(self): |
| 143 self.positions.draw() | 161 self.positions.draw() |
| 144 | 162 |
| 145 # def computeVelocities(self): | 163 # def computeVelocities(self): |
| 146 | 164 |
| 147 # need for a class representing the indicators, their units, how to print them in graphs... | 165 # need for a class representing the indicators, their units, how to print them in graphs... |
| 148 class TemporalIndicator: | 166 class TemporalIndicator: |
| 149 '''Class for temporal indicators | 167 '''Class for temporal indicators |
