Long Shot - Anyone here know how to do matrix transformations in visual C++ 6

SolarKnight

Guardian of the Balance
Joined
Oct 31, 2003
Messages
716
Location
Hertfordshire, England
Hi All

I am currently a student at university studying Computing Science, so I have limited experience with C++ and C, I am aspiring to be able to write games on my own or help write games as part of a company.

The one hurdle I have at the moment is that I have no clue how to perform matrix transformations (well write code to do it for me) so I am unable to program the graphics.

Does anyone here have any Idea how to do this? I know its fairly high level stuff.

Thanks in advance.

SK.
 
Comraddict said:
matrix is basically two dimensional array. go from there.

Did WillJ pay real money for your sig space?
 
SolarKnight said:
The one hurdle I have at the moment is that I have no clue how to perform matrix transformations (well write code to do it for me) so I am unable to program the graphics.

Does anyone here have any Idea how to do this?

1 matrix (array of arrays)

multiplication is 2 nested for loops implementing this:

http://mathworld.wolfram.com/MatrixMultiplication.html

SolarKnight said:
I know its fairly high level stuff.

No it's not, it's just two steps beyond "Hello World". If you cannot implement such a simple data structure you should try another major, perhaps peotry.
 
Thanks for the help, when I said high level, I meant that it would probably be higher level than most peoples understanding, I was under the I mpression that graphics programming was a fairly complicated procedure.

I knew the basic theory, of matrix multiplication I just wasn't sure how to implement it in code.

(Its a bit late for me to change my degree, I am already two years through a 4 year course)
 
SolarKnight said:
Thanks for the help, when I said high level, I meant that it would probably be higher level than most peoples understanding, I was under the I mpression that graphics programming was a fairly complicated procedure.

I knew the basic theory, of matrix multiplication I just wasn't sure how to implement it in code.

(Its a bit late for me to change my degree, I am already two years through a 4 year course)

It's never too late.

But if you really want some code ...

Here's some code in C, which should work in any versio of C++



#include<stdlib.h>

const int SIZE;
int i, j, k;

typedef struct matrix
{
int **m;
} * Matrix;

void initialize (Matrix *M)
{
*M = (Matrix) malloc (sizeof(struct matrix));
(*M)->m = (int**) malloc (SIZE*sizeof(int*));
for(i=0;i<SIZE;++i)
(*M)->m = (int*) malloc (SIZE*sizeof(int));
}

void zero (Matrix M)
{
for(i=0;i<SIZE;++i)
for(j=0;j<SIZE;++j)
M->m[j]=0;
}

Matrix multiply (Matrix M, Matrix N)
{
Matrix prod;
initialize(&prod);
zero(prod);
for(i=0;i<SIZE;++i)
for(j=0;j<SIZE;++j)
for(k=0;k<SIZE;++k)
prod->m[j] += M[k]*N[k][j];
}


I haven't tested it or compiled it yet, so there may be some errors, but I doubt it. Even so, your project will most likely have different parameters than this one, so just take it as a guideline.
 
Thanks nihilistic, I will have a look and see what i can do with it.
 
what kind of matrices are these? are we talking using a graphics library? if so, they would probably have some description of function for this already.
 
Back
Top Bottom