Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Matrix multiplication code anyone?

  1. #1
    Junior Member Regular Contributor
    Join Date
    Nov 2001
    Location
    Malaysia
    Posts
    112

    Matrix multiplication code anyone?

    I just happened to forgot it, could you post the code.
    I store the matrix in an array:

    GLfloat matrix[16];

  2. #2
    Intern Contributor
    Join Date
    Feb 2002
    Location
    Berk
    Posts
    52

    Re: Matrix multiplication code anyone?

    i guess from the 16 elements your using a 4 by 4 matrix, the code for that is avaliable along with a definition a bit like the one you put there from the Game tutorials at http://nehe.gamedev.net/

  3. #3
    Junior Member Regular Contributor
    Join Date
    Nov 2001
    Location
    Malaysia
    Posts
    112

    Re: Matrix multiplication code anyone?

    The method his using I already know, I want the algoritm, you know, using loops to multiply.

    Thanks anyway.

  4. #4
    Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    377

    Re: Matrix multiplication code anyone?

    perhaps it helps if you take a look here http://mathworld.wolfram.com/

  5. #5
    Intern Contributor
    Join Date
    Aug 2001
    Location
    sdddskskfj
    Posts
    62

    Re: Matrix multiplication code anyone?

    Maybe it'll help you!

    void MultiplyMatrix (GLfloat *n1, GLfloat *n2, GLfloat *result) {
    register GLbyte l, c, a;
    GLshort lc;

    for (l=0; l<=3; l++) {
    for (c=0; c<=3; c++) {
    lc = l*c;
    for (a=0; a<=3; a++)
    result[(lc)+c] += n1[(lc)+a] * n2[c + (a*4)];
    }
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •