20171111-0345 - 20171111-0415: 30 minutes
from shapely.geometry import LineString
line = LineString([(0, 0), (1, 1), (2, 0)])
line
line1 = LineString([(0, 0), (1, 1)])
line2 = LineString([(1, 1), (2, 0)])
from shapely.geometry import Point
print(line1.interpolate(line1.project(Point(2, 0))))
from shapely.geometry import MultiLineString
line1 = LineString([(0, 0), (2, 0)])
line2 = LineString([(0, 0), (1, 1)])
MultiLineString([line1, line2])
list(line2.coords)
print(line1.interpolate(line1.project(Point(1, 1))))
# Create angle that is greater than 90 degrees
from shapely.geometry import LineString, MultiLineString
line1 = LineString([(0, 0), (2, 0)])
line2 = LineString([(0, 0), (-1, 1)])
MultiLineString([line1, line2])
# Create right triangle
from shapely.geometry import Point
point = Point(set(line2.coords) - set(line1.coords))
print(point)
p1 = 2, 0
p2 = -1, 1
import numpy as np
p1[::-1]
p2[::-1]
angle1 = np.arctan2(*p1[::-1])
angle2 = np.arctan2(*p2[::-1])
np.rad2deg((angle1 - angle2) % (2 * np.pi))
a_xy = 2, 0
b_xy = 0, 0
c_xy = -1, 1
np.array(a_xy) - b_xy
a_xy - np.array(b_xy)
import numpy as np
def compute_angle(a_xy, b_xy, c_xy):
# https://stackoverflow.com/a/31735642/192092
b_xy = np.array(b_xy)
angle1 = np.arctan2(*(a_xy - b_xy)[::-1])
angle2 = np.arctan2(*(c_xy - b_xy)[::-1])
angle_in_degrees = np.rad2deg((angle1 - angle2) % (2 * np.pi))
if angle_in_degrees > 180:
angle_in_degrees = 360 - angle_in_degrees
return angle_in_degrees
print(compute_angle((2, 0), (0, 0), (-1, 1)))
print(compute_angle((2, 0), (0, 0), (1, 1)))
print(compute_angle((3, 1), (1, 1), (0, 2)))
+ Define linestring with point
+ Compute the angle of incoming vs outgoing line
20171111-0730 - 20171111-0800: 30 minutes
+ Create a tool that computes the angle
20171117-2215 - 20171117-2245: 30 minutes
import numpy as np
def compute_angle(a_xy, b_xy, c_xy):
# https://stackoverflow.com/a/31735642/192092
b_xy = np.array(b_xy)
angle1 = np.arctan2(*(a_xy - b_xy)[::-1])
angle2 = np.arctan2(*(c_xy - b_xy)[::-1])
angle_in_degrees = np.rad2deg(angle1 - angle2)
if angle_in_degrees < 0:
angle_in_degrees *= -1
return angle_in_degrees
print(compute_angle((2, 0), (0, 0), (-1, 1)))
print(compute_angle((2, 0), (0, 0), (1, 1)))
print(compute_angle((3, 1), (1, 1), (0, 2)))
20171128-2300 - 20171128-2315: 15 minutes
+ Use pole type A when the angle of the incoming and outcoming distribution line is smaller than X degrees.
+ Use pole type A for solar panel poles.
+ Use pole type B otherwise.