created distance_between_points in geometry_helper.py, erased almost_equal in polyhedron points
This commit is contained in:
parent
c3e06b5fa7
commit
215d62b62b
|
@ -30,13 +30,13 @@ class Polyhedron:
|
|||
self._min_z = None
|
||||
self._min_y = None
|
||||
self._min_x = None
|
||||
self._geometry = GeometryHelper(delta=5.0, area_delta=0.01)
|
||||
self._geometry = GeometryHelper()
|
||||
|
||||
def _position_of(self, point, face):
|
||||
vertices = self.vertices
|
||||
for i in range(len(vertices)):
|
||||
# ensure not duplicated vertex
|
||||
if i not in face and self._geometry.almost_equal(vertices[i], point):
|
||||
if i not in face and GeometryHelper.distance_between_points(vertices[i], point) == 0:
|
||||
return i
|
||||
return -1
|
||||
|
||||
|
@ -53,7 +53,7 @@ class Polyhedron:
|
|||
found = False
|
||||
for vertex_2 in self._vertices:
|
||||
found = False
|
||||
if self._geometry.almost_equal(vertex_1, vertex_2):
|
||||
if GeometryHelper.distance_between_points(vertex_1, vertex_2) == 0:
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
|
|
|
@ -27,7 +27,7 @@ class UsageZone:
|
|||
self._dhw_preparation_temperature = None
|
||||
self._electrical_app_average_consumption_sqm_year = None
|
||||
# todo: mechanical_air_change must come from library, talk to Rabeeh
|
||||
# todo: check to code clean and un used attributes
|
||||
# todo: check to clean code and un-used attributes
|
||||
self._mechanical_air_change = ConfigurationHelper().min_air_change
|
||||
self._occupancy = None
|
||||
self._schedules = None
|
||||
|
|
|
@ -19,6 +19,7 @@ class CityObject:
|
|||
self._lod = lod
|
||||
self._surfaces = surfaces
|
||||
self._polyhedron = None
|
||||
self._geometry = GeometryHelper()
|
||||
|
||||
@property
|
||||
def lod(self):
|
||||
|
|
|
@ -37,7 +37,7 @@ class GeometryHelper:
|
|||
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
|
||||
return GeometryHelper.distance_between_points(x, y) < max_distance
|
||||
|
||||
def almost_same_area(self, a1, a2):
|
||||
"""
|
||||
|
@ -58,7 +58,9 @@ class GeometryHelper:
|
|||
:param v2: [x,y,z]
|
||||
:return: Boolean
|
||||
"""
|
||||
delta = math.sqrt(pow((v1[0] - v2[0]), 2) + pow((v1[1] - v2[1]), 2) + pow((v1[2] - v2[2]), 2))
|
||||
print('3 dimensions')
|
||||
delta = self.distance_between_points(v1, v2)
|
||||
print('delta', delta)
|
||||
return delta <= self._delta
|
||||
|
||||
def is_almost_same_surface(self, s1, s2):
|
||||
|
@ -246,3 +248,11 @@ class GeometryHelper:
|
|||
mesh.compute_vertex_normals()
|
||||
o3d.visualization.draw_geometries([mesh], mesh_show_back_face=True)
|
||||
return Trimesh(vertices=np.asarray(mesh.vertices), faces=np.asarray(mesh.triangles))
|
||||
|
||||
@staticmethod
|
||||
def distance_between_points(vertex1, vertex2):
|
||||
power = 0
|
||||
for dimension in range(0, len(vertex1)):
|
||||
power += math.pow(vertex2[dimension]-vertex1[dimension], 2)
|
||||
distance = math.sqrt(power)
|
||||
return distance
|
||||
|
|
Loading…
Reference in New Issue
Block a user