diff python/moving.py @ 98:b85912ab4064

refactored projection functions
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 12 Jul 2011 16:43:33 -0400
parents b3a1c26e2f22
children 13187af8622d
line wrap: on
line diff
--- a/python/moving.py	Tue Jun 14 14:14:24 2011 -0400
+++ b/python/moving.py	Tue Jul 12 16:43:33 2011 -0400
@@ -2,6 +2,7 @@
 '''Libraries for moving objects, trajectories...'''
 
 import utils;
+import cvutils;
 
 from math import sqrt, hypot;
 
@@ -122,7 +123,7 @@
         return '(%f,%f)'%(self.x,self.y)
 
     def __repr__(self):
-        return str(self)
+        return self.__str__()
 
     def __sub__(self, other):
         return Point(self.x-other.x, self.y-other.y)
@@ -142,6 +143,11 @@
     def aslist(self):
         return [self.x, self.y]
 
+    def project(self, homography):
+        from numpy.core.multiarray import array
+        projected = cvutils.projectArray(homography, array([[self.x], [self.y]]))
+        return Point(projected[0], projected[1])
+
     def inPolygon(self, poly):
         '''Returns if the point x, y is inside the polygon.
         The polygon is defined by the ordered list of points in poly