Coverage for navipy/moving/maths.py : 92%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Mathematical computation are done in this module. Those involve mostly geometry, and predefined grids shapes """
'on_cubic_grid': { 'param': ['grid_spacing'], 'describe': "Agent restricted to move on a grid"}, 'free_run': { 'param': [], 'describe': "Freely moving agent, pos(t+dt)=pos+speed (dt=1)"}}
"""return the future position knowing speed and current position
:param motion_vec: the position and speed of the agent (pandas Series with columns ['x','y','z','dx','dy','dz']) :param grid_spacing: the spacing between two grid points (only relevant for regular grids) :param grid_mode: the type of grid.
..todo: add literal include for supported_grid_mode """ 'move mode must is not supported {}'.format(move_mode)) ('location', 'dz')] names=['position', 'orientation']) # speed = motion_vec.loc[['dx', 'dy', 'dz']] # speed in spherical coord np.sqrt(speed['location']['dx']**2 + speed['location']['dy']**2)) # scaling = 0 else: ('location', 'dz')] names=['position', 'orientation']) epsilon < (np.pi / 8)) else:
else: # scaling = 1 elif move_mode is 'free_run': pass # scaling = 1 # <=> dt = 1, user need to scale speed in dt units else: raise ValueError('grid_mode is not supported')
"""Return the closest position from a list of positions
:param pos: the position to find (a pandas Series with ['x','y','z'] :param positions: the possible closest positions (a pandas dataframe with [['location','x'],['location','y'],['location','z']]) """
(pos['location']['x'] - positions['location']['x'])**2 + (pos['location']['y'] - positions['location']['y'])**2 + (pos['location']['z'] - positions['location']['z'])**2)
"""Return the closest position from a list of positions
:param pos: the position to find (a pandas Series with ['x','y','z'] :param database: the possible closest positions (a pandas dataframe with ['x','y','z']) """ raise NameError('Not implemated') |