Advertisement
Guest User

Calcular ángulo

a guest
Nov 20th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. import turtle
  2.  
  3. def check_if_valid(var):
  4.     while True:
  5.         if var.isdigit():
  6.             break
  7.         else:
  8.             var = input('Enter a valid number ->')
  9.  
  10.  
  11. def get_x_and_y():
  12.     x = input('\'x\' coordinate -> ')
  13.     check_if_valid(x)
  14.     y = input('\'y\' coordinate -> ')
  15.     check_if_valid(y)
  16.     return [int(x),int(y)]
  17.  
  18. print('This program will read in 2 points, and draw 2 lines. \n\
  19. Then it will calculate the acute (smaller) angle \n\
  20. between the 2 lines you draw.')
  21.  
  22. # get coordinates
  23.  
  24.  
  25. print('1st point')
  26. point1 = get_x_and_y()
  27. print('2nd point')
  28. point2 = get_x_and_y()
  29.  
  30. # calculates the acute angle
  31.  
  32. up = point2[1] - point1[1]
  33. down = point2[0] - point1[0]
  34. m = up / down
  35. '''Aquí el problema! ¿Cómo obtener 2 puntos por cada línea?'''
  36.  
  37. # start drawing
  38. turtle.title('Angle Calculator')
  39.  
  40. #multiplicados por 4 para hacer las líneas más grandes.
  41. turtle.goto(point1[0] * 4, point1[1] * 4) #goes to the first point
  42. turtle.goto(point2[0] * 4, point1[1] * 4) # goes to the second point
  43.  
  44. turtle.done()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement