- Home /
Bigger matrix?
Hi, I'm new to matrix and I was looking into it because I would need one but all I could find was a 4x4. My use for a matrix would be storing the amount of slots a ship has for every weapon class from one to ten. The classes go from 1 to 10 and there are 20 ships so I would need to be able to access to lets say the amount of class 7 weapons that ship 11 can hold. Is that possible through a single variable/matrix or do I need a new integer with an array of 10 for every ship?
Thanks!
Answer by zharik86 · Mar 15, 2014 at 08:39 AM
Operations with matrixes 4x4 are intended for another. In your case it is necessary to create an array with necessary quantity of variables. For example(write on CSharp):
int[] myMassiv = new int[10]; //One-dimensional array of integer variables at 10 cells in size. Indexes from 0 to 9
Vector3[][] myVec = new Vector3[5][20]; //Two-dimensional array of Vector3. Minimum admissible address of myVec[0][0], maximum admissible address of myVec[4][19].
You can create any class and create an array of your elements of this class. For example, you have a class with the name myClass. Then:
myClass[] myMassiv = new myClass[10];
Certainly, instead of the digits determining the size of an array, it is possible to use variables.
That seems to be exactly what I'm looking for. I will have to look deeper into the matter since a class is not verry clear to me but i have a good idea. Thanks a lot!
Answer by itinerary · Mar 15, 2014 at 04:08 AM
Have a look at 2D Arrays http://www.dotnetperls.com/2d-array
Answer by Eric5h5 · Mar 15, 2014 at 02:15 AM
Those are two different concepts. A Matrix4x4 is a specific construct used normally for transform operations. You don't need a matrix, you just use arrays/classes.
Your answer
Follow this Question
Related Questions
Javascript array questions. 1 Answer
Recursive Tree Loop? How do i make the matrix-array? 3 Answers
IndexOutOfRangeException: Array index is out of range. 1 Answer
Error with an Array 1 Answer
As I compare 4 objects in an array? 2 Answers