pls can nyone xplain to me what this code is doing xcatly

0

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

As 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 as input data.

from numpy import *
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
print CalcCentre(array([[1,2,3], [4,5,6]]))
#--> [ 2.5 3.5 4.5]

import cv
from math import floor, sqrt, ceil
from numpy import array, dot, subtract, add, linalg as lin
def CalcCentre(data):
centre = array([0,0,0])
count = 0
n = 0
#data = list(data)
for p in data[n:n+3]:
centre = add(centre, array(p[:3]))
count += 1
centre = dot(1./count, centre)
return centre
n += 1
def ReadPointCloud(filename):
f = open(filename)
result = []
for l in f:
sp = l.split()
t = tuple(map(float, sp[1:4]))
result.append(t)
return result
def main (data):
j = 0
for i in len (data):
while j != 3:
centre = CalcCentre(data)
j += 1
print centre
if __name__ == '__main__':
data = ReadPointCloud(r'Z:\data\NEHreflectance_Scanner 1_part.txt')
main(data)

now this is the full prog or code..i want to find the centroid of every three points in a 3D data point cloud... but the code is printing the centroid for whole data 3 times...

also i want to know what does 'dot() ' function do ?? Also why len(data) is not working in the code ??

When I execute this progammatically, I get a table with row heights much larger than when I do this manually.

Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table.

public void AddClipboard()
{
Sel.PasteExcelTable(false,false, false);
var t = Sel.Tables[Sel.Tables.Count];
t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent);
}

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...