I would like to work with arrays (math arrays), example: „¡„Ÿ „Ÿ„¢ „¡„Ÿ „Ÿ„¢ „  11 12 13 „  „  11 12 13 „  A = „  21 22 23 „  B = „  21 22 23 „  „  31 32 33 „  „  31 32 33 „  „¤„Ÿ „Ÿ„£ „¤„Ÿ „Ÿ„£ C = A x B What's one good way? Thanks all.
Posted on 2001-04-13 12:56:00 by wolfao
wow! that trash! I' wrote: ....| 11 12 13 |..........| 11 12 13 | A=| 21 22 23 |......B=| 21 22 23 | ....| 31 32 33 |..........| 31 32 33 | C = A x B
Posted on 2001-04-13 13:17:00 by wolfao
This is the topic of my current tutorial, its almost finished, but seeing as you want some help now I'll post some code. I don't have time at the moment but when I post the tutorial tomorrow there'll be a full explanation. I assume you want this matrix maths for your 3D program. Heres a procedure that will multiply 4*4 matrices, easily modified to 3*3 if thats what you need. Note this be not be the best way. Also it assumes the matrices are stored as follows
``````
A  B  C  D        [00] [16] [32] [48]
E  F  G  H   - \  [04] [20] [36] [52]
I  J  K  L   - /  [08] [24] [40] [56]
M  N  O  P        [12] [28] [44] [60]
``````
``````
MulMatrix Proc pMatrix1:DWORD, pMatrix2:DWORD
push edi
push esi
mov edi, pMatrix1
mov esi, pMatrix2
mov ebx, 4
NxtRow:
mov ecx, 4
NxtCol:
fld  real4 ptr
fmul real4 ptr
fld  real4 ptr [16]
fmul real4 ptr [4]
fadd
fld  real4 ptr [32]
fmul real4 ptr [8]
fadd
fld  real4 ptr [48]
fmul real4 ptr [12]
fadd
add edi, 16
dec ecx
jnz NxtCol

fstp real4 ptr [48]
fstp real4 ptr [32]
fstp real4 ptr [16]
fstp real4 ptr
sub edi, 64
add esi, 4
dec ebx
jnz NxtRow
pop esi
pop edi
ret
MulMatrix EndP
``````
This code premultiplies Matrix2 by Matrix1 over writing Matrix2 While linear code would be quicker, a loop is easier to modify. Besides with registers as counters and branch prediction on CPUs this won't slow at all. This message was edited by Zadkiel, on 4/13/2001 1:45:49 PM
Posted on 2001-04-13 13:43:00 by Zadkiel
Thanks very much!!! :) (I'll read your tutorial too... :))
Posted on 2001-04-13 19:34:00 by wolfao