フィルターのクリア

deciding whether this point under Area or not

2 ビュー (過去 30 日間)
Ahmed Hassaan
Ahmed Hassaan 2012 年 3 月 8 日
hello, i drawn a hexagon using fill and i want to specify whether a user in it or not.
I divided the hexagon to one square and 2 triangles ,the triangles has a 4 straight line ,i calculated the straight line equations and put in matlab ,i can decide that the user in the square area so there's no problem in the square area. So the problem is i want to decide whether the user in the traingles or not. The code is below if anyone can help :
%the code
close all;clear all;clc;
r=1;ax=0;ay=0;r1=sqrt(3)*r/2;r2=(r/2);
x=[ax ax+r1 ax+r1 ax ax-r1 ax-r1];
y=[ay+r ay+r2 ay-r2 ay-r ay-r2 ay+r2];
xsquare1=ax-r1; %limits of square in x axes
square2=ax+r1;
ysquare1=ay-r2; %limits of square in y axes
ysquare2=ay+r2;
yfirstline=(ax/sqrt(3))+ay-(x/sqrt(3))+r; %straight lines eqns
ysecondline=(-ax/sqrt(3))+ay+(x/sqrt(3))+r;
ythirdline=(-ax/sqrt(3))+ay+(x/sqrt(3))-r;
yfourthline=(ax/sqrt(3))+ay-(x/sqrt(3))-r;
fill(x,y,'w');grid on ;hold on ;plot(ax,ay,'bo')
RN1x=0.6;RN1y=0.3; %this is the user axes;
if ((RN1x > xsquare1)&&(RN1x < xsquare2))&&((RN1y > ysquare1)&&(RN1y < ysquare2))&&(RN1y < yfirstline)&&(RN1y < ysecondline)&&(RN1y < ythirdline)&&(RN1y < yfourthline)
pass=1
else
pass=0
end

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 3 月 8 日
doc inpolygon %?
  3 件のコメント
Sean de Wolski
Sean de Wolski 2012 年 3 月 8 日
Why not?
x and y are the xv anv yv inputs in inpolygon...?
Ahmed Hassaan
Ahmed Hassaan 2012 年 3 月 8 日
its working thanks man :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by