I think, you just invoke your routine the wrong way (probably passing it the entire particle array instead of the array for only one particle.
Anyway, on other possible solution would be to split your array in individual arrays:
import numpy as np
pos = np.array([[200,0], [210,210], [215,215], [192,186]], dtype=float)
lastpos = np.array([[200,2000], [ 210,210], [195, 195], [160,160]], dtype=float)
velocity = np.array([[ 5,5], [8,2], [5,3], [10,-4]], dtype=float)
mass = np.array([ 10, 20, 5, 30 ], dtype=float)
size = np.array([ 15, 25, 15, 30 ], dtype=float)
def moveParticles(pos, lastpos, velocity, dt):
lastpos[:] = pos[:]
pos[:] += velocity * dt
This would make in-place replacement for pos
and lastpos
. In order to move your particles, you would have to invoke the function as:
moveParticles(pos, lastpos, velocity, 1)
where I set dt = 1. I also assumed, that you want to have floating point coordinates, if not, you should generate integer arrays instead.