Hello folks. im trying to code a program. and here is the simple algoritm:
N:number of points in polygon (keyboard input)
for i=0;i<N {
input x[i],y[i] //array
next i
for i=0;i<N{
m[i]=(y2-y1)/(x2-x1) //gradient
next i
after that i cant figure out how to find interior angles of this polygon.
the rule of being a concav is it is enough to be one of interior angle greater than 180 degree.
This is trig 101. I would start by making "x" and "y" members of a stuct\class. Then "draw" each line by making an array of that class, treating "x" and "y" as points on a graph. From there plug in your formula and go.
Keep in mind that you will also have to pay attention to what is "inside" and what is "outside" the polygon, since all angles will always measure <= 180 degrees (3.141592 radians), so you'll have to adjust that if the angle is outside to get the true inside angle. For information on that, google around "inside outside polygon".
A polygon with 6 sides has 6 points and is called a hexagon. If each point is connected by a line to the center 6 interior equal angles are created, each of which are 360 /6 deg or 2*pi/6 rad. Oh and the sides of this polygon are the same as the radius of the circumscribed circle. A polygon with 8 sides and points probably has interior angles of 45 deg or pi/2.
hth's