4
$\begingroup$

So I took a challenge from my Geometry teacher to create code that when the user gives the computer how many angles / sides a polygon has and the angle of each of the interior angles it could find each of the exterior angles whether it is regular or irregular. For example the user tells the computer they have a four-sided shape (quadrilateral), the interior angles are $70, 75, 110, 145$. The computer would then be able to output each corresponding angle in the proper order. My problem is that with coding you can't just type in the human logic so I need a formula to work from: what on earth would be a formula that could apply to any polygon with any number of sides (irregular or regular)?

$\endgroup$
0

2 Answers 2

1
$\begingroup$

At each vertex of the polygon, the interior angle and exterior angle must sum to $180$. You can use this to find the value of each exterior angle.

$\endgroup$
0
$\begingroup$

The other answer is not complete, because you can have a non convex polygon (i.e one interior angle can be 240) and to say that $180-$input_angle is not all correct.

Thr proper way to to this is:

  1. read angles and save them as a list angles_list
  2. initialize and empty array with size equal to angles_list with name exteriors.
  3. loop over elements in angles_list, if element is greater than 180, then append to exteriors $360-$element, else append $180-$element
  4. return exteriors

Also you can add validations to check if the input angles indeed correspond to a polygon (i.e, the sum of angles must be a multiple of 180)

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .