Re: pls help me with this prog

Discussion in 'Python' started by rusi, Oct 19, 2012.

  1. rusi

    rusi Guest

    Dont know what your code does/tries to do. Anyway some points:

    On Oct 19, 1:40 pm, 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




    The return makes the for iterate only once
    And n += 1 will never be reached

    > t = tuple(map(float, sp[1:4]))

    drops the sp[0] element.
     
    rusi, Oct 19, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. whoopsi

    help w/ simple GPIB prog.

    whoopsi, Oct 4, 2005, in forum: Python
    Replies:
    1
    Views:
    626
    Torsten Bronger
    Oct 4, 2005
  2. whoopsi

    help w/ simple GPIB prog.

    whoopsi, Oct 4, 2005, in forum: Python
    Replies:
    1
    Views:
    476
    Dietmar Schwertberger
    Oct 4, 2005
  3. -intl.com
    Replies:
    1
    Views:
    381
    Martin Gregorie
    Oct 22, 2006
  4. Dennis Lee Bieber

    Re: pls help me with this prog

    Dennis Lee Bieber, Oct 19, 2012, in forum: Python
    Replies:
    0
    Views:
    161
    Dennis Lee Bieber
    Oct 19, 2012
  5. 88888 Dihedral

    Re: pls help me with this prog

    88888 Dihedral, Oct 21, 2012, in forum: Python
    Replies:
    0
    Views:
    183
    88888 Dihedral
    Oct 21, 2012
Loading...

Share This Page