calculate part of solid circle in 2D array

2013-11-24 Thread Robert Voigtländer
Hi, I wonder if someone can help me with a function I need for programming my robot. I want to update an 2D occupancy grid based on sonar data. The sonar “view angle” is cone shaped. So I need to calculate all cells of a 30° slice of a filled circle. Something like this:

Re: calculate part of solid circle in 2D array

2013-11-25 Thread Robert Voigtländer
OK. Found a good one here: http://www.daniweb.com/software-development/python/threads/321181/python-bresenham-circle-arc-algorithm Now only filling is needed. Any help is welcome ... Thanks Robert Am Montag, 25. November 2013 08:26:19 UTC+1 schrieb Robert Voigtländer: Hi, I wonder

Re: calculate part of solid circle in 2D array

2013-11-25 Thread Robert Voigtländer
Thanks a lot for the links. I don't need it to be drawn. I need the fields within the arc for some statistical calculations for an occupancy map. So the target is a 2D array, not a picture. Robert -- https://mail.python.org/mailman/listinfo/python-list

Re: calculate part of solid circle in 2D array

2013-11-25 Thread Robert Voigtländer
Great discussion started here  To answer some of the questions and to give more background: - The grid resolution is 1x1cm. The problem starts when the distance of the readings gets high. Then a 1° resolution doesn’t cover all cells anymore. And cells get counted double on short

squeeze out some performance

2013-12-06 Thread Robert Voigtländer
Hi, I try to squeeze out some performance of the code pasted on the link below. http://pastebin.com/gMnqprST The code will be used to continuously analyze sonar sensor data. I set this up to calculate all coordinates in a sonar cone without heavy use of trigonometry (assuming that this way is

Re: squeeze out some performance

2013-12-06 Thread Robert Voigtländer
Thanks for your replies. I already did some basic profiling and optimized a lot. Especially with help of a goof python performance tips list I found. I think I'll follow the cython path. The geometry approach also sound good. But it's way above my math/geometry knowledge. Thanks for your

Re: squeeze out some performance

2013-12-06 Thread Robert Voigtländer
Am Freitag, 6. Dezember 2013 17:36:03 UTC+1 schrieb Mark Lawrence: I already did some basic profiling and optimized a lot. Especially with help of a goof python performance tips list I found. Wonderful typo -^ :) Oh well :-) ... it was a good one. Just had a quick look at Cython.

Re: squeeze out some performance

2013-12-09 Thread Robert Voigtländer
Am Samstag, 7. Dezember 2013 00:01:49 UTC+1 schrieb Dan Stromberg: On Fri, Dec 6, 2013 at 2:38 PM, Mark Lawrence bream...@yahoo.co.uk wrote: On 06/12/2013 16:52, John Ladasky wrote: On Friday, December 6, 2013 12:47:54 AM UTC-8, Robert Voigtländer wrote: I try to squeeze out

Re: squeeze out some performance

2013-12-10 Thread Robert Voigtländer
Actually for optimised code it looks very similar to some code posted here http://www.daniweb.com/software-development/python/threads/321181/python-bresenham-circle-arc-algorithm over three years ago. This is where it origins from. I just extended it for my needs and now want to

min max from tuples in list

2013-12-11 Thread Robert Voigtländer
Hi, I have a list like this: a = [(52, 193), (52, 193), (52, 192), (51, 193), (51, 191), (51, 190), (51, 189), (51, 188), (50, 194), (50, 187), (50, 186), (50, 185), (50, 184), (49, 194), (49, 183), (49, 182), (49, 181), (48, 194), (48, 180), (48, 179), (48, 178), (48, 177), (47, 194), (47,

Re: min max from tuples in list

2013-12-12 Thread Robert Voigtländer
Wow, thanks for the educating answer. I'll work through all the varaints. And yes, I meant keep it unsorted. As I read it, sorting may be required then if I don't want to use the slowest variant. I'll test them all. Thanks Robert -- https://mail.python.org/mailman/listinfo/python-list

Re: min max from tuples in list

2013-12-12 Thread Robert Voigtländer
I've heard the term used often. It means something like, performs well or runs fast. It may or may not be an English word, but that doesn't stop people from using it :-) If google can be used to mean make huge amouts of money with a product that is inherently flawed then I'll happily

use class in class

2014-01-21 Thread Robert Voigtländer
Hi, I have a problem using a class object within another class. It is about the line: self.openlist.append(Node(self.start, None, 0, 0)) If I use it in __init__ it works. If I use it in calcRoute(self) I get the following error: local variable 'node' referenced before assignment The error

Re: use class in class

2014-01-21 Thread Robert Voigtländer
I recommend using a different name for the instances here, probably with a lower-case first letter. That would solve your problem _and_ make your code more readable. Thanks a lot! I was confused by the debuger gifing me the wrong line as containing the error. I changed it regarding your

which data structure to use?

2014-01-21 Thread Robert Voigtländer
Hi, which would be the best data structure to use for the following case? I have objects like this: class Node(object): def __init__(self, pos, parent, g , h): self.pos = pos self.parent = parent self.g = g self.h = h self.f = g+h I need to

Re: which data structure to use?

2014-01-21 Thread Robert Voigtländer
On Tue, Jan 21, 2014 at 03:17:43AM -0800, Robert Voigtl�nder wrote: I have objects like this: class Node(object): def __init__(self, pos, parent, g , h): self.pos = pos self.parent = parent self.g = g self.h = h

Re: which data structure to use?

2014-01-21 Thread Robert Voigtländer
Am Dienstag, 21. Januar 2014 14:38:34 UTC+1 schrieb Robert Voigtländer: On Tue, Jan 21, 2014 at 03:17:43AM -0800, Robert Voigtl�nder wrote: I have objects like this: class Node(object): def __init__(self, pos, parent, g , h

Re: use class in class

2014-01-21 Thread Robert Voigtländer
copy/paste of the whole thing. The actual error message could not have said node, as there's no such name in the method. You are correct. I copied the error before I renamed node into Node. I have to be more consistent here. :-) The source for the error was still the same. --

Re: which data structure to use?

2014-01-21 Thread Robert Voigtländer
Am Dienstag, 21. Januar 2014 15:19:54 UTC+1 schrieb Peter Otten: Peter Otten wrote: def pop(self): f, node = heapq.heappop() del lookup[node.pos] return node That should be def pop(self): f, node =

Re: which data structure to use?

2014-01-21 Thread Robert Voigtländer
def pop(self): f, node = heapq.heappop() del lookup[node.pos] return node That should be def pop(self): f, node = heapq.heappop(self.heap) del self.lookup[node.pos] return node Hi Peter, this works great. I

Re: which data structure to use?

2014-01-22 Thread Robert Voigtländer
Unlikely. Are you sure that .heap and .lookup contents are still in sync with your modification? No it's not. Atfer having read about heapq it's clear why. Thanks for the hint. allows you to delete random nodes, but the lowest() method will slow down as it has to iterate over all dict

generating 2D bit array variants with specific algorythm

2014-11-07 Thread Robert Voigtländer
Hi, I need to generate all variants of a 2D array with variable dimension sizes which fit a specific rule. (up to 200*1000) The rules are: - Values are only 0 or 1 - the sum of each line bust be 1 - only valid results must be generated (generating all and only returning the valid results takes

Re: generating 2D bit array variants with specific algorythm

2014-11-07 Thread Robert Voigtländer
1011 What I mean is do you throw away the carry or does each row have only one zero? Not sure what you mean. Each row must have one 1. The rest must be 0. No combinations not fitting this rule must be generated. -- https://mail.python.org/mailman/listinfo/python-list