matlab 判断点与多边形区域之间的位置关系(内,外)

本文介绍了使用铅垂线内点法在Matlab中判断点是否位于多边形区域内的方法。通过计算铅垂线与多边形边的交点数,可以确定点是在区域内(奇数个交点)还是区域外(偶数个交点)。参考了《判断多边形位置关系的算法综述》一文。
摘要由CSDN通过智能技术生成

铅垂线内点法实现判断一个点与多边形区域之间的位置关系。

铅垂线内点法的基本思想是从待判别点向外引铅垂线,计算其与多边形交点的个数。若交点个数为奇数,则点在多边形内;若交点个数为偶数,则该点在多边形外。具体参见【王润科,张艳丽】的《判断多边形位置关系的算法综述》。

matlab代码

function result=area()
clear
clc
% the sequence points of an area. the last point is the same as the first one
areapoints=[116.293859, 39.983803
116.334411, 39.985055
116.334653, 39.98101
116.335607, 39.976502
116.337541, 39.975268
116.339567, 39.97489
116.340156, 39.966256
116.328224, 39.96611
116.315182, 39.965722
116.301885, 39.960507
116.300487, 39.968747
116.295395, 39.97214
116.293859, 39.983803];

plot(areapoints(1:end,1),areapoints(1:end,2));
n=length(areapoints)-1;
lines=[areapoints(1:end-1,:) areapoints(2:end,:)]; % all the border lines. save the two points of a line

lines
% for: the longitude of the first point must be less or equal to the second.
for i=1:n
    if lines(i,1)>lines(i,3)
        lines(i,:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值