check points inside triangle or on edge with example
古いコメントを表示
Good evening everyone
function or coding for finding point is inside triangle or sub triangle or its on edges
thanks for involving your knowledge to be share to answer question
7 件のコメント
John D'Errico
2016 年 4 月 8 日
編集済み: John D'Errico
2016 年 4 月 8 日
help inpolygon
If this is homework (as I expect from your statement) then why not make an effort? We are not here to provide detailed code for your every homework problem.
Redwan Dan
2016 年 4 月 8 日
編集済み: Walter Roberson
2016 年 4 月 9 日
John D'Errico
2016 年 4 月 8 日
編集済み: John D'Errico
2016 年 4 月 8 日
You don't actually say what it is that you expect to happen. Anyway, your code does not run at all, since it is missing the values of p, q, xmax, and ylow to start with. Possibly others, but I've not bothered to look past the first few lines. We cannot decipher uncommented code that will not even execute.
So why did inpolygon NOT suffice? Your question is apparently about a triangle, given the title, yet it is not at all obvious from the code what you are doing. If you want an answer, you need to provide some explanation.
Roger Stafford
2016 年 4 月 8 日
編集済み: Roger Stafford
2016 年 4 月 8 日
Even if 'inpolygon' is not used for some reason, checking that a point lies inside a triangle is very easily done. It requires three inequalities to be satisfied. Each one checks that a corresponding vertex lies on the same side of the line of the other two vertices as the given point. This is a comparison between two linear expressions. The point lies inside the triangle if and only if all three are true.
Redwan Dan
2016 年 4 月 9 日
Roger Stafford
2016 年 4 月 9 日
I've given the necessary expression as an "Answer" here. It doesn't seem like a very slow method to me.
Walter Roberson
2016 年 4 月 9 日
Redwan Dan comments to John D'Errico:
am not here to prove you any thing and the way your answer and close is not nice treat with me if you don't know just don't comment or close
採用された回答
その他の回答 (1 件)
Gary Bikini
2021 年 6 月 12 日
You can use the built-in function
[in,on]=inpolygon(xq,yq,xv,yv)
カテゴリ
ヘルプ センター および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!