码迷,mamicode.com
首页 > 编程语言 > 详细

算法.积累20200411

时间:2020-04-11 09:41:20      阅读:89      评论:0      收藏:0      [点我收藏+]

标签:ffffff   https   tail   lbp   code   art   col   四边形   turn   

1、ZC:求某个点 是否在 ()4边形 内部

 判断一个点是否在四边形内部_人工智能_San_Junipero的博客-CSDN博客.html(https://blog.csdn.net/San_Junipero/article/details/79172260

 已知四边形的四个点,求一个点是否在四边形之内的解决方法_人工智能_laukaka的专栏-CSDN博客.html(https://blog.csdn.net/laukaka/article/details/45168439

    private boolean isPointInRect(int x, int y)
{
final Point A = mLBPoint; final Point B = mLTPoint; final Point C = mRTPoint; final Point D = mRBPoint; final int a = (B.x - A.x)*(y - A.y) - (B.y - A.y)*(x - A.x); final int b = (C.x - B.x)*(y - B.y) - (C.y - B.y)*(x - B.x); final int c = (D.x - C.x)*(y - C.y) - (D.y - C.y)*(x - C.x); final int d = (A.x - D.x)*(y - D.y) - (A.y - D.y)*(x - D.x); if((a > 0 && b > 0 && c > 0 && d > 0) || (a < 0 && b < 0 && c < 0 && d < 0)) { return true; } // AB X AP = (b.x - a.x, b.y - a.y) x (p.x - a.x, p.y - a.y) = (b.x - a.x) * (p.y - a.y) - (b.y - a.y) * (p.x - a.x); // BC X BP = (c.x - b.x, c.y - b.y) x (p.x - b.x, p.y - b.y) = (c.x - b.x) * (p.y - b.y) - (c.y - b.y) * (p.x - b.x); return false;
}

 

2、

3、

4、

5、

 

算法.积累20200411

标签:ffffff   https   tail   lbp   code   art   col   四边形   turn   

原文地址:https://www.cnblogs.com/csskill/p/12677644.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!