#This program computes and displays the intersection points of a horizontal #line with a circle centered at the origin. import graphics as gph import math as mth def main(): #User Instructions and Get Input print("This program computes and displays the intersection points") print("of a horizantal line at y = (a number) with a circle of radisu r") print("centered at the origin.\n") radius=float(input("Please input a radius for the circle:")) lineY=float(input("Input a Y value for the line:")) #Create GUI graph=gph.GraphWin("CircleGraph", 500,500) graph.setCoords(-10,-10,10,10) xAxis = gph.Line(gph.Point(-10,0), gph.Point(10,0)) yAxis = gph.Line(gph.Point(0,-10), gph.Point(0,10)) xAxis.setFill("blue") yAxis.setFill("blue") xAxis.setArrow("last") yAxis.setArrow("last") xAxis.draw(graph) yAxis.draw(graph) #cir=gph.Circle(gph.Point(0,0),radius) #cir.draw(graph) gph.Circle(gph.Point(0,0),radius).draw(graph) gph.Line(gph.Point(-10,lineY),gph.Point(10,lineY)).draw(graph) #Compute line-circle intersection points xIntercept1=mth.sqrt((radius**2)-(lineY**2)) xIntercept2=xIntercept1*-1 cirOne=gph.Circle(gph.Point(xIntercept1,lineY), 0.2) cirOne.setFill("red") cirOne.draw(graph) cirTwo=gph.Circle(gph.Point(xIntercept2,lineY), 0.2) cirTwo.setFill("red") cirTwo.draw(graph) main()