Question: Python Program: Using our graphics module below, draw a rectangle and a circle inside the rectangle. Now have the circle move inside the rectangle. If

Python Program:

Using our graphics module below, draw a rectangle and a circle inside the rectangle. Now have the circle move inside the rectangle. If the circle touches the wall of the rectangle, it should bounce off the wall in the appropriate direction.

#HELPER FUNCTION TO DRAW ELLIPSE def ellipse(centerPoint, xradius, yradius, ang=pi, Nb=100):  '''ra - major axis length  rb - minor axis length  ang - angle  x0,y0 - position of center of ellipse  Nb - No. of points that make an ellipse   based on matlab code ellipse.m written by D.G. Long,  Brigham Young University, based on the  CIRCLES.m original  written by Peter Blattner, Institute of Microtechnology,  University of  Neuchatel, Switzerland, blattner@imt.unine.ch  '''  if xradius >= yradius:  ra = max(xradius * 2, yradius * 2) rb = min(xradius * 2, yradius * 2) else:  ra = min(xradius * 2, yradius * 2) rb = max(xradius * 2, yradius * 2) x0 = centerPoint.X y0 = centerPoint.Y xpos, ypos = x0, y0 radm, radn = ra, rb an = ang   co, si = cos(an), sin(an) the = linspace(0, 2 * pi, Nb) X = radm * cos(the) * co - si * radn * sin(the) + xpos Y = radm * cos(the) * si + co * radn * sin(the) + ypos return X, Y 

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!