def LCross(S1,S2):
	"""
	S1 and S2 are two element tuples of two element tuples of
	x,y coordinates of the two lines:
	
	Routine to check if two line segments intersect
	
	  returns  0 if they don't intersect,   1 if they intersect
	  """
	((px1,py1),(px2,py2)) = S1
	((px3,py3),(px4,py4)) = S2
	
	# First some utility functions:
	def SideOfLineCheck(x1,y1,x2,y2,Px,Py):
		""" Given a line segment x1,y1 to x2,y2
		it checks to see if point Px,Py is to the right
		or to the left of the line segment looking from
		point x1,y1 to point x2,y2.
		If D is positive, then the point Px,Py is to the LEFT of the
		line segment.  If D is negative, P is to the right of segment.
		If D is zero then, P is on the segment
		If D =0 then that means that the point P is on the line
		defined by the two points...they may not be on the segment
		
		The check is done by taking the
		cross product of the vectors x1,y1 to x2,y2
		
		and x1,y1 to Px,Py
		"""
		
		def CrossProduct(x1,y1,x2,y2):
		                # Given vectors x1,y1 and x2,y2
		                # this routine returns the cross product
		                # which is also the determinant
		
			return x1*y2 - y1*x2
			
		dx = x2 - x1
		dy = y2 - y1
		dxp = Px - x1
		dyp = Py - y1
		
		return CrossProduct(dx,dy,dxp,dyp)
		
		# Check to see if point 3 is to the left of segment 1
		
	D1 = SideOfLineCheck(px1,py1,px2,py2,px3,py3)
	
	# Now check if point 4 is to the left of segment 1
	
	D2 = SideOfLineCheck(px1,py1,px2,py2,px4,py4)
	
	# if points 3 and 4 are on the same side of line 1
	# then things don't cross
	
	if(D1*D2 > 0):
		return  0
		# now we need to check the other way...
		
		#Check to see if point 1 is to the left of segment 2
		
	D1 = SideOfLineCheck(px3,py3,px4,py4,px1,py1)
	
	# Now check if point 2 is to the left of segment 2
	
	D2 = SideOfLineCheck(px3,py3,px4,py4,px2,py2)
	
	# if points 1 and 2 are on the same side of line 2 then things don't cross
	
	if(D1*D2 > 0):
		return 0
		#if we get here, the hummers cross
	return 1