Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '__name__': 0.07; 'subject:help': 0.07; 'received:mail-qc0-f174.google.com': 0.09; 'teh': 0.09; 'def': 0.10; "'__main__':": 0.16; 'add,': 0.16; 'dot,': 0.16; 'numpy': 0.16; 'prog': 0.16; 'math': 0.20; 'to:name :python-list@python.org': 0.20; 'written': 0.20; 'import': 0.21; 'message-id:@mail.gmail.com': 0.27; 'points': 0.29; 'code': 0.31; 'print': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'data,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'subject:with': 0.36; 'received:209': 0.37; 'received:209.85.216': 0.37; 'data': 0.37; 'instead': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'floor,': 0.65; 'subject:this': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=S7Se9NrajxjM1JGjYRUuPPqo1auwQTPwEqsAsIc0LsQ=; b=qYoKTzbWgBOlyWRcB2/OIrgYF64a+goYtJpOJmk4QvkodOr0IlO3umI4b2OieyyCZQ pHDKfS0lPlp3hu4BIpmPMS4T+WGemYxXwMKK5iisTqxxmIqTrrCF9orsss80djMg/ZQN op5k9cHdNPxCBLdZdhpC0Bubcq68pIMqwgMLXYkHFoFN1SgZhuekUDYoPSW5+lakYr7V h7tj7kxLmx9yQXa+W/XqtloPRa85EEYbT6CuYxQh7MJVQA1bt8GT9oi2WVNKny2Ft6zk IfIFTiQu/Bie9G5Cl6OG6/G4my21FTGiICiHktTKtM0KZRYG6yiQat16YLtIbIZagUzs F7Uw== MIME-Version: 1.0 Date: Fri, 19 Oct 2012 10:40:40 +0200 Subject: pls help me with this prog From: inshu chauhan To: "python-list@python.org" Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350636042 news.xs4all.nl 6958 [2001:888:2000:d::a6]:35282 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31716 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 ;;;;