2023-05-22 22:08:21 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
|
|
|
|
# Copyright (c) 2016-2023 Regents of the University of California, Santa Cruz
|
|
|
|
|
# All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
"""
|
2023-05-29 18:18:55 +02:00
|
|
|
Utility functions for Hanan router.
|
2023-05-22 22:08:21 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def is_in_region(point, region):
|
2023-05-29 06:25:11 +02:00
|
|
|
""" Return if a point is in the given region. """
|
2023-05-22 22:08:21 +02:00
|
|
|
|
2023-05-29 06:25:11 +02:00
|
|
|
ll, ur = region.rect
|
|
|
|
|
if is_between(ll.x, ur.x, point.x) and is_between(ll.y, ur.y, point.y):
|
2023-05-22 22:08:21 +02:00
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_between(a, b, mid):
|
|
|
|
|
""" Return if 'mid' is between 'a' and 'b'. """
|
|
|
|
|
|
|
|
|
|
return (a < mid and mid < b) or (b < mid and mid < a)
|