Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
December 5th, 2012, 06:25 AM
 buzsh
Registered User

Join Date: Dec 2012
Posts: 1
Time spent in forums: 28 m 25 sec
Reputation Power: 0
Defining variables from arrays

Thanks for your interest on this post. I'm trying to model the spread of a circular wave coming out from a point and return an array that gives the amplitude of the wave at certain points.

So with a 4x4 grid, the centre of the wave would be at the centre where the middle lines cross, and in the centre of each space, the height of the wave will be shown by the array output in that position.

The thing is, does anyone know how to use the position in the array as a variable so that I can put it in a function and work out how far that position is from the centre?

Eternal love for you if you can put it in some fairly lay-man speak. Thanks so much

#2
December 5th, 2012, 10:19 AM
 rrashkin
Contributing User

Join Date: May 2012
Location: 39N 104.28W
Posts: 140
Time spent in forums: 2 Days 30 m 4 sec
Reputation Power: 2
First of all, in a 4x4 array, the center, where the diagonals cross, is not a cell, so there is no value there.

Now, let's start at the upper left cell, 0,0 (at least in 1970's conventions). We assume that each cell occupies "a" meters in x and "b" meters in y. So the center of cell, 0,1, being the adjacent cell to the right of the starting cell, is "a" meters from the center of the starting cell in the x-direction and 0 meters from the center of the starting cell in the y-direction. Generally, cell i,j is i*a meters in x and j*b meters in y from the starting cell.

Is that what you were asking?

#3
December 5th, 2012, 10:57 AM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 4,169
Time spent in forums: 1 Month 3 Weeks 2 Days 10 h 13 m
Reputation Power: 455
__________________
[code]Code tags[/code] are essential for python code!

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Defining variables from arrays