pls help me with this prog

inshu chauhan insideshoes at gmail.com
Fri Oct 19 04:40:40 EDT 2012


in this prog I have written a code to calculate teh centre of a given 3D data..

but i want to calculate it for every 3 points not the whole data, but
instead of giving me centre for every 3 data the prog is printing the
centre 3 times...

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
    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 data[:3]:
        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)




PLS HELP ;;;;



More information about the Python-list mailing list