I&C SCI 32 Lecture 16: spots_model.py

18 views2 pages

Document Summary

Spot_radius_frac= 0. 05 class spot: def __init__(self, center: point. point, radius_frac: float): Initialize a newly-created spot object, given its center point (a point object) and the spot"s radius (in fractional coordinates). self. _center = center self. _radius_frac = radius_frac def center(self) -> point. point: Returns a point object representing this spot"s center. return self. _center def radius_frac(self): Returns the radius of this spot, in terms of fractional coordinates. return self. _radius_frac def contains(self, point: point. point) -> bool: Returns true if the given point object lies within this spot, false otherwise. # since point objects know how to calculate a distance. # between themselves and other point objects, all we. # need to do is ask the center point how far it is. # from the given point; if that"s less than or equal. # to the radius, the given point is within the spot. return self. _center. frac_distance_from(point) <= self. _radius_frac class spotsstate: def __init__(self):

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions