如何确定一个点是否在四边形内 [英] How to determine if a point is within a quadrilateral

查看:1445
本文介绍了如何确定一个点是否在四边形内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标

我想确定测试点是否在定义的四边形内。我可能会在Matlab中实现这个解决方案,所以我只需要伪代码。



输入



四边形角:(x1,y1)(x2,y2)(x3,y3)(x4,y4)

测试点:( xt,yt)
$ b $ p 输出



1 - 如果在四边形内



0 - 否则

更新

有人指出,识别四边形的顶点不足以唯一标识它。你可以假设点的顺序决定了四边形的边(点1连接2,2连接到3,3连接到4,4连接到1)

解决方案

使用 inpolygon 。用法将是 inpolygon(xt,yt,[x1 x2 x3 x4],[y1 y2 y3 y4])


Goal

I want to determine if a test point is within a defined quadrilateral. I'm probably going to implement the solution in Matlab so I only need pseudo-code.

Inputs

Corners of quadrilateral : (x1,y1) (x2,y2) (x3,y3) (x4,y4)

Test point : (xt, yt)

Output

1 - If within quadrilateral

0 - Otherwise

Update

It was pointed out that identifying the vertices of the quadrilateral is not enough to uniquely identify it. You can assume that the order of the points determines the sides of the quadrilateral (point 1 connects 2, 2 connects to 3, 3 connects to 4, 4 connects to 1)

解决方案

Use inpolygon. Usage would be inpolygon(xt,yt,[x1 x2 x3 x4],[y1 y2 y3 y4])

这篇关于如何确定一个点是否在四边形内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆