|
-
Jul 14th, 2002, 05:12 PM
#1
Thread Starter
Lively Member
converting multidimensional arrays
ok, now that i have my question about defining multidimensional arrays, how do i convert them. i really just want to know how to convert a 3d array into 2d, as well as a 2d array into a 1d. (im not going to bother converting 3d to 1d, b/c that would be too long of an array when i would rather deal with it in 2d)
example
2d to 1d
VB Code:
dim MyArray(2,2)
dim MyOneDArray(8)
MyOneDArray(0) = MyArray(0,0)
MyOneDArray(1) = MyArray(1,0)
MyOneDArray(2) = MyArray(2,0)
MyOneDArray(3) = MyArray(0,1)
MyOneDArray(4) = MyArray(1,1)
MyOneDArray(5) = MyArray(2,1)
MyOneDArray(6) = MyArray(0,2)
MyOneDArray(7) = MyArray(1,2)
MyOneDArray(8) = MyArray(2,2)
but, ya know, i want to work with a much larger array conversion, and id dont want to have to type all that out...
Last edited by Liquid Pennies; Jul 14th, 2002 at 07:50 PM.
-
Jul 14th, 2002, 05:13 PM
#2
The picture isn't missing
what happens when you convert 2d to 1d
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jul 14th, 2002, 05:16 PM
#3
Thread Starter
Lively Member
i updated my post and gave an example, look at that B/P
-
Jul 14th, 2002, 06:47 PM
#4
What would you expect to happen here:
VB Code:
MyOneDArray(0) = MyArray(0,0)
MyOneDArray(0) = MyArray(2,2)
As you have it you'd be overwriting the (0,0) value with the (2,2) one. Are they numbers to be added? Strings to be appended? What?
-
Jul 14th, 2002, 07:01 PM
#5
Frenzied Member
VB Code:
Dim MyArray(2,2)
Dim MyOneDArray(8)
Dim i as Long, j as Long, ctr As Long
For i = 0 To UBound(MyArray, 1)
For j = 0 To UBound(MyArray, 2)
MyOneDArray(ctr) = MyArray(i, j)
ctr = ctr + 1
Next
Next
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Jul 14th, 2002, 07:51 PM
#6
Thread Starter
Lively Member
i fixed my typo 
and thanks microbasic, but id also like to conver 3d to 2d...how would you do that...?
Last edited by Liquid Pennies; Jul 14th, 2002 at 08:09 PM.
-
Jul 14th, 2002, 08:05 PM
#7
-
Jul 14th, 2002, 08:10 PM
#8
Thread Starter
Lively Member
really, all im trying to figure out, is i want to make a 3d, wireframe cube in a picturebox and i want to increment the x and z coordinates of each point and decrement the y coordnate so that the cube moves. ya know?
really, i just want to know howd you convert your 3d coordanites to 2d coordanites so that i can display them!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|