Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import matplotlib.pyplot as plt
- def main():
- draw_points()
- def generate_random_points():
- number_of_points = 30
- points = []
- for i in range(0, number_of_points):
- x, y = random.randint(1, 30), random.randint(1, 30)
- points.append((x, y))
- return points
- def draw_points():
- points = generate_random_points()
- graham(points)
- plt.plot(points, 'ro')
- plt.ylabel('Tygrysy')
- plt.show()
- def minimum(points):
- x, y = [], []
- for i in range(0,30):
- x.append(points[i][0])
- y.append(points[i][1])
- minimum_index = y.index(min(item for item in y))
- return x[minimum_index], y[minimum_index]
- def graham(points):
- minimum_x, minimum_y = minimum(points)
- x_moved, y_moved = [], []
- touple_of_moved_points = []
- for i in range(0, 30):
- x_moved.append(points[i][0] - minimum_x)
- y_moved.append(points[i][1] - minimum_y)
- touple_of_moved_points.append((x_moved[i], y_moved[i]))
- plt.plot(touple_of_moved_points, 'bo')
- plt.ylabel('Tygrysy')
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement