[SciPy-user] Centroid Calculation

Brian Cole brianc at temple.edu
Mon Jan 30 16:04:15 CST 2006


I'm a NumPy newbie. What is the NumPy way of doing this?
n=0
centroid_x=0
centroid_y=0
centroid_z=0
for x, y, z in catesian_coords:
    centroid_x+=x
    centroid_y+=y
    centroid_z+=z
    n+=1
centroid_x/=n
centroid_y/=n
centroid_z/=n

Or am I entirely missing the point of NumPy?

Thanks,
Brian



More information about the SciPy-user mailing list