|
|
@@ -64,9 +64,9 @@ type |
|
|
|
class function Multiply(const m: TMat3; const v: TBaseType): TMat3; overload; inline; |
|
|
|
class function Multiply(const m: TMat4; const v: TBaseType): TMat4; overload; inline; |
|
|
|
|
|
|
|
class function Invert(const m: TMat2): TMat2; overload; inline; |
|
|
|
class function Invert(const m: TMat3): TMat3; overload; inline; |
|
|
|
class function Invert(const m: TMat4): TMat4; overload; inline; |
|
|
|
class function Invert(m: TMat2): TMat2; overload; inline; |
|
|
|
class function Invert(m: TMat3): TMat3; overload; inline; |
|
|
|
class function Invert(m: TMat4): TMat4; overload; inline; |
|
|
|
|
|
|
|
class function CreateTranslate(const v: TVectorHelper.TVector2): TMat3; |
|
|
|
class function CreateTranslate(const v: TVectorHelper.TVector3): TMat4; |
|
|
@@ -80,8 +80,8 @@ type |
|
|
|
class function CreateShear(const v: TVectorHelper.TVector2): TMat3; |
|
|
|
class function CreateShear(const x, y, z: TVectorHelper.TVector2): TMat4; |
|
|
|
private |
|
|
|
class function GetElement(p: PBaseType; x, y, sz: Integer): TBaseType; // TODO inline; |
|
|
|
class procedure SetElement(p: PBaseType; x, y, sz: Integer; v: TBaseType); // TODO inline; |
|
|
|
class function GetElement(p: PBaseType; x, y, sz: Integer): TBaseType; inline; |
|
|
|
class procedure SetElement(p: PBaseType; x, y, sz: Integer; v: TBaseType); inline; |
|
|
|
|
|
|
|
class procedure Transpose(src, dst: PBaseType; sz: Integer); |
|
|
|
class procedure Sub(src, dst: PBaseType; sz, c, r: Integer); |
|
|
@@ -285,25 +285,30 @@ begin |
|
|
|
Mult(@m[0,0], @result[0,0], 4, 4, v); |
|
|
|
end; |
|
|
|
|
|
|
|
class function TgluMatrixHelper.Invert(const m: TMat2): TMat2; |
|
|
|
class function TgluMatrixHelper.Invert(m: TMat2): TMat2; |
|
|
|
begin |
|
|
|
result[0,0] := m[1,1]; |
|
|
|
result[0,1] := -m[0,1]; |
|
|
|
result[1,0] := -m[1,0]; |
|
|
|
result[1,1] := m[0,0]; |
|
|
|
Mult(@result[0,0], @result[0,0], 2, 2, 1 / Determinant(m)); |
|
|
|
m := result; |
|
|
|
Mult(@m[0,0], @result[0,0], 2, 2, 1 / Determinant(m)); |
|
|
|
end; |
|
|
|
|
|
|
|
class function TgluMatrixHelper.Invert(const m: TMat3): TMat3; |
|
|
|
class function TgluMatrixHelper.Invert(m: TMat3): TMat3; |
|
|
|
var d: TBaseType; |
|
|
|
begin |
|
|
|
result := Adjoint(m); |
|
|
|
Mult(@result[0,0], @result[0,0], 2, 2, 1 / Determinant(m)); |
|
|
|
d := Determinant(m); |
|
|
|
m := Adjoint(m); |
|
|
|
Mult(@m[0,0], @result[0,0], 3, 3, 1 / d); |
|
|
|
end; |
|
|
|
|
|
|
|
class function TgluMatrixHelper.Invert(const m: TMat4): TMat4; |
|
|
|
class function TgluMatrixHelper.Invert(m: TMat4): TMat4; |
|
|
|
var d: TBaseType; |
|
|
|
begin |
|
|
|
d := Determinant(m); |
|
|
|
result := Adjoint(m); |
|
|
|
Mult(@result[0,0], @result[0,0], 3, 3, 1 / Determinant(m)); |
|
|
|
Mult(@m[0,0], @result[0,0], 4, 4, 1 / d); |
|
|
|
end; |
|
|
|
|
|
|
|
class function TgluMatrixHelper.CreateTranslate(const v: TVectorHelper.TVector2): TMat3; |
|
|
|