Hello!
A simple question. I translated this 4x4 matrix multiply code from a C function:
Code:
function gr_Multiply(
const M1, M2: gr_aMatrix4x4
): gr_aMatrix4x4;
var
I, J, K: Integer;
begin
Result := gr_Matrix4x4;
for I := 0 to 3 do
for J := 0 to 3 do
for K := 0 to 3 do
Result[I,J] := Result[I,J]+M1[I,K]*M2[K,J];
end;
Now I need a 3x3 matrix multiply, so I just reduced the size of the For loops:
Code:
function gr_Multiply(
const M1, M2: gr_aMatrix3x3
): gr_aMatrix3x3;
var
I, J, K: Integer;
begin
Result := gr_Matrix3x3;
for I := 0 to 2 do
for J := 0 to 2 do
for K := 0 to 2 do
Result[I,J] := Result[I,J]+M1[I,K]*M2[K,J];
end;
Is this code ok? :?
Bookmarks