Question: 3 . ( Graham scan in Python ) In this question, you will implement the Graham scan algorithm for convex hull in 2 - space.

3.(Graham scan in Python) In this question, you will implement the Graham scan algorithm for convex
hull in 2-space.
(a) Write a Python function for computing the convex hull of a point cloud in 2-space. It has
one input parameter: a column-major data matrix representing the point cloud. It returns an
NumPy array: the column indices of the input that define the convex hull. These indices are
sorted counterclockwise around the hull, starting with the lowest point.
(b) Write a Python function that renders a point cloud and its convex hull. It takes two input
parameters, a column-major data matrix of the point cloud and an array of the column indices
of its convex hull. Use matplotlib to render. (As a challenge, you could try implementing using
pyglet.)
(c) To test the two functions on random point clouds, write a Python function with three input
parameters: the size of the point cloud, the bottom left corner of the square containing the point
cloud, the size of the square. It should return a column-major data matrix representing a random
point cloud of this size that lies inside this square.
(d) Use the three functions to test your code by drawing the convex hull of random point clouds.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!