Mistake and suggestion Problems 105 104

Back to General discussions forum

donnie_d     2018-04-22 08:16:36

"Polygon is called convex if each of its angles is less than PI/2". There should be PI, not PI/2.

And actually there is no need in restricting input with this condition, as Gauss’ shoelace formula works for any polygon regardless of its convexity and is quite simple.

It's easy to understand how it works: you just have to sum up all the areas of oriented rectangular trapezoids bounded by each edge of the polygon. All unnecessary areas will be reduced because of the sign.

Also, in problem 104 author suggests to use Heron's Formula to calculate area of a triangle given coordinates of its vertices. So almost all the solutions i've seen are based on this formula. However, this approach is rather complicated, inefficient and leads to rounding errors due to square roots calculations. Shoelace formula also works for triangles. In this case it just gives half magnitude of cross product (which is it's geometrical meaning btw). It's fast, simple and no square roots.

Please login and solve 5 problems to be able to post at forum