开发者

how can I check that a point is in a triangle?

Hi also consider that I have 4 points and I will have 4 triangles how can I check these four triangles for each point that is the point within the triangles or not. th开发者_JAVA百科anks


Polygon implements the Shape interface, which provides several contains() methods. Here's a simple example.


You need to find the equation for the line created by each side of the triangle, and then for each side, check whether the point in question is on the same side of this line as the third point in the triangle. If all three are on the same side, it is within the triangle. Add bounds checking for cases of a point falling ON one of your sides.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜