def shiftPointOnLine(self, x1, y1, x2, y2, distance):
if x2 - x1 == 0: # vertical line
x_T1 = x1
y_T1 = y1 - distance
else:
a = (y2 - y1) / (x2 - x1)
if a == 0: # horizontal line
x_T1 = x1 - distance
y_T1 = y1
else:
alfa = atan(a)
#alfa = tan(a)
x_T1 = x1 - distance * cos(alfa)
y_T1 = y1 - distance * sin(alfa)
return [x_T1, y_T1]
评论列表
文章目录