Commit 2de4f570 authored by sumpfralle's avatar sumpfralle

add comparison function for lines


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@416 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent c18047a7
...@@ -41,6 +41,21 @@ class Line: ...@@ -41,6 +41,21 @@ class Line:
def __repr__(self): def __repr__(self):
return "Line<%g,%g,%g>-<%g,%g,%g>" % (self.p1.x,self.p1.y,self.p1.z, return "Line<%g,%g,%g>-<%g,%g,%g>" % (self.p1.x,self.p1.y,self.p1.z,
self.p2.x,self.p2.y,self.p2.z) self.p2.x,self.p2.y,self.p2.z)
def __cmp__(self, other):
""" Two lines are equal if both pairs of points are at the same
locations.
Otherwise the result is based on the comparison of the first and then
the second point.
"""
if self.__class__ == other.__class__:
if (self.p1 == other.p1) and (self.p2 == other.p2):
return 0
elif self.p1 != other.p1:
return cmp(self.p1, other.p1)
else:
return cmp(self.p2, other.p2)
else:
return cmp(str(self), str(other))
def dir(self): def dir(self):
if not hasattr(self,"_dir"): if not hasattr(self,"_dir"):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment