点与线之间的距离 [英] distance between point and line

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

问题描述

大家好,

我需要计算点与线之间距离的代码吗?

Hi all,

I need code that computes the distance between point and line?

推荐答案

Wolfram Alpha对于此类事情非常方便:
Wolfram Alpha is very handy for such things: http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html[^] It shows you the final equation, and how to get there (step 14 for 2D)


您可能会在以下位置找到公式:"MathWorld,点线距离--3- Dimensional" [ ^ ].
You may find the formula, for instance, here: "MathWorld, Point-Line Distance--3-Dimensional"[^].


请参阅我的评论.我想解释一下为什么您不需要任何代码.

您需要使用线性代数(或者,如果需要的话,解析几何)的基本方法来做一些数学工作.由于问题相对简单,因此您也可以自己使用基本几何来推断适当的公式.对于研究生,这应该是个小问题,除非您在学校浪费了太多时间.

当您这样做时,编码将变得很琐碎.您只需要为线和点创建一些数据表示,但是除了这个简单的任务之外,这主要取决于您要如何处理它们.例如,如果您还将可视化直线和点,则数据模型最好与您要使用的图形库的类型定义更接近.

祝你好运,
—SA
Please see my comment. I want to explain why you don''t need any code.

You need to do some mathematical works using elementary methods of linear algebra (or, if you will, analytical geometry). As the problem is relatively simple, you can also infer the appropriate formula using elementary geometry all by yourself. For a graduate student, it should be a snap, unless you wasted time too much time at your school.

When you do it, the coding will be too trivial. You only need to create some data presentation for lines and points, but this mostly depends on what are you going to do with them, except this simple task. For example, if you also will visualize the lines and points, the data model would better be closer to the type definitions of the graphics library you want to use.

Good luck,
—SA


这篇关于点与线之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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