点上的线最接近的x,y [英] Point on a line closest to x,y

查看:232
本文介绍了点上的线最接近的x,y的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

可能重复:
  <一href="http://stackoverflow.com/questions/910882/how-can-i-tell-if-a-point-is-nearby-a-certain-line">How我可以告诉大家,如果一个点附近的某行?

  //返回的追踪,从开始到结束就行了点这
//谈到最近的50万,50万元。之间的点被缩放
// 1,000,000,0从其原始FP类型。
点closestToCentre(点开始,点结束);
 

任何人都知道的不是通过像素单步执行更快的方法?

难道比我有一个人更加警觉展示自己的数学和放大器;几何的威力吗?

修改 _ 的___

由于克里斯,这是困惑我:

[X; -a / BX-C / B] = [0; -c / B] -1 / B [-b;斧头。

现在我看到它是分割(主要的y分量)的矢量​​分成两个相结合,得到相同的结果。得到了老部分分式脑细胞兴奋了一分钟,然后:)

修改 _ _

杰森·摩尔,谢谢你的灵感,这里是我在做什么,图形,

我希望这是更清晰。

_ 修改 __ _

所以,我可以合理预期采取的线成直角我的取样线,从中心运行它,但如何知道什么时候他们接触?

我觉得方程克里斯的页面是一段路要走。如果你都告诉我,这是一个两步骤的过程。它只是两个联立方程组了,所以我可能不需要克里斯的推导。

_ 修改 __ _ _

无论是好事还是坏事,我不知道,但计算器作为搜索引擎的美已经向我透露调查的几条航线。主要是我喜欢的第一个解决方案在这里: <一href="http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment">Shortest一个点和线段的之间的距离。

但要证明这一点我自己,我需要从马蒂的解决方案的链接在底部(只有一个):

HTTP://www.topcoder.com / TC D1 =教程和放大器; D2 = geometry1和放大器;模块=静态

的推导是如此简单而优雅的连我都跟着呢!

由于 http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html

解决方案

这是一个点的线性投影的问题上一条线,它可以与一些细微的载体体操来完成,所阐述的的 MathWorld

这篇文章详细介绍了如何找到从点的最短距离为一条线,而中间步骤之一是找到垂直线从点X,Y,以原线。相交这两行会给你点就行了,最接近的X,Y。

编辑回应评论:什么公式(2)中的链接做的是该载体转化让人想起表达式y = mx + C的一种形式,它允许您快速,轻松地读出梯度,从垂直梯度可以容易地计算。

Possible Duplicate:
How can I tell if a point is nearby a certain line?

//Returns the point on the line traced from start to end which
//comes nearest to 500,000, 500,000. The points are scaled between
//1,000,000 and 0 from their original fp types.
Point closestToCentre(Point start, Point end);

Anyone know of quicker way than single stepping through the pixels?

Could some one more alert than me demonstrate their maths & geometry prowess please?

EDIT____

Thanks Kris, this was confusing me :

[x; -a/bx-c/b]=[0; -c/b]-1/b[-b; a]x.

Now I see it is just splitting (mainly the y component) the vector into two which combine to yield the same result. Got the old partial fractions brain cell excited for a minute then :)

EDIT__

Jason Moore, thanks for the inspiration, here is what I am doing, graphically,

I hope that is clearer.

_EDIT___

So I could reasonably expect to take a line at right angles to my sampled line and run it from the centre but how to tell when they touch?

I think Kris's page of equations is the way to go. If you're all telling me it is a two step process. It is just two simultaneous equations now, so I may not need Kris's derivations.

_EDIT____

Whether good or bad thing, I don't know, but the beauty of stackoverflow as a search engine has revealed to me several routes of investigation. Chiefly I like the first solution here: Shortest distance between a point and a line segment.

But to prove this to my self I needed the link from matti's solution at the bottom (but one):

http://www.topcoder.com/tc?d1=tutorials&d2=geometry1&module=Static

The derivation is so simple and elegant even I could follow it!

Given http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html

解决方案

This is a matter of linear projection of a point onto a line, which can be done with some fine vector gymnastics, as elaborated at MathWorld.

The article details how to find the shortest distance from a point to a line, and one of the intermediate steps is finding the perpendicular line from the point x,y to the original line. Intersecting these two lines will give you the point, on the line, closest to x,y.

Edit in response to comment: What equation (2) in the link is doing is transforming the vector into a form reminiscent of y = mx + c, which allows you to quickly and easily read off the gradient, from which the perpendicular gradient can be easily calculated.

这篇关于点上的线最接近的x,y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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