Solutions in place

This commit is contained in:
Chris Proctor 2023-07-30 17:36:43 -04:00
parent e198c13b95
commit d01f07eea0
1 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,7 @@ def clamp(value, low, high):
Returns value if it is between low and high.
If value is lower than low, returns low. If value is higher than high, returns high.
"""
return min(max(low, value), high)
return min(max(low, value), high)
def ratio(value, start, end):
"""Returns a number from 0.0 to 1.0, representing how far along value is from start to end.
@ -32,12 +32,12 @@ def ratio(value, start, end):
def scale(value, domain_min, domain_max, range_min, range_max):
"Given a value within a domain, returns the scaled equivalent within range."
raise NotImplementedError
return range_min + ratio(value, domain_min, domain_max) * (range_max - range_min)
def get_x_values(points):
"Returns the first value for each point in points."
raise NotImplementedError
return [x for x, y in points]
def get_y_values(points):
"Returns the second value for each point in points."
raise NotImplementedError
return [y for x, y in points]