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?

Answers (2)

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)
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 Comments

Thanks for the reply,
I am, but it doesn't help my case. This is for a project and we have to break it up a n-sided polygon into n-2 triangles. From here we need to be able to find the area of each triangle and this is where I'm stuck.
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

Sign in to comment.

Categories

Find more on Linear Algebra in Help Center and File Exchange

Asked:

on 28 Feb 2011

Community Treasure Hunt

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

Start Hunting!