从给定点垂直于直线 [英] Perpendicular on a line from a given point

查看:12
本文介绍了从给定点垂直于直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在给定点的线段上绘制垂线?我的线段定义为 (x1, y1), (x2, y2),如果我从点 (x3,y3) 画一条垂线,它与点 (x4,y4) 上的线相交.我想知道这个 (x4,y4).

How can I draw a perpendicular on a line segment from a given point? My line segment is defined as (x1, y1), (x2, y2), If I draw a perpendicular from a point (x3,y3) and it meets to line on point (x4,y4). I want to find out this (x4,y4).

推荐答案

我为你解了方程:

k = ((y2-y1) * (x3-x1) - (x2-x1) * (y3-y1)) / ((y2-y1)^2 + (x2-x1)^2)
x4 = x3 - k * (y2-y1)
y4 = y3 + k * (x2-x1)

^2 表示平方

这篇关于从给定点垂直于直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆