I decided to create a visualization of the second problem on the 2011 Math Olympiad competition. I need to create a line which passes through a point, and once it intersects a different point, I need it to rotate about it.
More info: https://artofproblemsolving.com/wiki/index.php?title=2011_IMO_Problems/Problem_2
I currently have two lines starting at the last point in my array of points, but once the line starts rotating, both lines will need to be shifted, and I don't know how to work that out.
import random
import math
from graphics import *
winWidth=300
winHeight=240
def show():
pointSetX = []
pointSetY = []
totalSet = []
'''Displaying all of the points on the screen'''
for i in range(random.randrange(2, 10)):
x = math.floor(random.randrange(0, winWidth))
y = math.floor(random.randrange(0, winWidth))
pt = Point(x, y)
circleForRotation = Circle(pt, 4)
circleForRotation.setFill('white')
circleForRotation.draw(win)
pointSetX.append(x)
pointSetY.append(y)
totalSet = zip(pointSetX, pointSetY)
'''Printing the totalSet to see where all of the points lie'''
print(totalSet)
'''Displaying the line(s) on the screen'''
ln = Line(pt, Point(pt.x, winHeight))
ln2 = Line(pt, Point(pt.x, 0))
ln.setFill('red')
ln2.setFill('blue')
ln2.draw(win)
ln.draw(win)
win = GraphWin('IMO 20011 P2', winWidth, winHeight)
show()
Everything in the code works as expected, but the two lines have the point as an endpoint, and I don't know how to continue with the problem without having one line pass through the point instead of two.