Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: pls help me with this prog

Reply
Thread Tools

Re: pls help me with this prog

 
 
88888 Dihedral
Guest
Posts: n/a
 
      10-21-2012
On Friday, October 19, 2012 4:40:42 PM UTC+8, inshu chauhan wrote:
> 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 ;;;;


# assume data is a list of 3 n numbers, n!=0

n3=data.length()
n=n/3
x=sum(data[0:n3:3])/n
y=sum(data[1:n3:3])/n
z=sum(data[2:n3:3])/n #(x,y,z)



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: pls help me with this prog 88888 Dihedral Python 0 10-21-2012 08:09 AM
Re: pls help me with this prog Dennis Lee Bieber Python 0 10-19-2012 09:40 PM
Re: pls help me with this prog rusi Python 0 10-19-2012 01:06 PM
Starting and stopping a prog. from another prog. andoni.oconchubhair@ie.fid-intl.com Java 1 10-22-2006 10:43 PM
pls, help.. i need a number..pls olabanji timothy MCSE 7 09-10-2003 04:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57