Advertisement
Guest User

Untitled

a guest
Apr 28th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. import numpy as np
  2.  
  3. def translate(coords):
  4.     '''
  5.    Coords are in the form [(x, y)]
  6.    '''
  7.     x_arr, y_arr = np.array(coords).transpose()
  8.     x_min = x_arr.min()
  9.     y_min = y_arr.min()
  10.  
  11.     if x_min < 0:
  12.         x_arr -= x_min
  13.     if y_min < 0:
  14.         y_arr -= y_min     
  15.    
  16.     trans_coords = np.vstack([x_arr, y_arr]).transpose()
  17.     return trans_coords
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement