how to make a matlab code that finds the area of a polygon using 2 different matrices, x and y coordinates?

10 views (last 30 days)
i need to write a code to find the area of a polygon with a matrix equation using x and y coordinates that also includes a special matrix

Answers (1)

KSSV
KSSV on 10 Oct 2016
Edited: KSSV on 10 Oct 2016
If you want to use a straight away function doc polyarea.
If you want to write a function, then it depends is your polygon a regular polygon. If regular polygon, then you can use the formulas to calculate the areas. Or, you can split the polygon into triangles, calculate the area of each triangle and sum them.
  2 Comments
KSSV
KSSV on 10 Oct 2016
Try this:
clc; clear all ;
t = (1/16:1/8:1)'*2*pi;
x = cos(t);
y = sin(t);
polygonVertices =[x y] ;
polygonEdges = [1 2;... %# Polygon edges (indices of connected vertices)
2 3;...
3 4;...
4 5;...
5 6;...
6 7;...
8 1];
dt = DelaunayTri(polygonVertices,polygonEdges); %# Create a constrained triangulation
isInside = inOutStatus(dt); %# Find the indices of inside triangles
faces = dt(isInside,:);
plot(polygonVertices(:,1),polygonVertices(:,2))
hold on
triplot(dt)

Sign in to comment.

Categories

Find more on Computational Geometry in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!