extract informations about corners
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import sys
|
||||
from math import sqrt, atan, degrees
|
||||
from helix.models.corner import Corner
|
||||
|
||||
class ProjectPresenter(object):
|
||||
def __init__(self, system_type, module_type):
|
||||
@@ -18,8 +20,6 @@ class ProjectPresenter(object):
|
||||
spacing_x, spacing_y = module_constants.presenter_spacing
|
||||
wind_zones = system_constants.wind_zones
|
||||
|
||||
|
||||
|
||||
for panel in panels:
|
||||
subarray = [x for x in subarrays if x.subarray_number == panel.subarray][0]
|
||||
origin = subarray.origin
|
||||
@@ -73,6 +73,39 @@ class ProjectPresenter(object):
|
||||
|
||||
return result
|
||||
|
||||
def get_corners(self, buildings):
|
||||
result = []
|
||||
for building in buildings:
|
||||
presentable_building = []
|
||||
result.append(presentable_building)
|
||||
previous_corner = building[-1]
|
||||
for i, corner in enumerate(building):
|
||||
if (i+1 == len(building)):
|
||||
next_corner = building[0]
|
||||
else:
|
||||
next_corner = building[i+1]
|
||||
|
||||
corner_length = sqrt((next_corner[0] - corner[0])**2 + (next_corner[1] - corner[1])**2)
|
||||
k1 = (corner[1] - previous_corner[1]) / (corner[0] - previous_corner[0])
|
||||
k2 = (next_corner[1] - corner[1]) / (next_corner[0] - corner[0])
|
||||
theta1 = degrees(atan(k1))
|
||||
theta2 = degrees(atan(k2))
|
||||
theta1 = theta1 - theta2
|
||||
if (theta1 < 0):
|
||||
if (k1 < 0 and k2 < 0):
|
||||
theta1 = 360 + theta1
|
||||
elif (k1 < 0 and k2 > 0):
|
||||
theta1 = 180 + theta1
|
||||
else:
|
||||
if (k1 > 0 and k2 > 0):
|
||||
theta1 = 180 + theta1
|
||||
|
||||
corner_angle = theta1
|
||||
presentable_building.append(Corner(corner[0], corner[1], corner_length, corner_angle).__dict__)
|
||||
previous_corner = corner
|
||||
|
||||
return result
|
||||
|
||||
def get_max_y(self,buildings, panels):
|
||||
|
||||
module_constants = self.system_type.module_constants(self.module_type)
|
||||
|
||||
Reference in New Issue
Block a user