LB Booster
Programming >> Liberty BASIC language >> As I was going to St. Ives...
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1478988260

As I was going to St. Ives...
Post by Alincon on Nov 12th, 2016, 9:04pm

I was trying to visualize an array with more than two dimensions and I thought of the Nursery rhyme:
dim one: wives/folders
dim two: sacks/files
dim three cats/records
dim four kittens/fields

Does anyone have a demo of using an array with more than 3 dimensions that is more practical than this?

I'm guessing that multidimensional arrays might be used in higher math.

r.m.
Re: As I was going to St. Ives...
Post by Richard Russell on Nov 13th, 2016, 09:30am

on Nov 12th, 2016, 9:04pm, Alincon wrote:
Does anyone have a demo of using an array with more than 3 dimensions that is more practical than this?

More than 3 or more than 2? You refer to both options in the question.

I don't know whether it's helpful, but in Bluatigro's recently posted CG animation thread he ideally needs a 3D array, but has simulated it using a 2D array - which is one reason why the program runs so slowly. He has a set of 3D objects, each of which has a position/size/orientation represented by a 4x4 matrix. So altogether it's an array of 2-dimensional arrays, i.e. a 3D array.

Another example would be to use a 3D array to describe the red, green and blue components of an image. The first index might correspond to the x-coordinate, the second index to the y-coordinate and the third index might contain the value 1, 2 or 3 (for R, G and B) to indicate which color component is stored.

You could extend this idea to a 4D array containing a set of 2D images. The first index would be the image number, the second and third indices the x&y coordinates and the fourth index the color component.

Richard.