1== 1 is False?
delphiro
delphiro at zonnet.nl
Fri Jun 20 10:07:34 EDT 2003
Hi,
I get a strange error stating that two equal values are not equal. In short what I do;
I calculate the intersection point of two linesegments. If they intersect I check if the intersections point is within both linesegmenents. The code for the latter is;
[CODE]
def GetLineSegmentIntersection( p1, p2, p3, p4 ):
p = GetLineIntersection( p1, p2, p3, p4 )
#do we have an intersection at all?
if p == []:
return []
xmax = _MAX( p1[0], p2[0] )
ymax = _MAX( p1[1], p2[1] )
xmin = _MIN( p1[0], p2[0] )
ymin = _MIN( p1[1], p2[1] )
#within range of line 1?
if( p[0] <= xmax )and( p[0] >= xmin)and( p[1] <= ymax )and( p[1] >= ymin ):
#line 2
xmax = _MAX( p3[0], p4[0] )
ymax = _MAX( p3[1], p4[1] )
xmin = _MIN( p3[0], p4[0] )
ymin = _MIN( p3[1], p4[1] )
if( p[0] <= xmax )and( p[0] >= xmin)and( p[1] <= ymax )and( p[1] >= ymin ):
return array((p[0],p[1]))
#if we get here then the point is not within the linesegments
return []
[/CODE]
This works fine but for some strange reason I sometimes the statement for the check of line 2 is NOT valid if p[1] == ymax == ymin.
If I print out the values I get something like 2.260212 <= 2.260212 and 2.260212 >= 2.260212 is NOT true.
What's wrong?
Rob
--
[-------------delphiro-------------]
[-- http://pyciv.sourceforge.net --]
[----------------------------------]
More information about the Python-list
mailing list