knotian Posted October 7, 2015 Posted October 7, 2015 I know about single level arrays in EV3 G, but would like to do a mapping program where I need a large 2 dimensional array. Any suggestions? I know I can do it other languages, but I'd like to stay with G for a while. Thanx, Ed Quote
davebarrett Posted October 8, 2015 Posted October 8, 2015 Any fixed-size n-dimensional array can be mapped to a 1 dimensional array. For example, this 3x3 array: 0 1 2 0 a b c 1 d e f 2 g h i 0 1 2 3 4 5 6 7 8 a b c d e f g h i And you can map between them with: oneDimensionalIndex = (twoDimensionalYIndex * twoDimensionalXLength) + twoDimensionalXIndex -- twoDimensionalXIndex = oneDimensionalIndex MOD twoDimensionalXLength twoDimensionalYIndex = (oneDimensionalIndex - twoDimensionalXIndex) / twoDimensionalXLength Hope that helps. Quote
knotian Posted October 8, 2015 Author Posted October 8, 2015 Dave - thanks but I'm not sure if EV3G can handle a 18k+ single array. For the time being I am wanting to stay with EV3G to aid in to the mindstorm learning process. The application involves mapping a 96 by 198 stud environment. Quote
Vectormatic Posted October 8, 2015 Posted October 8, 2015 Dave - thanks but I'm not sure if EV3G can handle a 18k+ single array. For the time being I am wanting to stay with EV3G to aid in to the mindstorm learning process. The application involves mapping a 96 by 198 stud environment. How much data do you want to map per stud? If you want to map only a single bit per stud (as in, there is something there, or there isnt), you can encode 8 studs in a byte, which is especially easy considering your area dimensions are multiples of 8. A single line would be 12 bytes, times 198 gets you under 2.4 KB in memory footprint Otherwise, If you arent affraid of other languages, id look into seeing if there are Java or C/C++ tools for EV3, im not familiar with G, but any more mainstream language is probably more useful for stuff outside of Lego, and it will probably allow you to do more with the EV3 as it is Quote
knotian Posted October 8, 2015 Author Posted October 8, 2015 Vectormatic - now that's thinking!!! good idea!. I'm not afraid of other languages since I've used many over the past 50 years or so. The people I am dealing with are exposed to the Graphical Mindstorm environment and I'd like to push that rather than start them on a new track. Ed Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.