检查选定区域中的坐标 [英] Check if coordinate in selected area
本文介绍了检查选定区域中的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 4 个区域坐标:x1,y1 ...等等.还有一个位置 x0,y0.
I have 4 coordinates of area: x1,y1 ... etc. And have one more position x0,y0.
如何检查我的坐标是否在选定区域?
How to check if my coordinate in selected area?
推荐答案
我将向您解释如何检查 (x0,y0) 是否位于通过 (x1,y1) 和 (x2,y2) 的线下方".本质上,您希望向量 (x0-x1,y0-y1) 指向 (x2-x1, y2-y1) 的右侧".这相当于说矩阵
I will explain you how to check that (x0,y0) lies "below" the line through (x1,y1) and (x2,y2). Essentially, you want that the vector (x0-x1,y0-y1) points "to the right" of (x2-x1, y2-y1). This is equivalent to saying that the matrix
x0-x1 y0-y1
x2-x1 y2-y1
有一个负决定因素.所以你的情况变成了
has a negative determinant. So your condition becomes
(x0-x1)(y2-y1) < (y0-y1)(x2-x1).
对于包围该区域的任何线,您都会得到这样的条件.
You get such a condition for any line bounding the area.
这篇关于检查选定区域中的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文