Line.py
Go to the documentation of this file.
1 # a Line is an object where a wall lay. When different Lines meet, they form Surfaces.
2 
3 from __future__ import division
4 import numpy as np
5 import math
6 
7 
8 class Line(object):
9  def __init__(self, point, angular_cluster, spatial_cluster):
10  self.point = point
11  self.angular_cluster = angular_cluster
12  self.spatial_cluster = spatial_cluster
13 
14 
15 def create_extended_lines(spatial_clusters, wall_list, x_min, y_min):
16  # crea una extended_line per ogni cluster spaziale. La retta avra' cluster spaziale e angolare = a cluster spaziale
17  # e angolare dei muri che la generano, e come punto avra' (mediana delle x dei punti medi, ymin) se e' verticale,
18  # (xmin, mediana delle y dei punti medi) se e' orizzontale, mediana dei punti medi se e' obliqua.
19  extended_lines = []
20  for cluster in set(spatial_clusters):
21  mid_points = []
22  angle = None
23  for wall in wall_list:
24  if wall.spatial_cluster == cluster:
25  if angle is None:
26  angle = wall.angular_cluster
27  # set only 1 time. all the walls with same spatial_cluster have same angular_cluster
28  mid_x = (wall.x1+wall.x2)/2
29  mid_y = (wall.y1+wall.y2)/2
30  mid_point = np.array([mid_x,mid_y])
31  mid_points.append(mid_point)
32  # check if angular_cluster is horizontal, vertical or oblique
33  # horizontal
34  if angle == 0:
35  # ordered by y
36  mid_points.sort(key=lambda x: (x[1], x[0]))
37  index = len(mid_points)//2
38  point = np.array([x_min, mid_points[index][1]])
39  # vertical
40  elif angle == math.radians(90):
41  # ordered by x
42  mid_points.sort(key=lambda x: (x[0], x[1]))
43  index = len(mid_points)//2
44  point = np.array([mid_points[index][0], y_min])
45  # oblique
46  else:
47  # ordered by x
48  mid_points.sort(key=lambda x: (x[0], x[1]))
49  index = len(mid_points)//2
50  point = mid_points[index]
51  extended_lines.append(Line(point, angle, cluster))
52  return extended_lines
Line.Line.point
point
Definition: Line.py:10
Line.Line
Definition: Line.py:8
Line.Line.spatial_cluster
spatial_cluster
Definition: Line.py:12
Line.create_extended_lines
def create_extended_lines(spatial_clusters, wall_list, x_min, y_min)
Definition: Line.py:15
Line.Line.__init__
def __init__(self, point, angular_cluster, spatial_cluster)
Definition: Line.py:9
Line.Line.angular_cluster
angular_cluster
Definition: Line.py:11


rose2
Author(s): Gabriele Somaschini, Matteo Luperto
autogenerated on Wed Jun 28 2023 02:21:53