Defining points of a polygon for use in finding area of triangle.
古いコメントを表示
My problem is I need a way to take the points from a convex polygon and later use those points to calculate the area of triangles that make of the polygon. How would I define the points [x1 x2 x3...] and [y1 y2 y3...] in a way they can be used later in a loop to find the areas of a triangle? Thanks?
回答 (2 件)
Bruno Luong
2011 年 2 月 28 日
For polygon (x1,y1) ... (xn,yn) Why not breaking up with respect to the first vertex:
T1 = (x1,y1)(x2,y2)(x3,y3)
T2 = (x1,y1)(x3,y3)(x4,y4)
T3 = (x1,y1)(x4,y4)(x5,y5)
...
Tn-2 = (x1,y1)(xn-1,yn-1)(xn,yn)
Walter Roberson
2011 年 2 月 28 日
0 投票
The list you already show is as good as any representation for that purpose.
You have more of a problem in defining the "triangles that make up the polygon". There is no unique decomposition of a polygon of 4 or more points in to triangles, even when the polygon is constrained to be convex. The decomposition becomes even less special if you are allowed to introduce new interior points.
By the way, are you aware of the polyarea() call?
2 件のコメント
Austin Hoffeditz
2011 年 2 月 28 日
Walter Roberson
2011 年 2 月 28 日
newx = [x x(1) x(2)];
newy = [y y(1) y(2)];
for K = 1:length(x)
find the area of triangle defined by newx(K:K+2), newy(K:K+2)
end
カテゴリ
ヘルプ センター および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!