在给定线的另一个点和垂直线上的2个点的情况下,如何找到该点的X坐标? [英] How to find the X coordinate of a point on a line given another point of the line and the 2 points on a perpendicular line?

查看:241
本文介绍了在给定线的另一个点和垂直线上的2个点的情况下,如何找到该点的X坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个python应用程序以选择矩形区域,当用户设置2个点(矩形的长度)时,第三点和第四个点在形成矩形时受到限制,其中矩形的宽度已给定通过鼠标光标和最后一个点的Y差.

I'm writing a python app to select rectangular areas, when the user has set 2 points (the length of the rectangle), the third and 4th points are constrained in forming a rectangle, where the width of the rectangle is given by the Y difference of the mouse cursor and the last point.

下面是一张简短的图片,我正在寻找C点的X坐标.

Here's a quick picture to explain, I'm looking for the X coordinate of the point C.

我知道:

  • A(2,3)
  • B(5,5)
  • 角度= 90度
  • C的Y坐标为7.

我不确定如何使用向量解决这个问题?我在项目中使用了numpy.

I'm not sure how to tackle this... using vectors ? I'm using numpy in my project.

推荐答案

这不仅仅是数学问题,更是数学问题.

This is more of a math issue than a numpy issue.

(AB)的斜率是(y_a - y_b)/ (a - b).因此,与(AB)垂直的任何斜率都为p=(b-a)/(y_a-y_b)(与原始斜率的倒数相反).

The slope of (AB) is (y_a - y_b)/ (a - b). So the slope of any perpendicular to (AB) is p=(b-a)/(y_a-y_b) (opposite of the inverse of the original slope).

从这里可以轻松确定穿过B的垂直于(AB)的方程:y-y_b=p*(x-x_b).并将y_c替换为y以找到x_c

From here it is easy to determine the equation of the perpendicular to (AB) passing through B : y-y_b=p*(x-x_b). And substitute y_c to y to find x_c

如果(AB)是水平的(0斜率),则存在一个问题(被零除).在这种情况下,x_c就是x_b((BC)上的所有点都具有相同的x坐标)

There is an issue (division by zero) if (AB) is horizontal (0 slope). In that case, x_c is just x_b (all of the points on (BC) have same x coordinate)

这篇关于在给定线的另一个点和垂直线上的2个点的情况下,如何找到该点的X坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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