diff --git a/helpers/geometry_helper.py b/helpers/geometry_helper.py index 393e6525..da7475dd 100644 --- a/helpers/geometry_helper.py +++ b/helpers/geometry_helper.py @@ -4,12 +4,12 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ import math -from datetime import datetime import numpy as np import open3d as o3d from trimesh import Trimesh from trimesh import intersections +from helpers.configuration_helper import ConfigurationHelper class GeometryHelper: @@ -19,6 +19,18 @@ class GeometryHelper: def __init__(self, delta=0.5): self._delta = delta + def adjacent_locations(self, location1, location2): + """ + Determine when two buildings may be adjacent or not based in the dis + :param location1: + :param location2: + :return: Boolean + """ + max_distance = ConfigurationHelper().max_location_distance_for_shared_walls + x = location1[0] - location2[0] + y = location1[1] - location2[1] + return math.sqrt(math.pow(x, 2) + math.pow(y, 2)) < max_distance + def almost_equal(self, v1, v2): """ Compare two points and decides if they are almost equal (quadratic error under delta) @@ -36,7 +48,6 @@ class GeometryHelper: :param s2: Surface :return: Boolean """ - start = datetime.utcnow() # delta is grads an need to be converted into radians delta = np.rad2deg(self._delta) @@ -61,7 +72,7 @@ class GeometryHelper: minimum_distance = distance if minimum_distance <= self._delta: break - print('intersect', datetime.utcnow() - start) + if minimum_distance > self._delta or s1.intersect(s2) is None: return False else: