Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97947
| From | Bartc <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Nearest neighbours of points |
| Date | 2015-10-25 12:36 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n0ii97$7fe$1@dont-email.me> (permalink) |
| References | <81947104-f6dd-48b3-ba7b-f03b0c5b6f39@googlegroups.com> <2be81eec-e7dc-4c83-a578-f8c15eb4c1dc@googlegroups.com> |
On 24/10/2015 23:44, Poul Riis wrote: > def calc_dist(p1,p2): > return math.sqrt((p2[0] - p1[0]) ** 2 + > (p2[1] - p1[1]) ** 2 + > (p2[2] - p1[2]) ** 2) > dist=calc_dist(pts[i],pts[j]) > if n==0: > distold=dist > else: > if dist <distold: Just to compare two distances, you can probably work with the squares. You don't need the square root in calc_dist. You will need it for the final report, but that's only one square root, not thousands or millions. -- Bartc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Nearest neighbours of points Poul Riis <priisdk@gmail.com> - 2015-10-24 13:05 -0700
Re: Nearest neighbours of points Christian Gollwitzer <auriocus@gmx.de> - 2015-10-24 22:45 +0200
Re: Nearest neighbours of points Poul Riis <priisdk@gmail.com> - 2015-10-24 15:44 -0700
Re: Nearest neighbours of points Christian Gollwitzer <auriocus@gmx.de> - 2015-10-25 09:55 +0100
Re: Nearest neighbours of points Poul Riis <priisdk@gmail.com> - 2015-10-25 05:00 -0700
Re: Nearest neighbours of points Peter Pearson <pkpearson@nowhere.invalid> - 2015-10-25 17:01 +0000
Re: Nearest neighbours of points Bartc <bc@freeuk.com> - 2015-10-25 12:36 +0000
Re: Nearest neighbours of points Fabien <fabien.maussion@gmail.com> - 2015-10-26 03:25 +0100
Re: Nearest neighbours of points Tom P <werotizy@freent.dd> - 2015-10-31 22:28 +0100
Re: Nearest neighbours of points Terry Reedy <tjreedy@udel.edu> - 2015-10-31 23:00 -0400
csiph-web