Python. Given the code below (or a modified version of it) for gift wrapping/convex hull. Does anybody know how to make a GUI in tkinter where the user can add points by clicking the left mouse button, and remove points by clicking the right mouse button? Then the "graph"/"line" around the points will be updated

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Python. Given the code below (or a modified version of it) for gift wrapping/convex hull. Does anybody know how to make a GUI in tkinter where the user can add points by clicking the left mouse button, and remove points by clicking the right mouse button? Then the "graph"/"line" around the points will be updated

 

class Point:

def __init__(self, x, y):

self.x = x

self.y = y

 

def Left_index(points):

minn = 0

for i in range(1,len(points)):

if points[i].x < points[minn].x:

minn = i

elif points[i].x == points[minn].x:

if points[i].y > points[minn].y:

minn = i

return minn

 

def orientation(p, q, r):

val = (q.y - p.y) * (r.x - q.x) - \

(q.x - p.x) * (r.y - q.y)

 

if val == 0:

return 0

elif val > 0:

return 1

else:

return 2

 

def convexHull(points, n):

if n < 3:

return

l = Left_index(points)

hull = []

p = l

q = 0

while(True):

hull.append(p)

q = (p + 1) % n

for i in range(n):

if(orientation(points[p],

points[i], points[q]) == 2):

q = i

p = q

if(p == l):

break

for each in hull:

print(points[each].x, points[each].y)

 

points = []

points.append(Point(0, 3))

points.append(Point(2, 2))

points.append(Point(1, 1))

points.append(Point(2, 1))

points.append(Point(3, 0))

points.append(Point(0, 0))

points.append(Point(3, 3))

convexHull(points, len(points))

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY