图像中求点到直线的距离
来源:互联网 发布:单片机开发板有什么用 编辑:程序博客网 时间:2024/05/19 02:06
在图像中求距离用到较多的是对两点式直线求距离,这篇文章给出的代码也是基于这种情况,在给定直线上两个点的情况下求直线外一点到直线的距离。
首先回顾下直线的多种表达公式:
http://baike.baidu.com/view/2136602.htm
以及点到直线的距离公式:
http://baike.baidu.com/subview/3268213/3268213.htm
那么从两点式化为一般式:
// 两点式公式为(y - y1)/(x - x1) = (y2 - y1)/ (x2 - x1)
// 化简为一般式为(y2 - y1)x + (x1 - x2)y + (x2y1 - x1y2) = 0
最后,照着公式走就可以了。
//HEADER内声明:typedef struct _point2i{ double row; double column;}point2i;//SOURCE:void point2lineDis(const point2i& point, const point2i& linePoint1, const point2i& linePoint2, double& distance){ double A, B, C; A = linePoint2.column - linePoint1.column; B = linePoint1.row - linePoint2.row; C = linePoint2.row * linePoint1.column - linePoint1.row * linePoint2.column; distance = abs(A * point.row + B * point.column + C) / sqrt(A * A + B * B);}
0 0
- 图像中求点到直线的距离
- 求点到直线的距离
- 求点到直线的距离
- 点到直线的距离
- 点到直线的距离
- 点到直线的距离
- 点到直线的距离
- 点到直线的距离
- 三维空间里点到直线的距离
- 点到直线的距离
- 直线距离
- 点到线段直线的距离, 直线与直线的关系 直线与线段的关系
- [图像] 直方图的距离
- 点到空间直线的距离
- ZJUT1051 到直线的最长距离
- 计算点到直线的距离
- 计算地球上两点的直线距离
- 获取GPS 两点间的直线距离
- oracle max()函数和min()函数
- 关于dialog
- html5表单中的<button>按钮
- 两个链表的第一个公共节点
- JavaWeb学习总结(一)——JavaWeb开发入门
- 图像中求点到直线的距离
- 寻找自己的核心竞争力
- 【leetcode】 46. Permutations ,python实现
- JAVA使用Calendar操作Date
- Qt5打印功能示例代码
- 特征工程-降维
- 创建存储过程
- AssetBundle.CreateFromFile使用时注意事项
- MFC自定义消息