def CalcCentre(data):
centre = array([0,0,0])
count = 0
for p in data:
centre = add(centre, array(p[:3]))
count += 1
centre = dot(1./count, centre)
return centre
Inshu 0 Newbie Poster
Recommended Answers
Jump to PostAs posted over we need more info,like input data.
Code use Numpy and it use function add() and dot().
To see what these numpy function dos,look into numpy doc here is add()
To test function so it work i guessed for a nested list …
Jump to PostSo the function calculates the barycentre of a set of points in a multidimensional space.
All 5 Replies
richieking 44 Master Poster
snippsat 661 Master Poster
Gribouillis commented: well spotted +13
Gribouillis 1,391 Programming Explorer Team Colleague
Inshu 0 Newbie Poster
Inshu 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.