+ 16
🏰👑CHALLENGE OF KINGS👑🏰 Random Convex Pentagon
Write a program to do the following tasks: 1. Randomly generate and print 5 points A1(x1,y1), A2(x2,y2), A3(x3,y3),A4(x4,y4),A5(x5,y5) on a plane (for simplicity assume that the width and height of the plane are 200.) 2. Determine whether the pentagon A1--A2--A3--A4--A5--A is convex or concave. 3. If the above pentagon is convex, print a message and compute the area of the pentagon. 4. If the above pentagon is concave print a message and start over. Hint: Apply cross product of vectors to d
4 Respuestas
+ 18
Here is a my solution to the above challenge as an example:
https://code.sololearn.com/WJbuQT5wON9n/?ref=app
+ 11
Another intersting idea is to embed polygons inside ellipses and approximate the area of ellipses using them.
+ 3
Here's my program for all regular convex polygons:
(I had made this code before seeing your challenge so it doesn't qualify but it's a nice tangent to it.)
https://code.sololearn.com/WjZChqY4vZXO/?ref=app
(And the first one I had made about a year ago.
Also for regular convex polygons.)
https://code.sololearn.com/WHFnoAHhXh1H/?ref=app
0
I'll try to make a code for your challenge. ☺
Generic polygons and determining concavity or convexity are a step up from what I've been doing.