TA的每日心情![](source/plugin/dsu_paulsign/img/emot/kx.gif) | 开心 昨天 15:13 |
---|
签到天数: 153 天 [LV.7]常住居民III
管理员
中国膜结构网www.mjgou.com
- 积分
- 2147483647
![QQ](static/image/common/qq_big.gif)
|
- //点到直线的距离
- public static double getDistanceByPointToLine采用笛卡尔坐标(Coordinate point, Coordinate pnt1, Coordinate pnt2)
- {
- double dis = 0;
- if (pnt1.x == pnt2.x)
- {
- if (pnt1.y == pnt2.y)
- {
- double dx = point.x - pnt1.x;
- double dy = point.y - pnt1.y;
- dis = Math.sqrt(dx * dx + dy * dy);
- }
- else
- dis = Math.abs(point.x - pnt1.x);
- }
- else
- {
- double lineK = (pnt2.y - pnt1.y) / (pnt2.x - pnt1.x);
- double lineC = (pnt2.x * pnt1.y - pnt1.x * pnt2.y) / (pnt2.x - pnt1.x);
- dis = Math.abs(lineK * point.x - point.y + lineC) / (Math.sqrt(lineK * lineK + 1));
- }
- //
- return dis;
- }
复制代码 |
|