0

What's wrong with:
def project_to_distance(point_x, point_y, distance):

 dist_to_origin = math.square_root(point_x ** 2 + point_y ** 2)    


 scale = distance / dist_to_origin
temp1= point_x * scale
temp2= point_y * scale

print temp1, temp2

print project_to_distance(2, 7, 4)

3
Contributors
2
Replies
19
Views
3 Years
Discussion Span
Last Post by HiHe
0

Hint:

def get_distance(x1, y1, x2, y2):
    """
    get_distance(x1, y1, x2, y2)
    returns distance between two points using the pythagorean theorem
    the function parameters are the coordinates of the two points
    """
    dx = x2 - x1
    dy = y2 - y1
    distance = (dx**2 + dy**2)**0.5
    return distance
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.