如何计算线段的法向量? [英] How do I calculate the normal vector of a line segment?

查看:167
本文介绍了如何计算线段的法向量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一条从(x1,y1)到(x2,y2)的线段。我如何计算垂直于线条的法线矢量?



我可以找到很多关于在3D中为飞机做这件事情,但没有2D的东西。



请在数学上轻松一点(欢迎使用工作示例,图表或算法的链接),我是一名程序员,而不是数学家;)

解决方案

如果我们定义了dx = x2-x1和dy = y2-y1,那么法线是(-dy,dx)和(dy,-dx )。



请注意,不需要划分,因此您不用冒被零除的风险。


Suppose I have a line segment going from (x1,y1) to (x2,y2). How do I calculate the normal vector perpendicular to the line?

I can find lots of stuff about doing this for planes in 3D, but no 2D stuff.

Please go easy on the maths (links to worked examples, diagrams or algorithms are welcome), I'm a programmer more than I'm a mathematician ;)

解决方案

if we define dx=x2-x1 and dy=y2-y1, then the normals are (-dy, dx) and (dy, -dx).

Note that no division is required, and so you're not risking dividing by zero.

这篇关于如何计算线段的法向量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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