class Circle(object):
def __init__(self, center=(0,0), radius=1):
""" Center and radius define a unique circle """
self._center = center
self._radius = radius
...
def isOn(self, point):
if point_on_circle:
return True
return False
...
def get_new_point(self, start=(1,0), distance=1, direction='clockwise'):
""" Inputs:
circle - instance of the Circle() class
start - tuple of (x, y) the exists on circle
distance - distance to travel in radians
direction - 'clockwise' or 'widdershins'
"""
assert circle.isOn(start), "Start point is NOT on the circle"
end = ...
return end
def get_points_on_an_arc(self, x1, y1, x2, y2, large, clockwise, start_distance, end_distance):
""" Your function signature will ONLY work if it is a class method
The alternative is to change the signature and explicitly pass in a Circle() object to the function
"""
s_x, s_y = get_new_point(start=(x1, y1), distance=start_distance, direction='clockwise')
e_x, e_y = get_new_point(start=(x2, y2), distance=end_distance, direction='widdershins')
return s_x, s_y, e_x, e_y
large=false
只是另一种说法,表示“从(x1,y1)顺时针方向”。 - Teemu