点到直线垂线交点计算
Posted 鲁氏新之助
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了点到直线垂线交点计算相关的知识,希望对你有一定的参考价值。
点到直线垂线交点计算
linepoint_1, linepoint_2:直线的两个端点
verticalline_point:线外点
a为斜率,b为截距
def get_cross_point(linepoint_1, linepoint_2, verticalline_point):
a = (linepoint_1[1] - linepoint_2[1]) / (linepoint_1[0] - linepoint_2[0])
a_ver = -1 / a
b_ver = verticalline_point[1] - a_ver * verticalline_point[0]
b = linepoint_1[1] - a * linepoint_1[0]
point_long = (b_ver - b) / (a - a_ver)
point_lat = a * point_long + b
return point_long, point_lat
以上是关于点到直线垂线交点计算的主要内容,如果未能解决你的问题,请参考以下文章